Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
2d1b2793
Commit
2d1b2793
authored
Dec 15, 2014
by
Brendan Burns
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2905 from smarterclayton/misc_cleanup
Small fixes to prepare for v1beta3
parents
af4fb611
b1b255f9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
53 deletions
+80
-53
test-cmd.sh
hack/test-cmd.sh
+51
-49
apiserver.go
pkg/apiserver/apiserver.go
+17
-4
list.go
pkg/util/list.go
+4
-0
net.go
pkg/util/net.go
+8
-0
No files found.
hack/test-cmd.sh
View file @
2d1b2793
...
@@ -77,15 +77,6 @@ APISERVER_PID=$!
...
@@ -77,15 +77,6 @@ APISERVER_PID=$!
kube::util::wait_for_url
"http://127.0.0.1:
${
API_PORT
}
/healthz"
"apiserver: "
kube::util::wait_for_url
"http://127.0.0.1:
${
API_PORT
}
/healthz"
"apiserver: "
kube_cmd
=(
"
${
KUBE_OUTPUT_HOSTBIN
}
/kubectl"
)
kube_flags
=(
-s
"http://127.0.0.1:
${
API_PORT
}
"
--match-server-version
)
# Start controller manager
# Start controller manager
kube::log::status
"Starting CONTROLLER-MANAGER"
kube::log::status
"Starting CONTROLLER-MANAGER"
"
${
KUBE_OUTPUT_HOSTBIN
}
/kube-controller-manager"
\
"
${
KUBE_OUTPUT_HOSTBIN
}
/kube-controller-manager"
\
...
@@ -95,45 +86,56 @@ CTLRMGR_PID=$!
...
@@ -95,45 +86,56 @@ CTLRMGR_PID=$!
kube::util::wait_for_url
"http://127.0.0.1:
${
CTLRMGR_PORT
}
/healthz"
"controller-manager: "
kube::util::wait_for_url
"http://127.0.0.1:
${
CTLRMGR_PORT
}
/healthz"
"controller-manager: "
kube::log::status
"Testing kubectl(pods)"
kube_cmd
=(
"
${
kube_cmd
[@]
}
"
get pods
"
${
kube_flags
[@]
}
"
"
${
KUBE_OUTPUT_HOSTBIN
}
/kubectl"
"
${
kube_cmd
[@]
}
"
create
-f
examples/guestbook/redis-master.json
"
${
kube_flags
[@]
}
"
)
"
${
kube_cmd
[@]
}
"
get pods
"
${
kube_flags
[@]
}
"
kube_api_versions
=(
"
${
kube_cmd
[@]
}
"
get pod redis-master
"
${
kube_flags
[@]
}
"
v1beta1
[[
"
$(
"
${
kube_cmd
[@]
}
"
get pod redis-master
-o
template
--output-version
=
v1beta1
-t
'{{ .id }}'
"
${
kube_flags
[@]
}
"
)
"
==
"redis-master"
]]
v1beta2
output_pod
=
$(
"
${
kube_cmd
[@]
}
"
get pod redis-master
-o
json
--output-version
=
v1beta1
"
${
kube_flags
[@]
}
"
)
)
"
${
kube_cmd
[@]
}
"
delete pod redis-master
"
${
kube_flags
[@]
}
"
for
version
in
"
${
kube_api_versions
[@]
}
"
;
do
[[
$(
"
${
kube_cmd
[@]
}
"
get pods
-o
template
-t
'{{ len .items }}'
"
${
kube_flags
[@]
}
"
)
-eq
0
]]
kube_flags
=(
echo
$output_pod
|
"
${
kube_cmd
[@]
}
"
create
-f
-
"
${
kube_flags
[@]
}
"
-s
"http://127.0.0.1:
${
API_PORT
}
"
[[
$(
"
${
kube_cmd
[@]
}
"
get pods
-o
template
-t
'{{ len .items }}'
"
${
kube_flags
[@]
}
"
)
-eq
1
]]
--match-server-version
"
${
kube_cmd
[@]
}
"
get pods
-o
yaml
"
${
kube_flags
[@]
}
"
|
grep
-q
"id: redis-master"
--api-version
=
"
${
version
}
"
"
${
kube_cmd
[@]
}
"
describe pod redis-master
"
${
kube_flags
[@]
}
"
|
grep
-q
'Name:.*redis-master'
)
"
${
kube_cmd
[@]
}
"
delete
-f
examples/guestbook/redis-master.json
"
${
kube_flags
[@]
}
"
kube::log::status
"Testing kubectl(pods)"
kube::log::status
"Testing kubectl(services)"
"
${
kube_cmd
[@]
}
"
get pods
"
${
kube_flags
[@]
}
"
"
${
kube_cmd
[@]
}
"
get services
"
${
kube_flags
[@]
}
"
"
${
kube_cmd
[@]
}
"
create
-f
examples/guestbook/redis-master.json
"
${
kube_flags
[@]
}
"
"
${
kube_cmd
[@]
}
"
create
-f
examples/guestbook/frontend-service.json
"
${
kube_flags
[@]
}
"
"
${
kube_cmd
[@]
}
"
get pods
"
${
kube_flags
[@]
}
"
"
${
kube_cmd
[@]
}
"
get services
"
${
kube_flags
[@]
}
"
"
${
kube_cmd
[@]
}
"
get pod redis-master
"
${
kube_flags
[@]
}
"
"
${
kube_cmd
[@]
}
"
delete service frontend
"
${
kube_flags
[@]
}
"
[[
"
$(
"
${
kube_cmd
[@]
}
"
get pod redis-master
-o
template
--output-version
=
v1beta1
-t
'{{ .id }}'
"
${
kube_flags
[@]
}
"
)
"
==
"redis-master"
]]
output_pod
=
$(
"
${
kube_cmd
[@]
}
"
get pod redis-master
-o
json
--output-version
=
v1beta1
"
${
kube_flags
[@]
}
"
)
kube::log::status
"Testing kubectl(replicationcontrollers)"
"
${
kube_cmd
[@]
}
"
delete pod redis-master
"
${
kube_flags
[@]
}
"
"
${
kube_cmd
[@]
}
"
get replicationcontrollers
"
${
kube_flags
[@]
}
"
before
=
"
$(
"
${
kube_cmd
[@]
}
"
get pods
-o
template
-t
'{{ len .items }}'
"
${
kube_flags
[@]
}
"
)
"
"
${
kube_cmd
[@]
}
"
create
-f
examples/guestbook/frontend-controller.json
"
${
kube_flags
[@]
}
"
echo
$output_pod
|
"
${
kube_cmd
[@]
}
"
create
-f
-
"
${
kube_flags
[@]
}
"
"
${
kube_cmd
[@]
}
"
get replicationcontrollers
"
${
kube_flags
[@]
}
"
after
=
"
$(
"
${
kube_cmd
[@]
}
"
get pods
-o
template
-t
'{{ len .items }}'
"
${
kube_flags
[@]
}
"
)
"
"
${
kube_cmd
[@]
}
"
describe replicationcontroller frontendController
"
${
kube_flags
[@]
}
"
|
grep
-q
'Replicas:.*3 desired'
[[
"
$((${
after
}
-
${
before
}))
"
-eq
1
]]
"
${
kube_cmd
[@]
}
"
get pods
-o
yaml
"
${
kube_flags
[@]
}
"
|
grep
-q
"id: redis-master"
kube::log::status
"Testing kubectl(minions)"
"
${
kube_cmd
[@]
}
"
describe pod redis-master
"
${
kube_flags
[@]
}
"
|
grep
-q
'Name:.*redis-master'
"
${
kube_cmd
[@]
}
"
get minions
"
${
kube_flags
[@]
}
"
"
${
kube_cmd
[@]
}
"
delete
-f
examples/guestbook/redis-master.json
"
${
kube_flags
[@]
}
"
"
${
kube_cmd
[@]
}
"
get minions 127.0.0.1
"
${
kube_flags
[@]
}
"
kube::log::status
"Testing kubectl(services)"
kube::log::status
"Testing kubectl(nodes)"
"
${
kube_cmd
[@]
}
"
get services
"
${
kube_flags
[@]
}
"
"
${
kube_cmd
[@]
}
"
get nodes
"
${
kube_flags
[@]
}
"
"
${
kube_cmd
[@]
}
"
create
-f
examples/guestbook/frontend-service.json
"
${
kube_flags
[@]
}
"
"
${
kube_cmd
[@]
}
"
describe nodes 127.0.0.1
"
${
kube_flags
[@]
}
"
"
${
kube_cmd
[@]
}
"
get services
"
${
kube_flags
[@]
}
"
"
${
kube_cmd
[@]
}
"
delete service frontend
"
${
kube_flags
[@]
}
"
kube::log::status
"Testing kubectl(replicationcontrollers)"
"
${
kube_cmd
[@]
}
"
get replicationcontrollers
"
${
kube_flags
[@]
}
"
"
${
kube_cmd
[@]
}
"
create
-f
examples/guestbook/frontend-controller.json
"
${
kube_flags
[@]
}
"
"
${
kube_cmd
[@]
}
"
get replicationcontrollers
"
${
kube_flags
[@]
}
"
"
${
kube_cmd
[@]
}
"
describe replicationcontroller frontendController
"
${
kube_flags
[@]
}
"
|
grep
-q
'Replicas:.*3 desired'
"
${
kube_cmd
[@]
}
"
delete rc frontendController
"
${
kube_flags
[@]
}
"
kube::log::status
"Testing kubectl(minions)"
"
${
kube_cmd
[@]
}
"
get minions
"
${
kube_flags
[@]
}
"
"
${
kube_cmd
[@]
}
"
get minions 127.0.0.1
"
${
kube_flags
[@]
}
"
kube::log::status
"Testing kubectl(nodes)"
"
${
kube_cmd
[@]
}
"
get nodes
"
${
kube_flags
[@]
}
"
"
${
kube_cmd
[@]
}
"
describe nodes 127.0.0.1
"
${
kube_flags
[@]
}
"
done
kube::log::status
"TEST PASSED"
kube::log::status
"TEST PASSED"
# Start proxy
#PROXY_LOG=/tmp/kube-proxy.log
#${KUBE_OUTPUT_HOSTBIN}/kube-proxy \
# --etcd_servers="http://127.0.0.1:${ETCD_PORT}" 1>&2 &
#PROXY_PID=$!
pkg/apiserver/apiserver.go
View file @
2d1b2793
...
@@ -19,6 +19,7 @@ package apiserver
...
@@ -19,6 +19,7 @@ package apiserver
import
(
import
(
"bytes"
"bytes"
"encoding/json"
"encoding/json"
"fmt"
"io/ioutil"
"io/ioutil"
"net/http"
"net/http"
"path"
"path"
...
@@ -283,16 +284,14 @@ func APIVersionHandler(versions ...string) restful.RouteFunction {
...
@@ -283,16 +284,14 @@ func APIVersionHandler(versions ...string) restful.RouteFunction {
func
writeJSON
(
statusCode
int
,
codec
runtime
.
Codec
,
object
runtime
.
Object
,
w
http
.
ResponseWriter
)
{
func
writeJSON
(
statusCode
int
,
codec
runtime
.
Codec
,
object
runtime
.
Object
,
w
http
.
ResponseWriter
)
{
output
,
err
:=
codec
.
Encode
(
object
)
output
,
err
:=
codec
.
Encode
(
object
)
if
err
!=
nil
{
if
err
!=
nil
{
// Note: If codec is broken, this results in an infinite recursion
errorJSONFatal
(
err
,
codec
,
w
)
errorJSON
(
err
,
codec
,
w
)
return
return
}
}
// PR #2243: Pretty-print JSON by default.
// PR #2243: Pretty-print JSON by default.
formatted
:=
&
bytes
.
Buffer
{}
formatted
:=
&
bytes
.
Buffer
{}
err
=
json
.
Indent
(
formatted
,
output
,
""
,
" "
)
err
=
json
.
Indent
(
formatted
,
output
,
""
,
" "
)
if
err
!=
nil
{
if
err
!=
nil
{
// Note: If codec is broken, this results in an infinite recursion
errorJSONFatal
(
err
,
codec
,
w
)
errorJSON
(
err
,
codec
,
w
)
return
return
}
}
w
.
Header
()
.
Set
(
"Content-Type"
,
"application/json"
)
w
.
Header
()
.
Set
(
"Content-Type"
,
"application/json"
)
...
@@ -306,6 +305,20 @@ func errorJSON(err error, codec runtime.Codec, w http.ResponseWriter) {
...
@@ -306,6 +305,20 @@ func errorJSON(err error, codec runtime.Codec, w http.ResponseWriter) {
writeJSON
(
status
.
Code
,
codec
,
status
,
w
)
writeJSON
(
status
.
Code
,
codec
,
status
,
w
)
}
}
// errorJSONFatal renders an error to the response, and if codec fails will render plaintext
func
errorJSONFatal
(
err
error
,
codec
runtime
.
Codec
,
w
http
.
ResponseWriter
)
{
status
:=
errToAPIStatus
(
err
)
output
,
err
:=
codec
.
Encode
(
status
)
if
err
!=
nil
{
w
.
WriteHeader
(
status
.
Code
)
fmt
.
Fprintf
(
w
,
"%s: %s"
,
status
.
Reason
,
status
.
Message
)
return
}
w
.
Header
()
.
Set
(
"Content-Type"
,
"application/json"
)
w
.
WriteHeader
(
status
.
Code
)
w
.
Write
(
output
)
}
// writeRawJSON writes a non-API object in JSON.
// writeRawJSON writes a non-API object in JSON.
func
writeRawJSON
(
statusCode
int
,
object
interface
{},
w
http
.
ResponseWriter
)
{
func
writeRawJSON
(
statusCode
int
,
object
interface
{},
w
http
.
ResponseWriter
)
{
// PR #2243: Pretty-print JSON by default.
// PR #2243: Pretty-print JSON by default.
...
...
pkg/util/list.go
View file @
2d1b2793
...
@@ -33,3 +33,7 @@ func (sl *StringList) Set(value string) error {
...
@@ -33,3 +33,7 @@ func (sl *StringList) Set(value string) error {
}
}
return
nil
return
nil
}
}
func
(
*
StringList
)
Type
()
string
{
return
"stringList"
}
pkg/util/net.go
View file @
2d1b2793
...
@@ -37,6 +37,10 @@ func (ip *IP) Set(value string) error {
...
@@ -37,6 +37,10 @@ func (ip *IP) Set(value string) error {
return
nil
return
nil
}
}
func
(
*
IP
)
Type
()
string
{
return
"ip"
}
// IPNet adapts net.IPNet for use as a flag.
// IPNet adapts net.IPNet for use as a flag.
type
IPNet
net
.
IPNet
type
IPNet
net
.
IPNet
...
@@ -53,3 +57,7 @@ func (ipnet *IPNet) Set(value string) error {
...
@@ -53,3 +57,7 @@ func (ipnet *IPNet) Set(value string) error {
*
ipnet
=
IPNet
(
*
n
)
*
ipnet
=
IPNet
(
*
n
)
return
nil
return
nil
}
}
func
(
*
IPNet
)
Type
()
string
{
return
"ipNet"
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment