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
dcfcf315
Commit
dcfcf315
authored
Dec 12, 2014
by
Brendan Burns
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Add an api object for the kubelet, and a versioned endpoint."
This reverts commit
d4b99793
.
parent
121a291a
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
44 additions
and
122 deletions
+44
-122
integration.go
cmd/integration/integration.go
+1
-1
register.go
pkg/api/register.go
+0
-2
serialization_test.go
pkg/api/serialization_test.go
+1
-1
types.go
pkg/api/types.go
+0
-7
types.go
pkg/api/v1beta1/types.go
+0
-6
register.go
pkg/api/v1beta2/register.go
+0
-2
types.go
pkg/api/v1beta2/types.go
+0
-6
register.go
pkg/api/v1beta3/register.go
+0
-2
types.go
pkg/api/v1beta3/types.go
+0
-7
kubelet.go
pkg/client/kubelet.go
+13
-15
kubelet_test.go
pkg/client/kubelet_test.go
+5
-9
server.go
pkg/kubelet/server.go
+3
-33
pod_cache.go
pkg/master/pod_cache.go
+4
-4
pod_cache_test.go
pkg/master/pod_cache_test.go
+13
-23
rest.go
pkg/registry/pod/rest.go
+2
-2
rest_test.go
pkg/registry/pod/rest_test.go
+2
-2
No files found.
cmd/integration/integration.go
View file @
dcfcf315
...
...
@@ -62,7 +62,7 @@ var (
type
fakeKubeletClient
struct
{}
func
(
fakeKubeletClient
)
GetPodInfo
(
host
,
podNamespace
,
podID
string
)
(
api
.
Pod
Container
Info
,
error
)
{
func
(
fakeKubeletClient
)
GetPodInfo
(
host
,
podNamespace
,
podID
string
)
(
api
.
PodInfo
,
error
)
{
// This is a horrible hack to get around the fact that we can't provide
// different port numbers per kubelet...
var
c
client
.
PodInfoGetter
...
...
pkg/api/register.go
View file @
dcfcf315
...
...
@@ -25,7 +25,6 @@ var Scheme = runtime.NewScheme()
func
init
()
{
Scheme
.
AddKnownTypes
(
""
,
&
PodContainerInfo
{},
&
PodList
{},
&
Pod
{},
&
ReplicationControllerList
{},
...
...
@@ -53,7 +52,6 @@ func init() {
Scheme
.
AddKnownTypeWithName
(
""
,
"MinionList"
,
&
NodeList
{})
}
func
(
*
PodContainerInfo
)
IsAnAPIObject
()
{}
func
(
*
Pod
)
IsAnAPIObject
()
{}
func
(
*
PodList
)
IsAnAPIObject
()
{}
func
(
*
ReplicationController
)
IsAnAPIObject
()
{}
...
...
pkg/api/serialization_test.go
View file @
dcfcf315
...
...
@@ -203,7 +203,7 @@ func TestList(t *testing.T) {
api
.
Scheme
.
Log
(
nil
)
}
var
nonRoundTrippableTypes
=
util
.
NewStringSet
(
"ContainerManifest"
,
"PodContainerInfo"
)
var
nonRoundTrippableTypes
=
util
.
NewStringSet
(
"ContainerManifest"
)
var
nonInternalRoundTrippableTypes
=
util
.
NewStringSet
(
"List"
)
func
TestRoundTripTypes
(
t
*
testing
.
T
)
{
...
...
pkg/api/types.go
View file @
dcfcf315
...
...
@@ -410,13 +410,6 @@ type ContainerStatus struct {
// PodInfo contains one entry for every container with available info.
type
PodInfo
map
[
string
]
ContainerStatus
// PodContainerInfo is a wrapper for PodInfo that can be encode/decoded
type
PodContainerInfo
struct
{
TypeMeta
`json:",inline"`
ObjectMeta
`json:"metadata,omitempty"`
ContainerInfo
PodInfo
`json:"containerInfo"`
}
type
RestartPolicyAlways
struct
{}
// TODO(dchen1107): Define what kinds of failures should restart.
...
...
pkg/api/v1beta1/types.go
View file @
dcfcf315
...
...
@@ -366,12 +366,6 @@ type ContainerStatus struct {
// PodInfo contains one entry for every container with available info.
type
PodInfo
map
[
string
]
ContainerStatus
// PodContainerInfo is a wrapper for PodInfo that can be encode/decoded
type
PodContainerInfo
struct
{
TypeMeta
`json:",inline"`
ContainerInfo
PodInfo
`json:"containerInfo" description:"information about each container in this pod"`
}
type
RestartPolicyAlways
struct
{}
// TODO(dchen1107): Define what kinds of failures should restart
...
...
pkg/api/v1beta2/register.go
View file @
dcfcf315
...
...
@@ -31,7 +31,6 @@ func init() {
api
.
Scheme
.
AddKnownTypes
(
"v1beta2"
,
&
Pod
{},
&
PodContainerInfo
{},
&
PodList
{},
&
ReplicationController
{},
&
ReplicationControllerList
{},
...
...
@@ -59,7 +58,6 @@ func init() {
}
func
(
*
Pod
)
IsAnAPIObject
()
{}
func
(
*
PodContainerInfo
)
IsAnAPIObject
()
{}
func
(
*
PodList
)
IsAnAPIObject
()
{}
func
(
*
ReplicationController
)
IsAnAPIObject
()
{}
func
(
*
ReplicationControllerList
)
IsAnAPIObject
()
{}
...
...
pkg/api/v1beta2/types.go
View file @
dcfcf315
...
...
@@ -331,12 +331,6 @@ type ContainerStatus struct {
// PodInfo contains one entry for every container with available info.
type
PodInfo
map
[
string
]
ContainerStatus
// PodContainerInfo is a wrapper for PodInfo that can be encode/decoded
type
PodContainerInfo
struct
{
TypeMeta
`json:",inline"`
ContainerInfo
PodInfo
`json:"containerInfo" description:"information about each container in this pod"`
}
type
RestartPolicyAlways
struct
{}
// TODO(dchen1107): Define what kinds of failures should restart.
...
...
pkg/api/v1beta3/register.go
View file @
dcfcf315
...
...
@@ -26,7 +26,6 @@ var Codec = runtime.CodecFor(api.Scheme, "v1beta3")
func
init
()
{
api
.
Scheme
.
AddKnownTypes
(
"v1beta3"
,
&
PodContainerInfo
{},
&
Pod
{},
&
PodList
{},
&
PodTemplate
{},
...
...
@@ -54,7 +53,6 @@ func init() {
api
.
Scheme
.
AddKnownTypeWithName
(
"v1beta3"
,
"MinionList"
,
&
NodeList
{})
}
func
(
*
PodContainerInfo
)
IsAnAPIObject
()
{}
func
(
*
Pod
)
IsAnAPIObject
()
{}
func
(
*
PodList
)
IsAnAPIObject
()
{}
func
(
*
PodTemplate
)
IsAnAPIObject
()
{}
...
...
pkg/api/v1beta3/types.go
View file @
dcfcf315
...
...
@@ -427,13 +427,6 @@ type ContainerStatus struct {
// PodInfo contains one entry for every container with available info.
type
PodInfo
map
[
string
]
ContainerStatus
// PodContainerInfo is a wrapper for PodInfo that can be encode/decoded
type
PodContainerInfo
struct
{
TypeMeta
`json:",inline"`
ObjectMeta
`json:"metadata,omitempty"`
ContainerInfo
PodInfo
`json:"containerInfo" description:"information about each container in this pod"`
}
type
RestartPolicyAlways
struct
{}
// TODO(dchen1107): Define what kinds of failures should restart.
...
...
pkg/client/kubelet.go
View file @
dcfcf315
...
...
@@ -17,16 +17,15 @@ limitations under the License.
package
client
import
(
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"log"
"net"
"net/http"
"strconv"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
"github.com/GoogleCloudPlatform/kubernetes/pkg/health"
)
...
...
@@ -49,7 +48,7 @@ type KubeletHealthChecker interface {
type
PodInfoGetter
interface
{
// GetPodInfo returns information about all containers which are part
// Returns an api.PodInfo, or an error if one occurs.
GetPodInfo
(
host
,
podNamespace
,
podID
string
)
(
api
.
Pod
Container
Info
,
error
)
GetPodInfo
(
host
,
podNamespace
,
podID
string
)
(
api
.
PodInfo
,
error
)
}
// HTTPKubeletClient is the default implementation of PodInfoGetter and KubeletHealthchecker, accesses the kubelet over HTTP.
...
...
@@ -90,36 +89,35 @@ func (c *HTTPKubeletClient) url(host string) string {
}
// GetPodInfo gets information about the specified pod.
func
(
c
*
HTTPKubeletClient
)
GetPodInfo
(
host
,
podNamespace
,
podID
string
)
(
api
.
Pod
Container
Info
,
error
)
{
func
(
c
*
HTTPKubeletClient
)
GetPodInfo
(
host
,
podNamespace
,
podID
string
)
(
api
.
PodInfo
,
error
)
{
request
,
err
:=
http
.
NewRequest
(
"GET"
,
fmt
.
Sprintf
(
"%s/
api/v1beta1/
podInfo?podID=%s&podNamespace=%s"
,
"%s/podInfo?podID=%s&podNamespace=%s"
,
c
.
url
(
host
),
podID
,
podNamespace
),
nil
)
info
:=
api
.
PodContainerInfo
{}
if
err
!=
nil
{
return
info
,
err
return
nil
,
err
}
response
,
err
:=
c
.
Client
.
Do
(
request
)
if
err
!=
nil
{
return
info
,
err
return
nil
,
err
}
defer
response
.
Body
.
Close
()
if
response
.
StatusCode
==
http
.
StatusNotFound
{
return
info
,
ErrPodInfoNotAvailable
return
nil
,
ErrPodInfoNotAvailable
}
body
,
err
:=
ioutil
.
ReadAll
(
response
.
Body
)
if
err
!=
nil
{
return
info
,
err
return
nil
,
err
}
// Check that this data can be unmarshalled
log
.
Printf
(
"FOOO: %s"
,
string
(
body
))
err
=
latest
.
Codec
.
DecodeInto
(
body
,
&
info
)
info
:=
api
.
PodInfo
{}
err
=
json
.
Unmarshal
(
body
,
&
info
)
if
err
!=
nil
{
return
info
,
err
return
nil
,
err
}
return
info
,
nil
}
...
...
@@ -134,8 +132,8 @@ func (c *HTTPKubeletClient) HealthCheck(host string) (health.Status, error) {
type
FakeKubeletClient
struct
{}
// GetPodInfo is a fake implementation of PodInfoGetter.GetPodInfo.
func
(
c
FakeKubeletClient
)
GetPodInfo
(
host
,
podNamespace
string
,
podID
string
)
(
api
.
Pod
Container
Info
,
error
)
{
return
api
.
Pod
Container
Info
{},
errors
.
New
(
"Not Implemented"
)
func
(
c
FakeKubeletClient
)
GetPodInfo
(
host
,
podNamespace
string
,
podID
string
)
(
api
.
PodInfo
,
error
)
{
return
api
.
PodInfo
{},
errors
.
New
(
"Not Implemented"
)
}
func
(
c
FakeKubeletClient
)
HealthCheck
(
host
string
)
(
health
.
Status
,
error
)
{
...
...
pkg/client/kubelet_test.go
View file @
dcfcf315
...
...
@@ -31,10 +31,8 @@ import (
)
func
TestHTTPKubeletClient
(
t
*
testing
.
T
)
{
expectObj
:=
api
.
PodContainerInfo
{
ContainerInfo
:
map
[
string
]
api
.
ContainerStatus
{
"myID"
:
{},
},
expectObj
:=
api
.
PodInfo
{
"myID"
:
api
.
ContainerStatus
{},
}
body
,
err
:=
json
.
Marshal
(
expectObj
)
if
err
!=
nil
{
...
...
@@ -70,16 +68,14 @@ func TestHTTPKubeletClient(t *testing.T) {
}
// reflect.DeepEqual(expectObj, gotObj) doesn't handle blank times well
if
len
(
gotObj
.
ContainerInfo
)
!=
len
(
expectObj
.
ContainerInfo
)
{
if
len
(
gotObj
)
!=
len
(
expectObj
)
{
t
.
Errorf
(
"Unexpected response. Expected: %#v, received %#v"
,
expectObj
,
gotObj
)
}
}
func
TestHTTPKubeletClientNotFound
(
t
*
testing
.
T
)
{
expectObj
:=
api
.
PodContainerInfo
{
ContainerInfo
:
map
[
string
]
api
.
ContainerStatus
{
"myID"
:
{},
},
expectObj
:=
api
.
PodInfo
{
"myID"
:
api
.
ContainerStatus
{},
}
_
,
err
:=
json
.
Marshal
(
expectObj
)
if
err
!=
nil
{
...
...
pkg/kubelet/server.go
View file @
dcfcf315
...
...
@@ -35,7 +35,6 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/healthz"
"github.com/GoogleCloudPlatform/kubernetes/pkg/httplog"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/ghodss/yaml"
"github.com/golang/glog"
"github.com/google/cadvisor/info"
...
...
@@ -92,8 +91,7 @@ func NewServer(host HostInterface, updates chan<- interface{}, enableDebuggingHa
// InstallDefaultHandlers registers the default set of supported HTTP request patterns with the mux.
func
(
s
*
Server
)
InstallDefaultHandlers
()
{
healthz
.
InstallHandler
(
s
.
mux
)
s
.
mux
.
HandleFunc
(
"/podInfo"
,
s
.
handlePodInfoOld
)
s
.
mux
.
HandleFunc
(
"/api/v1beta1/podInfo"
,
s
.
handlePodInfoVersioned
)
s
.
mux
.
HandleFunc
(
"/podInfo"
,
s
.
handlePodInfo
)
s
.
mux
.
HandleFunc
(
"/boundPods"
,
s
.
handleBoundPods
)
s
.
mux
.
HandleFunc
(
"/stats/"
,
s
.
handleStats
)
s
.
mux
.
HandleFunc
(
"/spec/"
,
s
.
handleSpec
)
...
...
@@ -251,16 +249,8 @@ func (s *Server) handleBoundPods(w http.ResponseWriter, req *http.Request) {
w
.
Write
(
data
)
}
func
(
s
*
Server
)
handlePodInfoOld
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
s
.
handlePodInfo
(
w
,
req
,
false
)
}
func
(
s
*
Server
)
handlePodInfoVersioned
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
s
.
handlePodInfo
(
w
,
req
,
true
)
}
// handlePodInfo handles podInfo requests against the Kubelet
func
(
s
*
Server
)
handlePodInfo
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
,
versioned
bool
)
{
func
(
s
*
Server
)
handlePodInfo
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
u
,
err
:=
url
.
ParseRequestURI
(
req
.
RequestURI
)
if
err
!=
nil
{
s
.
error
(
w
,
err
)
...
...
@@ -296,7 +286,7 @@ func (s *Server) handlePodInfo(w http.ResponseWriter, req *http.Request, version
s
.
error
(
w
,
err
)
return
}
data
,
err
:=
exportPodInfo
(
info
,
versioned
)
data
,
err
:=
json
.
Marshal
(
info
)
if
err
!=
nil
{
s
.
error
(
w
,
err
)
return
...
...
@@ -447,23 +437,3 @@ func (s *Server) serveStats(w http.ResponseWriter, req *http.Request) {
w
.
Write
(
data
)
return
}
func
exportPodInfo
(
info
api
.
PodInfo
,
versioned
bool
)
([]
byte
,
error
)
{
if
versioned
{
// TODO: support arbitrary versions here
codec
,
err
:=
findCodec
(
"v1beta1"
)
if
err
!=
nil
{
return
nil
,
err
}
return
codec
.
Encode
(
&
api
.
PodContainerInfo
{
ContainerInfo
:
info
})
}
return
json
.
Marshal
(
info
)
}
func
findCodec
(
version
string
)
(
runtime
.
Codec
,
error
)
{
versions
,
err
:=
latest
.
InterfacesFor
(
version
)
if
err
!=
nil
{
return
nil
,
err
}
return
versions
.
Codec
,
nil
}
pkg/master/pod_cache.go
View file @
dcfcf315
...
...
@@ -33,7 +33,7 @@ type PodCache struct {
containerInfo
client
.
PodInfoGetter
pods
pod
.
Registry
// This is a map of pod id to a map of container name to the
podInfo
map
[
string
]
api
.
Pod
Container
Info
podInfo
map
[
string
]
api
.
PodInfo
podLock
sync
.
Mutex
}
...
...
@@ -42,7 +42,7 @@ func NewPodCache(info client.PodInfoGetter, pods pod.Registry) *PodCache {
return
&
PodCache
{
containerInfo
:
info
,
pods
:
pods
,
podInfo
:
map
[
string
]
api
.
Pod
Container
Info
{},
podInfo
:
map
[
string
]
api
.
PodInfo
{},
}
}
...
...
@@ -54,12 +54,12 @@ func makePodCacheKey(podNamespace, podID string) string {
// GetPodInfo implements the PodInfoGetter.GetPodInfo.
// The returned value should be treated as read-only.
// TODO: Remove the host from this call, it's totally unnecessary.
func
(
p
*
PodCache
)
GetPodInfo
(
host
,
podNamespace
,
podID
string
)
(
api
.
Pod
Container
Info
,
error
)
{
func
(
p
*
PodCache
)
GetPodInfo
(
host
,
podNamespace
,
podID
string
)
(
api
.
PodInfo
,
error
)
{
p
.
podLock
.
Lock
()
defer
p
.
podLock
.
Unlock
()
value
,
ok
:=
p
.
podInfo
[
makePodCacheKey
(
podNamespace
,
podID
)]
if
!
ok
{
return
api
.
PodContainerInfo
{}
,
client
.
ErrPodInfoNotAvailable
return
nil
,
client
.
ErrPodInfoNotAvailable
}
return
value
,
nil
}
...
...
pkg/master/pod_cache_test.go
View file @
dcfcf315
...
...
@@ -28,11 +28,11 @@ type FakePodInfoGetter struct {
host
string
id
string
namespace
string
data
api
.
Pod
Container
Info
data
api
.
PodInfo
err
error
}
func
(
f
*
FakePodInfoGetter
)
GetPodInfo
(
host
,
namespace
,
id
string
)
(
api
.
Pod
Container
Info
,
error
)
{
func
(
f
*
FakePodInfoGetter
)
GetPodInfo
(
host
,
namespace
,
id
string
)
(
api
.
PodInfo
,
error
)
{
f
.
host
=
host
f
.
id
=
id
f
.
namespace
=
namespace
...
...
@@ -42,15 +42,11 @@ func (f *FakePodInfoGetter) GetPodInfo(host, namespace, id string) (api.PodConta
func
TestPodCacheGetDifferentNamespace
(
t
*
testing
.
T
)
{
cache
:=
NewPodCache
(
nil
,
nil
)
expectedDefault
:=
api
.
PodContainerInfo
{
ContainerInfo
:
api
.
PodInfo
{
"foo"
:
api
.
ContainerStatus
{},
},
expectedDefault
:=
api
.
PodInfo
{
"foo"
:
api
.
ContainerStatus
{},
}
expectedOther
:=
api
.
PodContainerInfo
{
ContainerInfo
:
api
.
PodInfo
{
"bar"
:
api
.
ContainerStatus
{},
},
expectedOther
:=
api
.
PodInfo
{
"bar"
:
api
.
ContainerStatus
{},
}
cache
.
podInfo
[
makePodCacheKey
(
api
.
NamespaceDefault
,
"foo"
)]
=
expectedDefault
...
...
@@ -76,10 +72,8 @@ func TestPodCacheGetDifferentNamespace(t *testing.T) {
func
TestPodCacheGet
(
t
*
testing
.
T
)
{
cache
:=
NewPodCache
(
nil
,
nil
)
expected
:=
api
.
PodContainerInfo
{
ContainerInfo
:
api
.
PodInfo
{
"foo"
:
api
.
ContainerStatus
{},
},
expected
:=
api
.
PodInfo
{
"foo"
:
api
.
ContainerStatus
{},
}
cache
.
podInfo
[
makePodCacheKey
(
api
.
NamespaceDefault
,
"foo"
)]
=
expected
...
...
@@ -99,16 +93,14 @@ func TestPodCacheGetMissing(t *testing.T) {
if
err
==
nil
{
t
.
Errorf
(
"Unexpected non-error: %#v"
,
err
)
}
if
!
reflect
.
DeepEqual
(
info
,
api
.
PodContainerInfo
{})
{
if
info
!=
nil
{
t
.
Errorf
(
"Unexpected info: %#v"
,
info
)
}
}
func
TestPodGetPodInfoGetter
(
t
*
testing
.
T
)
{
expected
:=
api
.
PodContainerInfo
{
ContainerInfo
:
api
.
PodInfo
{
"foo"
:
api
.
ContainerStatus
{},
},
expected
:=
api
.
PodInfo
{
"foo"
:
api
.
ContainerStatus
{},
}
fake
:=
FakePodInfoGetter
{
data
:
expected
,
...
...
@@ -141,10 +133,8 @@ func TestPodUpdateAllContainers(t *testing.T) {
pods
:=
[]
api
.
Pod
{
pod
}
mockRegistry
:=
registrytest
.
NewPodRegistry
(
&
api
.
PodList
{
Items
:
pods
})
expected
:=
api
.
PodContainerInfo
{
ContainerInfo
:
api
.
PodInfo
{
"foo"
:
api
.
ContainerStatus
{},
},
expected
:=
api
.
PodInfo
{
"foo"
:
api
.
ContainerStatus
{},
}
fake
:=
FakePodInfoGetter
{
data
:
expected
,
...
...
pkg/registry/pod/rest.go
View file @
dcfcf315
...
...
@@ -230,8 +230,8 @@ func (rs *REST) fillPodInfo(pod *api.Pod) {
return
}
}
pod
.
Status
.
Info
=
info
.
ContainerInfo
netContainerInfo
,
ok
:=
pod
.
Status
.
I
nfo
[
"net"
]
pod
.
Status
.
Info
=
info
netContainerInfo
,
ok
:=
i
nfo
[
"net"
]
if
ok
{
if
netContainerInfo
.
PodIP
!=
""
{
pod
.
Status
.
PodIP
=
netContainerInfo
.
PodIP
...
...
pkg/registry/pod/rest_test.go
View file @
dcfcf315
...
...
@@ -566,8 +566,8 @@ type FakePodInfoGetter struct {
err
error
}
func
(
f
*
FakePodInfoGetter
)
GetPodInfo
(
host
,
podNamespace
string
,
podID
string
)
(
api
.
Pod
Container
Info
,
error
)
{
return
api
.
PodContainerInfo
{
ContainerInfo
:
f
.
info
}
,
f
.
err
func
(
f
*
FakePodInfoGetter
)
GetPodInfo
(
host
,
podNamespace
string
,
podID
string
)
(
api
.
PodInfo
,
error
)
{
return
f
.
info
,
f
.
err
}
func
TestFillPodInfo
(
t
*
testing
.
T
)
{
...
...
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