mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +00:00
Merge pull request #3487 from thockin/uid_type
Move util.UID to pkg/types
This commit is contained in:
commit
1d0c36a494
@ -18,7 +18,7 @@ package meta
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// VersionInterfaces contains the interfaces one should use for dealing with types of a particular version.
|
// VersionInterfaces contains the interfaces one should use for dealing with types of a particular version.
|
||||||
@ -37,8 +37,8 @@ type Interface interface {
|
|||||||
SetNamespace(namespace string)
|
SetNamespace(namespace string)
|
||||||
Name() string
|
Name() string
|
||||||
SetName(name string)
|
SetName(name string)
|
||||||
UID() util.UID
|
UID() types.UID
|
||||||
SetUID(uid util.UID)
|
SetUID(uid types.UID)
|
||||||
APIVersion() string
|
APIVersion() string
|
||||||
SetAPIVersion(version string)
|
SetAPIVersion(version string)
|
||||||
Kind() string
|
Kind() string
|
||||||
@ -72,8 +72,8 @@ type MetadataAccessor interface {
|
|||||||
Name(obj runtime.Object) (string, error)
|
Name(obj runtime.Object) (string, error)
|
||||||
SetName(obj runtime.Object, name string) error
|
SetName(obj runtime.Object, name string) error
|
||||||
|
|
||||||
UID(obj runtime.Object) (util.UID, error)
|
UID(obj runtime.Object) (types.UID, error)
|
||||||
SetUID(obj runtime.Object, uid util.UID) error
|
SetUID(obj runtime.Object, uid types.UID) error
|
||||||
|
|
||||||
SelfLink(obj runtime.Object) (string, error)
|
SelfLink(obj runtime.Object) (string, error)
|
||||||
SetSelfLink(obj runtime.Object, selfLink string) error
|
SetSelfLink(obj runtime.Object, selfLink string) error
|
||||||
|
@ -22,7 +22,7 @@ import (
|
|||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/conversion"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/conversion"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Accessor takes an arbitary object pointer and returns meta.Interface.
|
// Accessor takes an arbitary object pointer and returns meta.Interface.
|
||||||
@ -152,7 +152,7 @@ func (resourceAccessor) SetName(obj runtime.Object, name string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (resourceAccessor) UID(obj runtime.Object) (util.UID, error) {
|
func (resourceAccessor) UID(obj runtime.Object) (types.UID, error) {
|
||||||
accessor, err := Accessor(obj)
|
accessor, err := Accessor(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@ -160,7 +160,7 @@ func (resourceAccessor) UID(obj runtime.Object) (util.UID, error) {
|
|||||||
return accessor.UID(), nil
|
return accessor.UID(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (resourceAccessor) SetUID(obj runtime.Object, uid util.UID) error {
|
func (resourceAccessor) SetUID(obj runtime.Object, uid types.UID) error {
|
||||||
accessor, err := Accessor(obj)
|
accessor, err := Accessor(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -242,7 +242,7 @@ func (resourceAccessor) SetResourceVersion(obj runtime.Object, version string) e
|
|||||||
type genericAccessor struct {
|
type genericAccessor struct {
|
||||||
namespace *string
|
namespace *string
|
||||||
name *string
|
name *string
|
||||||
uid *util.UID
|
uid *types.UID
|
||||||
apiVersion *string
|
apiVersion *string
|
||||||
kind *string
|
kind *string
|
||||||
resourceVersion *string
|
resourceVersion *string
|
||||||
@ -279,14 +279,14 @@ func (a genericAccessor) SetName(name string) {
|
|||||||
*a.name = name
|
*a.name = name
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a genericAccessor) UID() util.UID {
|
func (a genericAccessor) UID() types.UID {
|
||||||
if a.uid == nil {
|
if a.uid == nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
return *a.uid
|
return *a.uid
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a genericAccessor) SetUID(uid util.UID) {
|
func (a genericAccessor) SetUID(uid types.UID) {
|
||||||
if a.uid == nil {
|
if a.uid == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ package api
|
|||||||
import (
|
import (
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -93,7 +94,7 @@ type ObjectMeta struct {
|
|||||||
// UID is the unique in time and space value for this object. It is typically generated by
|
// UID is the unique in time and space value for this object. It is typically generated by
|
||||||
// the server on successful creation of a resource and is not allowed to change on PUT
|
// the server on successful creation of a resource and is not allowed to change on PUT
|
||||||
// operations.
|
// operations.
|
||||||
UID util.UID `json:"uid,omitempty"`
|
UID types.UID `json:"uid,omitempty"`
|
||||||
|
|
||||||
// An opaque value that represents the version of this resource. May be used for optimistic
|
// An opaque value that represents the version of this resource. May be used for optimistic
|
||||||
// concurrency, change detection, and the watch operation on a resource or set of resources.
|
// concurrency, change detection, and the watch operation on a resource or set of resources.
|
||||||
@ -1007,7 +1008,7 @@ type ObjectReference struct {
|
|||||||
Kind string `json:"kind,omitempty"`
|
Kind string `json:"kind,omitempty"`
|
||||||
Namespace string `json:"namespace,omitempty"`
|
Namespace string `json:"namespace,omitempty"`
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
UID util.UID `json:"uid,omitempty"`
|
UID types.UID `json:"uid,omitempty"`
|
||||||
APIVersion string `json:"apiVersion,omitempty"`
|
APIVersion string `json:"apiVersion,omitempty"`
|
||||||
ResourceVersion string `json:"resourceVersion,omitempty"`
|
ResourceVersion string `json:"resourceVersion,omitempty"`
|
||||||
|
|
||||||
@ -1076,7 +1077,7 @@ type ContainerManifest struct {
|
|||||||
// TODO: UUID on Manifest is deprecated in the future once we are done
|
// TODO: UUID on Manifest is deprecated in the future once we are done
|
||||||
// with the API refactoring. It is required for now to determine the instance
|
// with the API refactoring. It is required for now to determine the instance
|
||||||
// of a Pod.
|
// of a Pod.
|
||||||
UUID util.UID `json:"uuid,omitempty"`
|
UUID types.UID `json:"uuid,omitempty"`
|
||||||
Volumes []Volume `json:"volumes"`
|
Volumes []Volume `json:"volumes"`
|
||||||
Containers []Container `json:"containers"`
|
Containers []Container `json:"containers"`
|
||||||
RestartPolicy RestartPolicy `json:"restartPolicy,omitempty"`
|
RestartPolicy RestartPolicy `json:"restartPolicy,omitempty"`
|
||||||
|
@ -18,6 +18,7 @@ package v1beta1
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -56,7 +57,7 @@ type ContainerManifest struct {
|
|||||||
// TODO: UUID on Manifext is deprecated in the future once we are done
|
// TODO: UUID on Manifext is deprecated in the future once we are done
|
||||||
// with the API refactory. It is required for now to determine the instance
|
// with the API refactory. It is required for now to determine the instance
|
||||||
// of a Pod.
|
// of a Pod.
|
||||||
UUID util.UID `json:"uuid,omitempty" description:"manifest UUID"`
|
UUID types.UID `json:"uuid,omitempty" description:"manifest UUID"`
|
||||||
Volumes []Volume `json:"volumes" description:"list of volumes that can be mounted by containers belonging to the pod"`
|
Volumes []Volume `json:"volumes" description:"list of volumes that can be mounted by containers belonging to the pod"`
|
||||||
Containers []Container `json:"containers" description:"list of containers belonging to the pod"`
|
Containers []Container `json:"containers" description:"list of containers belonging to the pod"`
|
||||||
RestartPolicy RestartPolicy `json:"restartPolicy,omitempty" description:"restart policy for all containers within the pod; one of RestartPolicyAlways, RestartPolicyOnFailure, RestartPolicyNever"`
|
RestartPolicy RestartPolicy `json:"restartPolicy,omitempty" description:"restart policy for all containers within the pod; one of RestartPolicyAlways, RestartPolicyOnFailure, RestartPolicyNever"`
|
||||||
@ -297,7 +298,7 @@ type Lifecycle struct {
|
|||||||
type TypeMeta struct {
|
type TypeMeta struct {
|
||||||
Kind string `json:"kind,omitempty" description:"kind of object, in CamelCase"`
|
Kind string `json:"kind,omitempty" description:"kind of object, in CamelCase"`
|
||||||
ID string `json:"id,omitempty" description:"name of the object; must be a DNS_SUBDOMAIN and unique among all objects of the same kind within the same namespace; used in resource URLs"`
|
ID string `json:"id,omitempty" description:"name of the object; must be a DNS_SUBDOMAIN and unique among all objects of the same kind within the same namespace; used in resource URLs"`
|
||||||
UID util.UID `json:"uid,omitempty" description:"UUID assigned by the system upon creation, unique across space and time"`
|
UID types.UID `json:"uid,omitempty" description:"UUID assigned by the system upon creation, unique across space and time"`
|
||||||
CreationTimestamp util.Time `json:"creationTimestamp,omitempty" description:"RFC 3339 date and time at which the object was created; recorded by the system; null for lists"`
|
CreationTimestamp util.Time `json:"creationTimestamp,omitempty" description:"RFC 3339 date and time at which the object was created; recorded by the system; null for lists"`
|
||||||
SelfLink string `json:"selfLink,omitempty" description:"URL for the object"`
|
SelfLink string `json:"selfLink,omitempty" description:"URL for the object"`
|
||||||
ResourceVersion uint64 `json:"resourceVersion,omitempty" description:"string that identifies the internal version of this object that can be used by clients to determine when objects have changed; value must be treated as opaque by clients and passed unmodified back to the server"`
|
ResourceVersion uint64 `json:"resourceVersion,omitempty" description:"string that identifies the internal version of this object that can be used by clients to determine when objects have changed; value must be treated as opaque by clients and passed unmodified back to the server"`
|
||||||
@ -779,7 +780,7 @@ type ObjectReference struct {
|
|||||||
Kind string `json:"kind,omitempty" description:"kind of the referent"`
|
Kind string `json:"kind,omitempty" description:"kind of the referent"`
|
||||||
Namespace string `json:"namespace,omitempty" description:"namespace of the referent"`
|
Namespace string `json:"namespace,omitempty" description:"namespace of the referent"`
|
||||||
ID string `json:"name,omitempty" description:"id of the referent"`
|
ID string `json:"name,omitempty" description:"id of the referent"`
|
||||||
UID util.UID `json:"uid,omitempty" description:"uid of the referent"`
|
UID types.UID `json:"uid,omitempty" description:"uid of the referent"`
|
||||||
APIVersion string `json:"apiVersion,omitempty" description:"API version of the referent"`
|
APIVersion string `json:"apiVersion,omitempty" description:"API version of the referent"`
|
||||||
ResourceVersion string `json:"resourceVersion,omitempty" description:"specific resourceVersion to which this reference is made, if any"`
|
ResourceVersion string `json:"resourceVersion,omitempty" description:"specific resourceVersion to which this reference is made, if any"`
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ package v1beta2
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -260,7 +261,7 @@ type Lifecycle struct {
|
|||||||
type TypeMeta struct {
|
type TypeMeta struct {
|
||||||
Kind string `json:"kind,omitempty" description:"kind of object, in CamelCase"`
|
Kind string `json:"kind,omitempty" description:"kind of object, in CamelCase"`
|
||||||
ID string `json:"id,omitempty" description:"name of the object; must be a DNS_SUBDOMAIN and unique among all objects of the same kind within the same namespace; used in resource URLs"`
|
ID string `json:"id,omitempty" description:"name of the object; must be a DNS_SUBDOMAIN and unique among all objects of the same kind within the same namespace; used in resource URLs"`
|
||||||
UID util.UID `json:"uid,omitempty" description:"UUID assigned by the system upon creation, unique across space and time"`
|
UID types.UID `json:"uid,omitempty" description:"UUID assigned by the system upon creation, unique across space and time"`
|
||||||
CreationTimestamp util.Time `json:"creationTimestamp,omitempty" description:"RFC 3339 date and time at which the object was created; recorded by the system; null for lists"`
|
CreationTimestamp util.Time `json:"creationTimestamp,omitempty" description:"RFC 3339 date and time at which the object was created; recorded by the system; null for lists"`
|
||||||
SelfLink string `json:"selfLink,omitempty" description:"URL for the object"`
|
SelfLink string `json:"selfLink,omitempty" description:"URL for the object"`
|
||||||
ResourceVersion uint64 `json:"resourceVersion,omitempty" description:"string that identifies the internal version of this object that can be used by clients to determine when objects have changed; value must be treated as opaque by clients and passed unmodified back to the server"`
|
ResourceVersion uint64 `json:"resourceVersion,omitempty" description:"string that identifies the internal version of this object that can be used by clients to determine when objects have changed; value must be treated as opaque by clients and passed unmodified back to the server"`
|
||||||
@ -752,7 +753,7 @@ type ObjectReference struct {
|
|||||||
Kind string `json:"kind,omitempty" description:"kind of the referent"`
|
Kind string `json:"kind,omitempty" description:"kind of the referent"`
|
||||||
Namespace string `json:"namespace,omitempty" description:"namespace of the referent"`
|
Namespace string `json:"namespace,omitempty" description:"namespace of the referent"`
|
||||||
ID string `json:"name,omitempty" description:"id of the referent"`
|
ID string `json:"name,omitempty" description:"id of the referent"`
|
||||||
UID util.UID `json:"uid,omitempty" description:"uid of the referent"`
|
UID types.UID `json:"uid,omitempty" description:"uid of the referent"`
|
||||||
APIVersion string `json:"apiVersion,omitempty" description:"API version of the referent"`
|
APIVersion string `json:"apiVersion,omitempty" description:"API version of the referent"`
|
||||||
ResourceVersion string `json:"resourceVersion,omitempty" description:"specific resourceVersion to which this reference is made, if any"`
|
ResourceVersion string `json:"resourceVersion,omitempty" description:"specific resourceVersion to which this reference is made, if any"`
|
||||||
|
|
||||||
@ -825,7 +826,7 @@ type ContainerManifest struct {
|
|||||||
// TODO: UUID on Manifext is deprecated in the future once we are done
|
// TODO: UUID on Manifext is deprecated in the future once we are done
|
||||||
// with the API refactory. It is required for now to determine the instance
|
// with the API refactory. It is required for now to determine the instance
|
||||||
// of a Pod.
|
// of a Pod.
|
||||||
UUID util.UID `json:"uuid,omitempty" description:"manifest UUID"`
|
UUID types.UID `json:"uuid,omitempty" description:"manifest UUID"`
|
||||||
Volumes []Volume `json:"volumes" description:"list of volumes that can be mounted by containers belonging to the pod"`
|
Volumes []Volume `json:"volumes" description:"list of volumes that can be mounted by containers belonging to the pod"`
|
||||||
Containers []Container `json:"containers" description:"list of containers belonging to the pod"`
|
Containers []Container `json:"containers" description:"list of containers belonging to the pod"`
|
||||||
RestartPolicy RestartPolicy `json:"restartPolicy,omitempty" description:"restart policy for all containers within the pod; one of RestartPolicyAlways, RestartPolicyOnFailure, RestartPolicyNever"`
|
RestartPolicy RestartPolicy `json:"restartPolicy,omitempty" description:"restart policy for all containers within the pod; one of RestartPolicyAlways, RestartPolicyOnFailure, RestartPolicyNever"`
|
||||||
|
@ -19,6 +19,7 @@ package v1beta3
|
|||||||
import (
|
import (
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/resource"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -93,7 +94,7 @@ type ObjectMeta struct {
|
|||||||
// UID is the unique in time and space value for this object. It is typically generated by
|
// UID is the unique in time and space value for this object. It is typically generated by
|
||||||
// the server on successful creation of a resource and is not allowed to change on PUT
|
// the server on successful creation of a resource and is not allowed to change on PUT
|
||||||
// operations.
|
// operations.
|
||||||
UID util.UID `json:"uid,omitempty"`
|
UID types.UID `json:"uid,omitempty"`
|
||||||
|
|
||||||
// An opaque value that represents the version of this resource. May be used for optimistic
|
// An opaque value that represents the version of this resource. May be used for optimistic
|
||||||
// concurrency, change detection, and the watch operation on a resource or set of resources.
|
// concurrency, change detection, and the watch operation on a resource or set of resources.
|
||||||
@ -138,7 +139,7 @@ const (
|
|||||||
// // TODO: UUID on Manifest is deprecated in the future once we are done
|
// // TODO: UUID on Manifest is deprecated in the future once we are done
|
||||||
// // with the API refactoring. It is required for now to determine the instance
|
// // with the API refactoring. It is required for now to determine the instance
|
||||||
// // of a Pod.
|
// // of a Pod.
|
||||||
// UUID util.UID `json:"uuid,omitempty"`
|
// UUID types.UID `json:"uuid,omitempty"`
|
||||||
// Volumes []Volume `json:"volumes"`
|
// Volumes []Volume `json:"volumes"`
|
||||||
// Containers []Container `json:"containers"`
|
// Containers []Container `json:"containers"`
|
||||||
// RestartPolicy RestartPolicy `json:"restartPolicy,omitempty"`
|
// RestartPolicy RestartPolicy `json:"restartPolicy,omitempty"`
|
||||||
@ -998,7 +999,7 @@ type ObjectReference struct {
|
|||||||
Kind string `json:"kind,omitempty"`
|
Kind string `json:"kind,omitempty"`
|
||||||
Namespace string `json:"namespace,omitempty"`
|
Namespace string `json:"namespace,omitempty"`
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
UID util.UID `json:"uid,omitempty"`
|
UID types.UID `json:"uid,omitempty"`
|
||||||
APIVersion string `json:"apiVersion,omitempty"`
|
APIVersion string `json:"apiVersion,omitempty"`
|
||||||
ResourceVersion string `json:"resourceVersion,omitempty"`
|
ResourceVersion string `json:"resourceVersion,omitempty"`
|
||||||
|
|
||||||
|
@ -21,14 +21,14 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
)
|
)
|
||||||
|
|
||||||
const defaultHealthyOutput = "ok"
|
const defaultHealthyOutput = "ok"
|
||||||
|
|
||||||
type CommandRunner interface {
|
type CommandRunner interface {
|
||||||
RunInContainer(podFullName string, uid util.UID, containerName string, cmd []string) ([]byte, error)
|
RunInContainer(podFullName string, uid types.UID, containerName string, cmd []string) ([]byte, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type ExecHealthChecker struct {
|
type ExecHealthChecker struct {
|
||||||
@ -39,7 +39,7 @@ func NewExecHealthChecker(runner CommandRunner) HealthChecker {
|
|||||||
return &ExecHealthChecker{runner}
|
return &ExecHealthChecker{runner}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *ExecHealthChecker) HealthCheck(podFullName string, podUID util.UID, status api.PodStatus, container api.Container) (Status, error) {
|
func (e *ExecHealthChecker) HealthCheck(podFullName string, podUID types.UID, status api.PodStatus, container api.Container) (Status, error) {
|
||||||
if container.LivenessProbe.Exec == nil {
|
if container.LivenessProbe.Exec == nil {
|
||||||
return Unknown, fmt.Errorf("missing exec parameters")
|
return Unknown, fmt.Errorf("missing exec parameters")
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FakeExec struct {
|
type FakeExec struct {
|
||||||
@ -31,7 +31,7 @@ type FakeExec struct {
|
|||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FakeExec) RunInContainer(podFullName string, uid util.UID, container string, cmd []string) ([]byte, error) {
|
func (f *FakeExec) RunInContainer(podFullName string, uid types.UID, container string, cmd []string) ([]byte, error) {
|
||||||
f.cmd = cmd
|
f.cmd = cmd
|
||||||
return f.out, f.err
|
return f.out, f.err
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ const (
|
|||||||
|
|
||||||
// HealthChecker defines an abstract interface for checking container health.
|
// HealthChecker defines an abstract interface for checking container health.
|
||||||
type HealthChecker interface {
|
type HealthChecker interface {
|
||||||
HealthCheck(podFullName string, podUID util.UID, status api.PodStatus, container api.Container) (Status, error)
|
HealthCheck(podFullName string, podUID types.UID, status api.PodStatus, container api.Container) (Status, error)
|
||||||
CanCheck(probe *api.LivenessProbe) bool
|
CanCheck(probe *api.LivenessProbe) bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ func (m *muxHealthChecker) findCheckerFor(probe *api.LivenessProbe) HealthChecke
|
|||||||
|
|
||||||
// HealthCheck delegates the health-checking of the container to one of the bundled implementations.
|
// HealthCheck delegates the health-checking of the container to one of the bundled implementations.
|
||||||
// If there is no health checker that can check container it returns Unknown, nil.
|
// If there is no health checker that can check container it returns Unknown, nil.
|
||||||
func (m *muxHealthChecker) HealthCheck(podFullName string, podUID util.UID, status api.PodStatus, container api.Container) (Status, error) {
|
func (m *muxHealthChecker) HealthCheck(podFullName string, podUID types.UID, status api.PodStatus, container api.Container) (Status, error) {
|
||||||
checker := m.findCheckerFor(container.LivenessProbe)
|
checker := m.findCheckerFor(container.LivenessProbe)
|
||||||
if checker == nil {
|
if checker == nil {
|
||||||
glog.Warningf("Failed to find health checker for %s %+v", container.Name, container.LivenessProbe)
|
glog.Warningf("Failed to find health checker for %s %+v", container.Name, container.LivenessProbe)
|
||||||
|
@ -24,6 +24,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
)
|
)
|
||||||
@ -105,7 +106,7 @@ func DoHTTPCheck(url string, client HTTPGetInterface) (Status, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HealthCheck checks if the container is healthy by trying sending HTTP Get requests to the container.
|
// HealthCheck checks if the container is healthy by trying sending HTTP Get requests to the container.
|
||||||
func (h *HTTPHealthChecker) HealthCheck(podFullName string, podUID util.UID, status api.PodStatus, container api.Container) (Status, error) {
|
func (h *HTTPHealthChecker) HealthCheck(podFullName string, podUID types.UID, status api.PodStatus, container api.Container) (Status, error) {
|
||||||
host, port, path, err := getURLParts(status, container)
|
host, port, path, err := getURLParts(status, container)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Unknown, err
|
return Unknown, err
|
||||||
|
@ -22,6 +22,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
)
|
)
|
||||||
@ -74,7 +75,7 @@ func DoTCPCheck(addr string) (Status, error) {
|
|||||||
return Healthy, nil
|
return Healthy, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TCPHealthChecker) HealthCheck(podFullName string, podUID util.UID, status api.PodStatus, container api.Container) (Status, error) {
|
func (t *TCPHealthChecker) HealthCheck(podFullName string, podUID types.UID, status api.PodStatus, container api.Container) (Status, error) {
|
||||||
host, port, err := getTCPAddrParts(status, container)
|
host, port, err := getTCPAddrParts(status, container)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Unknown, err
|
return Unknown, err
|
||||||
|
@ -20,7 +20,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||||
cadvisor "github.com/google/cadvisor/info"
|
cadvisor "github.com/google/cadvisor/info"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ func (kl *Kubelet) statsFromDockerContainer(cc cadvisorInterface, containerId st
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetContainerInfo returns stats (from Cadvisor) for a container.
|
// GetContainerInfo returns stats (from Cadvisor) for a container.
|
||||||
func (kl *Kubelet) GetContainerInfo(podFullName string, uid util.UID, containerName string, req *cadvisor.ContainerInfoRequest) (*cadvisor.ContainerInfo, error) {
|
func (kl *Kubelet) GetContainerInfo(podFullName string, uid types.UID, containerName string, req *cadvisor.ContainerInfoRequest) (*cadvisor.ContainerInfo, error) {
|
||||||
cc := kl.GetCadvisorClient()
|
cc := kl.GetCadvisorClient()
|
||||||
if cc == nil {
|
if cc == nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
@ -22,7 +22,7 @@ import (
|
|||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -53,7 +53,7 @@ func (s sortedPods) Less(i, j int) bool {
|
|||||||
func CreateValidPod(name, namespace, source string) api.BoundPod {
|
func CreateValidPod(name, namespace, source string) api.BoundPod {
|
||||||
return api.BoundPod{
|
return api.BoundPod{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
UID: util.UID(name), // for the purpose of testing, this is unique enough
|
UID: types.UID(name), // for the purpose of testing, this is unique enough
|
||||||
Name: name,
|
Name: name,
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Annotations: map[string]string{kubelet.ConfigSourceAnnotationKey: source},
|
Annotations: map[string]string{kubelet.ConfigSourceAnnotationKey: source},
|
||||||
|
@ -30,6 +30,7 @@ import (
|
|||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
|
|
||||||
"github.com/ghodss/yaml"
|
"github.com/ghodss/yaml"
|
||||||
@ -164,7 +165,7 @@ func extractFromFile(filename string) (api.BoundPod, error) {
|
|||||||
fmt.Fprintf(hasher, "host:%s", hostname)
|
fmt.Fprintf(hasher, "host:%s", hostname)
|
||||||
fmt.Fprintf(hasher, "file:%s", filename)
|
fmt.Fprintf(hasher, "file:%s", filename)
|
||||||
util.DeepHashObject(hasher, pod)
|
util.DeepHashObject(hasher, pod)
|
||||||
pod.UID = util.UID(hex.EncodeToString(hasher.Sum(nil)[0:]))
|
pod.UID = types.UID(hex.EncodeToString(hasher.Sum(nil)[0:]))
|
||||||
glog.V(5).Infof("Generated UID %q for pod %q from file %s", pod.UID, pod.Name, filename)
|
glog.V(5).Infof("Generated UID %q for pod %q from file %s", pod.UID, pod.Name, filename)
|
||||||
}
|
}
|
||||||
if len(pod.Namespace) == 0 {
|
if len(pod.Namespace) == 0 {
|
||||||
|
@ -28,13 +28,13 @@ import (
|
|||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ExampleManifestAndPod(id string) (api.ContainerManifest, api.BoundPod) {
|
func ExampleManifestAndPod(id string) (api.ContainerManifest, api.BoundPod) {
|
||||||
manifest := api.ContainerManifest{
|
manifest := api.ContainerManifest{
|
||||||
ID: id,
|
ID: id,
|
||||||
UUID: util.UID(id),
|
UUID: types.UID(id),
|
||||||
Containers: []api.Container{
|
Containers: []api.Container{
|
||||||
{
|
{
|
||||||
Name: "c" + id,
|
Name: "c" + id,
|
||||||
@ -54,7 +54,7 @@ func ExampleManifestAndPod(id string) (api.ContainerManifest, api.BoundPod) {
|
|||||||
expectedPod := api.BoundPod{
|
expectedPod := api.BoundPod{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Name: id,
|
Name: id,
|
||||||
UID: util.UID(id),
|
UID: types.UID(id),
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Containers: []api.Container{
|
Containers: []api.Container{
|
||||||
|
@ -30,6 +30,7 @@ import (
|
|||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
|
|
||||||
"github.com/ghodss/yaml"
|
"github.com/ghodss/yaml"
|
||||||
@ -147,7 +148,7 @@ func applyDefaults(pod *api.BoundPod, url string) {
|
|||||||
hasher := md5.New()
|
hasher := md5.New()
|
||||||
fmt.Fprintf(hasher, "url:%s", url)
|
fmt.Fprintf(hasher, "url:%s", url)
|
||||||
util.DeepHashObject(hasher, pod)
|
util.DeepHashObject(hasher, pod)
|
||||||
pod.UID = util.UID(hex.EncodeToString(hasher.Sum(nil)[0:]))
|
pod.UID = types.UID(hex.EncodeToString(hasher.Sum(nil)[0:]))
|
||||||
glog.V(5).Infof("Generated UID %q for pod %q from URL %s", pod.UID, pod.Name, url)
|
glog.V(5).Infof("Generated UID %q for pod %q from URL %s", pod.UID, pod.Name, url)
|
||||||
}
|
}
|
||||||
if len(pod.Namespace) == 0 {
|
if len(pod.Namespace) == 0 {
|
||||||
|
@ -31,6 +31,7 @@ import (
|
|||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/credentialprovider"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/credentialprovider"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
docker "github.com/fsouza/go-dockerclient"
|
docker "github.com/fsouza/go-dockerclient"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
@ -254,7 +255,7 @@ func (p throttledDockerPuller) IsImagePresent(name string) (bool, error) {
|
|||||||
// DockerContainers is a map of containers
|
// DockerContainers is a map of containers
|
||||||
type DockerContainers map[DockerID]*docker.APIContainers
|
type DockerContainers map[DockerID]*docker.APIContainers
|
||||||
|
|
||||||
func (c DockerContainers) FindPodContainer(podFullName string, uid util.UID, containerName string) (*docker.APIContainers, bool, uint64) {
|
func (c DockerContainers) FindPodContainer(podFullName string, uid types.UID, containerName string) (*docker.APIContainers, bool, uint64) {
|
||||||
for _, dockerContainer := range c {
|
for _, dockerContainer := range c {
|
||||||
if len(dockerContainer.Names) == 0 {
|
if len(dockerContainer.Names) == 0 {
|
||||||
continue
|
continue
|
||||||
@ -314,7 +315,7 @@ func GetKubeletDockerContainers(client DockerInterface, allContainers bool) (Doc
|
|||||||
|
|
||||||
// GetRecentDockerContainersWithNameAndUUID returns a list of dead docker containers which matches the name
|
// GetRecentDockerContainersWithNameAndUUID returns a list of dead docker containers which matches the name
|
||||||
// and uid given.
|
// and uid given.
|
||||||
func GetRecentDockerContainersWithNameAndUUID(client DockerInterface, podFullName string, uid util.UID, containerName string) ([]*docker.Container, error) {
|
func GetRecentDockerContainersWithNameAndUUID(client DockerInterface, podFullName string, uid types.UID, containerName string) ([]*docker.Container, error) {
|
||||||
var result []*docker.Container
|
var result []*docker.Container
|
||||||
containers, err := client.ListContainers(docker.ListContainersOptions{All: true})
|
containers, err := client.ListContainers(docker.ListContainersOptions{All: true})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -447,7 +448,7 @@ func inspectContainer(client DockerInterface, dockerID, containerName, tPath str
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetDockerPodInfo returns docker info for all containers in the pod/manifest.
|
// GetDockerPodInfo returns docker info for all containers in the pod/manifest.
|
||||||
func GetDockerPodInfo(client DockerInterface, manifest api.PodSpec, podFullName string, uid util.UID) (api.PodInfo, error) {
|
func GetDockerPodInfo(client DockerInterface, manifest api.PodSpec, podFullName string, uid types.UID) (api.PodInfo, error) {
|
||||||
info := api.PodInfo{}
|
info := api.PodInfo{}
|
||||||
expectedContainers := make(map[string]api.Container)
|
expectedContainers := make(map[string]api.Container)
|
||||||
for _, container := range manifest.Containers {
|
for _, container := range manifest.Containers {
|
||||||
@ -545,7 +546,7 @@ func HashContainer(container *api.Container) uint64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Creates a name which can be reversed to identify both full pod name and container name.
|
// Creates a name which can be reversed to identify both full pod name and container name.
|
||||||
func BuildDockerName(podUID util.UID, podFullName string, container *api.Container) string {
|
func BuildDockerName(podUID types.UID, podFullName string, container *api.Container) string {
|
||||||
containerName := container.Name + "." + strconv.FormatUint(HashContainer(container), 16)
|
containerName := container.Name + "." + strconv.FormatUint(HashContainer(container), 16)
|
||||||
return fmt.Sprintf("%s_%s_%s_%s_%08x",
|
return fmt.Sprintf("%s_%s_%s_%s_%08x",
|
||||||
containerNamePrefix,
|
containerNamePrefix,
|
||||||
@ -557,7 +558,7 @@ func BuildDockerName(podUID util.UID, podFullName string, container *api.Contain
|
|||||||
|
|
||||||
// Unpacks a container name, returning the pod full name and container name we would have used to
|
// Unpacks a container name, returning the pod full name and container name we would have used to
|
||||||
// construct the docker name. If the docker name isn't the one we created, we may return empty strings.
|
// construct the docker name. If the docker name isn't the one we created, we may return empty strings.
|
||||||
func ParseDockerName(name string) (podFullName string, podUID util.UID, containerName string, hash uint64) {
|
func ParseDockerName(name string) (podFullName string, podUID types.UID, containerName string, hash uint64) {
|
||||||
// For some reason docker appears to be appending '/' to names.
|
// For some reason docker appears to be appending '/' to names.
|
||||||
// If it's there, strip it.
|
// If it's there, strip it.
|
||||||
if name[0] == '/' {
|
if name[0] == '/' {
|
||||||
@ -590,7 +591,7 @@ func ParseDockerName(name string) (podFullName string, podUID util.UID, containe
|
|||||||
podFullName = parts[2]
|
podFullName = parts[2]
|
||||||
|
|
||||||
// Pod UID.
|
// Pod UID.
|
||||||
podUID = util.UID(parts[3])
|
podUID = types.UID(parts[3])
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import (
|
|||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/credentialprovider"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/credentialprovider"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
docker "github.com/fsouza/go-dockerclient"
|
docker "github.com/fsouza/go-dockerclient"
|
||||||
)
|
)
|
||||||
@ -91,7 +92,7 @@ func verifyPackUnpack(t *testing.T, podNamespace, podUID, podName, containerName
|
|||||||
util.DeepHashObject(hasher, *container)
|
util.DeepHashObject(hasher, *container)
|
||||||
computedHash := uint64(hasher.Sum32())
|
computedHash := uint64(hasher.Sum32())
|
||||||
podFullName := fmt.Sprintf("%s.%s", podName, podNamespace)
|
podFullName := fmt.Sprintf("%s.%s", podName, podNamespace)
|
||||||
name := BuildDockerName(util.UID(podUID), podFullName, container)
|
name := BuildDockerName(types.UID(podUID), podFullName, container)
|
||||||
returnedPodFullName, returnedUID, returnedContainerName, hash := ParseDockerName(name)
|
returnedPodFullName, returnedUID, returnedContainerName, hash := ParseDockerName(name)
|
||||||
if podFullName != returnedPodFullName || podUID != string(returnedUID) || containerName != returnedContainerName || computedHash != hash {
|
if podFullName != returnedPodFullName || podUID != string(returnedUID) || containerName != returnedContainerName || computedHash != hash {
|
||||||
t.Errorf("For (%s, %s, %s, %d), unpacked (%s, %s, %s, %d)", podFullName, podUID, containerName, computedHash, returnedPodFullName, returnedUID, returnedContainerName, hash)
|
t.Errorf("For (%s, %s, %s, %d), unpacked (%s, %s, %s, %d)", podFullName, podUID, containerName, computedHash, returnedPodFullName, returnedUID, returnedContainerName, hash)
|
||||||
|
@ -24,6 +24,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
)
|
)
|
||||||
@ -32,7 +33,7 @@ type execActionHandler struct {
|
|||||||
kubelet *Kubelet
|
kubelet *Kubelet
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *execActionHandler) Run(podFullName string, uid util.UID, container *api.Container, handler *api.Handler) error {
|
func (e *execActionHandler) Run(podFullName string, uid types.UID, container *api.Container, handler *api.Handler) error {
|
||||||
_, err := e.kubelet.RunInContainer(podFullName, uid, container.Name, handler.Exec.Command)
|
_, err := e.kubelet.RunInContainer(podFullName, uid, container.Name, handler.Exec.Command)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -67,7 +68,7 @@ func ResolvePort(portReference util.IntOrString, container *api.Container) (int,
|
|||||||
return -1, fmt.Errorf("couldn't find port: %v in %v", portReference, container)
|
return -1, fmt.Errorf("couldn't find port: %v in %v", portReference, container)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *httpActionHandler) Run(podFullName string, uid util.UID, container *api.Container, handler *api.Handler) error {
|
func (h *httpActionHandler) Run(podFullName string, uid types.UID, container *api.Container, handler *api.Handler) error {
|
||||||
host := handler.HTTPGet.Host
|
host := handler.HTTPGet.Host
|
||||||
if len(host) == 0 {
|
if len(host) == 0 {
|
||||||
var info api.PodInfo
|
var info api.PodInfo
|
||||||
|
@ -41,6 +41,7 @@ import (
|
|||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/envvars"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/envvars"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/errors"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/errors"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume"
|
||||||
@ -205,7 +206,7 @@ func (kl *Kubelet) GetPodsDir() string {
|
|||||||
|
|
||||||
// GetPodDir returns the full path to the per-pod data directory for the
|
// GetPodDir returns the full path to the per-pod data directory for the
|
||||||
// specified pod. This directory may not exist if the pod does not exist.
|
// specified pod. This directory may not exist if the pod does not exist.
|
||||||
func (kl *Kubelet) GetPodDir(podUID util.UID) string {
|
func (kl *Kubelet) GetPodDir(podUID types.UID) string {
|
||||||
// Backwards compat. The "old" stuff should be removed before 1.0
|
// Backwards compat. The "old" stuff should be removed before 1.0
|
||||||
// release. The thinking here is this:
|
// release. The thinking here is this:
|
||||||
// !old && !new = use new
|
// !old && !new = use new
|
||||||
@ -228,14 +229,14 @@ func (kl *Kubelet) GetPodDir(podUID util.UID) string {
|
|||||||
// GetPodVolumesDir returns the full path to the per-pod data directory under
|
// GetPodVolumesDir returns the full path to the per-pod data directory under
|
||||||
// which volumes are created for the specified pod. This directory may not
|
// which volumes are created for the specified pod. This directory may not
|
||||||
// exist if the pod does not exist.
|
// exist if the pod does not exist.
|
||||||
func (kl *Kubelet) GetPodVolumesDir(podUID util.UID) string {
|
func (kl *Kubelet) GetPodVolumesDir(podUID types.UID) string {
|
||||||
return path.Join(kl.GetPodDir(podUID), "volumes")
|
return path.Join(kl.GetPodDir(podUID), "volumes")
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPodContainerDir returns the full path to the per-pod data directory under
|
// GetPodContainerDir returns the full path to the per-pod data directory under
|
||||||
// which container data is held for the specified pod. This directory may not
|
// which container data is held for the specified pod. This directory may not
|
||||||
// exist if the pod or container does not exist.
|
// exist if the pod or container does not exist.
|
||||||
func (kl *Kubelet) GetPodContainerDir(podUID util.UID, ctrName string) string {
|
func (kl *Kubelet) GetPodContainerDir(podUID types.UID, ctrName string) string {
|
||||||
// Backwards compat. The "old" stuff should be removed before 1.0
|
// Backwards compat. The "old" stuff should be removed before 1.0
|
||||||
// release. The thinking here is this:
|
// release. The thinking here is this:
|
||||||
// !old && !new = use new
|
// !old && !new = use new
|
||||||
@ -275,15 +276,15 @@ func (kl *Kubelet) setupDataDirs() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get a list of pods that have data directories.
|
// Get a list of pods that have data directories.
|
||||||
func (kl *Kubelet) listPodsFromDisk() ([]util.UID, error) {
|
func (kl *Kubelet) listPodsFromDisk() ([]types.UID, error) {
|
||||||
podInfos, err := ioutil.ReadDir(kl.GetPodsDir())
|
podInfos, err := ioutil.ReadDir(kl.GetPodsDir())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
pods := []util.UID{}
|
pods := []types.UID{}
|
||||||
for i := range podInfos {
|
for i := range podInfos {
|
||||||
if podInfos[i].IsDir() {
|
if podInfos[i].IsDir() {
|
||||||
pods = append(pods, util.UID(podInfos[i].Name()))
|
pods = append(pods, types.UID(podInfos[i].Name()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pods, nil
|
return pods, nil
|
||||||
@ -527,7 +528,7 @@ func (kl *Kubelet) mountExternalVolumes(pod *api.BoundPod) (volumeMap, error) {
|
|||||||
|
|
||||||
// A basic interface that knows how to execute handlers
|
// A basic interface that knows how to execute handlers
|
||||||
type actionHandler interface {
|
type actionHandler interface {
|
||||||
Run(podFullName string, uid util.UID, container *api.Container, handler *api.Handler) error
|
Run(podFullName string, uid types.UID, container *api.Container, handler *api.Handler) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (kl *Kubelet) newActionHandler(handler *api.Handler) actionHandler {
|
func (kl *Kubelet) newActionHandler(handler *api.Handler) actionHandler {
|
||||||
@ -542,7 +543,7 @@ func (kl *Kubelet) newActionHandler(handler *api.Handler) actionHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (kl *Kubelet) runHandler(podFullName string, uid util.UID, container *api.Container, handler *api.Handler) error {
|
func (kl *Kubelet) runHandler(podFullName string, uid types.UID, container *api.Container, handler *api.Handler) error {
|
||||||
actionHandler := kl.newActionHandler(handler)
|
actionHandler := kl.newActionHandler(handler)
|
||||||
if actionHandler == nil {
|
if actionHandler == nil {
|
||||||
return fmt.Errorf("invalid handler")
|
return fmt.Errorf("invalid handler")
|
||||||
@ -1134,7 +1135,7 @@ func (kl *Kubelet) syncPod(pod *api.BoundPod, dockerContainers dockertools.Docke
|
|||||||
|
|
||||||
type podContainer struct {
|
type podContainer struct {
|
||||||
podFullName string
|
podFullName string
|
||||||
uid util.UID
|
uid types.UID
|
||||||
containerName string
|
containerName string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1197,7 +1198,7 @@ func (kl *Kubelet) SyncPods(pods []api.BoundPod) error {
|
|||||||
glog.V(4).Infof("Desired: %#v", pods)
|
glog.V(4).Infof("Desired: %#v", pods)
|
||||||
var err error
|
var err error
|
||||||
desiredContainers := make(map[podContainer]empty)
|
desiredContainers := make(map[podContainer]empty)
|
||||||
desiredPods := make(map[util.UID]empty)
|
desiredPods := make(map[types.UID]empty)
|
||||||
|
|
||||||
dockerContainers, err := dockertools.GetKubeletDockerContainers(kl.dockerClient, false)
|
dockerContainers, err := dockertools.GetKubeletDockerContainers(kl.dockerClient, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1268,7 +1269,7 @@ func (kl *Kubelet) SyncPods(pods []api.BoundPod) error {
|
|||||||
|
|
||||||
func updateBoundPods(changed []api.BoundPod, current []api.BoundPod) []api.BoundPod {
|
func updateBoundPods(changed []api.BoundPod, current []api.BoundPod) []api.BoundPod {
|
||||||
updated := []api.BoundPod{}
|
updated := []api.BoundPod{}
|
||||||
m := map[util.UID]*api.BoundPod{}
|
m := map[types.UID]*api.BoundPod{}
|
||||||
for i := range changed {
|
for i := range changed {
|
||||||
pod := &changed[i]
|
pod := &changed[i]
|
||||||
m[pod.UID] = pod
|
m[pod.UID] = pod
|
||||||
@ -1376,7 +1377,7 @@ func (kl *Kubelet) GetPodByName(namespace, name string) (*api.BoundPod, bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetPodInfo returns information from Docker about the containers in a pod
|
// GetPodInfo returns information from Docker about the containers in a pod
|
||||||
func (kl *Kubelet) GetPodInfo(podFullName string, uid util.UID) (api.PodInfo, error) {
|
func (kl *Kubelet) GetPodInfo(podFullName string, uid types.UID) (api.PodInfo, error) {
|
||||||
var manifest api.PodSpec
|
var manifest api.PodSpec
|
||||||
for _, pod := range kl.pods {
|
for _, pod := range kl.pods {
|
||||||
if GetPodFullName(&pod) == podFullName {
|
if GetPodFullName(&pod) == podFullName {
|
||||||
@ -1387,7 +1388,7 @@ func (kl *Kubelet) GetPodInfo(podFullName string, uid util.UID) (api.PodInfo, er
|
|||||||
return dockertools.GetDockerPodInfo(kl.dockerClient, manifest, podFullName, uid)
|
return dockertools.GetDockerPodInfo(kl.dockerClient, manifest, podFullName, uid)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (kl *Kubelet) healthy(podFullName string, podUID util.UID, status api.PodStatus, container api.Container, dockerContainer *docker.APIContainers) (health.Status, error) {
|
func (kl *Kubelet) healthy(podFullName string, podUID types.UID, status api.PodStatus, container api.Container, dockerContainer *docker.APIContainers) (health.Status, error) {
|
||||||
// Give the container 60 seconds to start up.
|
// Give the container 60 seconds to start up.
|
||||||
if container.LivenessProbe == nil {
|
if container.LivenessProbe == nil {
|
||||||
return health.Healthy, nil
|
return health.Healthy, nil
|
||||||
@ -1408,7 +1409,7 @@ func (kl *Kubelet) ServeLogs(w http.ResponseWriter, req *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run a command in a container, returns the combined stdout, stderr as an array of bytes
|
// Run a command in a container, returns the combined stdout, stderr as an array of bytes
|
||||||
func (kl *Kubelet) RunInContainer(podFullName string, uid util.UID, container string, cmd []string) ([]byte, error) {
|
func (kl *Kubelet) RunInContainer(podFullName string, uid types.UID, container string, cmd []string) ([]byte, error) {
|
||||||
if kl.runner == nil {
|
if kl.runner == nil {
|
||||||
return nil, fmt.Errorf("no runner specified.")
|
return nil, fmt.Errorf("no runner specified.")
|
||||||
}
|
}
|
||||||
@ -1431,7 +1432,7 @@ func (kl *Kubelet) BirthCry() {
|
|||||||
ref := &api.ObjectReference{
|
ref := &api.ObjectReference{
|
||||||
Kind: "Minion",
|
Kind: "Minion",
|
||||||
Name: kl.hostname,
|
Name: kl.hostname,
|
||||||
UID: util.UID(kl.hostname),
|
UID: types.UID(kl.hostname),
|
||||||
Namespace: api.NamespaceDefault,
|
Namespace: api.NamespaceDefault,
|
||||||
}
|
}
|
||||||
record.Eventf(ref, "starting", "Starting kubelet.")
|
record.Eventf(ref, "starting", "Starting kubelet.")
|
||||||
|
@ -33,6 +33,7 @@ import (
|
|||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/health"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/health"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/volume"
|
||||||
"github.com/fsouza/go-dockerclient"
|
"github.com/fsouza/go-dockerclient"
|
||||||
@ -808,7 +809,7 @@ func TestSyncPodDeletesDuplicate(t *testing.T) {
|
|||||||
|
|
||||||
type FalseHealthChecker struct{}
|
type FalseHealthChecker struct{}
|
||||||
|
|
||||||
func (f *FalseHealthChecker) HealthCheck(podFullName string, podUID util.UID, status api.PodStatus, container api.Container) (health.Status, error) {
|
func (f *FalseHealthChecker) HealthCheck(podFullName string, podUID types.UID, status api.PodStatus, container api.Container) (health.Status, error) {
|
||||||
return health.Unhealthy, nil
|
return health.Unhealthy, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ import (
|
|||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/healthz"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/healthz"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/httplog"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/httplog"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"github.com/google/cadvisor/info"
|
"github.com/google/cadvisor/info"
|
||||||
)
|
)
|
||||||
@ -62,13 +62,13 @@ func ListenAndServeKubeletServer(host HostInterface, address net.IP, port uint,
|
|||||||
// HostInterface contains all the kubelet methods required by the server.
|
// HostInterface contains all the kubelet methods required by the server.
|
||||||
// For testablitiy.
|
// For testablitiy.
|
||||||
type HostInterface interface {
|
type HostInterface interface {
|
||||||
GetContainerInfo(podFullName string, uid util.UID, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error)
|
GetContainerInfo(podFullName string, uid types.UID, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error)
|
||||||
GetRootInfo(req *info.ContainerInfoRequest) (*info.ContainerInfo, error)
|
GetRootInfo(req *info.ContainerInfoRequest) (*info.ContainerInfo, error)
|
||||||
GetMachineInfo() (*info.MachineInfo, error)
|
GetMachineInfo() (*info.MachineInfo, error)
|
||||||
GetBoundPods() ([]api.BoundPod, error)
|
GetBoundPods() ([]api.BoundPod, error)
|
||||||
GetPodByName(namespace, name string) (*api.BoundPod, bool)
|
GetPodByName(namespace, name string) (*api.BoundPod, bool)
|
||||||
GetPodInfo(name string, uid util.UID) (api.PodInfo, error)
|
GetPodInfo(name string, uid types.UID) (api.PodInfo, error)
|
||||||
RunInContainer(name string, uid util.UID, container string, cmd []string) ([]byte, error)
|
RunInContainer(name string, uid types.UID, container string, cmd []string) ([]byte, error)
|
||||||
GetKubeletContainerLogs(podFullName, containerName, tail string, follow bool, stdout, stderr io.Writer) error
|
GetKubeletContainerLogs(podFullName, containerName, tail string, follow bool, stdout, stderr io.Writer) error
|
||||||
ServeLogs(w http.ResponseWriter, req *http.Request)
|
ServeLogs(w http.ResponseWriter, req *http.Request)
|
||||||
}
|
}
|
||||||
@ -204,7 +204,7 @@ func (s *Server) handlePodInfo(w http.ResponseWriter, req *http.Request, version
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
podID := u.Query().Get("podID")
|
podID := u.Query().Get("podID")
|
||||||
podUID := util.UID(u.Query().Get("UUID"))
|
podUID := types.UID(u.Query().Get("UUID"))
|
||||||
podNamespace := u.Query().Get("podNamespace")
|
podNamespace := u.Query().Get("podNamespace")
|
||||||
if len(podID) == 0 {
|
if len(podID) == 0 {
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
@ -272,7 +272,7 @@ func (s *Server) handleRun(w http.ResponseWriter, req *http.Request) {
|
|||||||
}
|
}
|
||||||
parts := strings.Split(u.Path, "/")
|
parts := strings.Split(u.Path, "/")
|
||||||
var podNamespace, podID, container string
|
var podNamespace, podID, container string
|
||||||
var uid util.UID
|
var uid types.UID
|
||||||
if len(parts) == 5 {
|
if len(parts) == 5 {
|
||||||
podNamespace = parts[2]
|
podNamespace = parts[2]
|
||||||
podID = parts[3]
|
podID = parts[3]
|
||||||
@ -280,7 +280,7 @@ func (s *Server) handleRun(w http.ResponseWriter, req *http.Request) {
|
|||||||
} else if len(parts) == 6 {
|
} else if len(parts) == 6 {
|
||||||
podNamespace = parts[2]
|
podNamespace = parts[2]
|
||||||
podID = parts[3]
|
podID = parts[3]
|
||||||
uid = util.UID(parts[4])
|
uid = types.UID(parts[4])
|
||||||
container = parts[5]
|
container = parts[5]
|
||||||
} else {
|
} else {
|
||||||
http.Error(w, "Unexpected path for command running", http.StatusBadRequest)
|
http.Error(w, "Unexpected path for command running", http.StatusBadRequest)
|
||||||
@ -348,7 +348,7 @@ func (s *Server) serveStats(w http.ResponseWriter, req *http.Request) {
|
|||||||
http.Error(w, "Pod does not exist", http.StatusNotFound)
|
http.Error(w, "Pod does not exist", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
stats, err = s.host.GetContainerInfo(GetPodFullName(pod), util.UID(components[3]), components[4], &query)
|
stats, err = s.host.GetContainerInfo(GetPodFullName(pod), types.UID(components[3]), components[4], &query)
|
||||||
default:
|
default:
|
||||||
http.Error(w, "unknown resource.", http.StatusNotFound)
|
http.Error(w, "unknown resource.", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
|
@ -29,19 +29,19 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||||
"github.com/google/cadvisor/info"
|
"github.com/google/cadvisor/info"
|
||||||
)
|
)
|
||||||
|
|
||||||
type fakeKubelet struct {
|
type fakeKubelet struct {
|
||||||
podByNameFunc func(namespace, name string) (*api.BoundPod, bool)
|
podByNameFunc func(namespace, name string) (*api.BoundPod, bool)
|
||||||
infoFunc func(name string) (api.PodInfo, error)
|
infoFunc func(name string) (api.PodInfo, error)
|
||||||
containerInfoFunc func(podFullName string, uid util.UID, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error)
|
containerInfoFunc func(podFullName string, uid types.UID, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error)
|
||||||
rootInfoFunc func(query *info.ContainerInfoRequest) (*info.ContainerInfo, error)
|
rootInfoFunc func(query *info.ContainerInfoRequest) (*info.ContainerInfo, error)
|
||||||
machineInfoFunc func() (*info.MachineInfo, error)
|
machineInfoFunc func() (*info.MachineInfo, error)
|
||||||
boundPodsFunc func() ([]api.BoundPod, error)
|
boundPodsFunc func() ([]api.BoundPod, error)
|
||||||
logFunc func(w http.ResponseWriter, req *http.Request)
|
logFunc func(w http.ResponseWriter, req *http.Request)
|
||||||
runFunc func(podFullName string, uid util.UID, containerName string, cmd []string) ([]byte, error)
|
runFunc func(podFullName string, uid types.UID, containerName string, cmd []string) ([]byte, error)
|
||||||
containerLogsFunc func(podFullName, containerName, tail string, follow bool, stdout, stderr io.Writer) error
|
containerLogsFunc func(podFullName, containerName, tail string, follow bool, stdout, stderr io.Writer) error
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,11 +49,11 @@ func (fk *fakeKubelet) GetPodByName(namespace, name string) (*api.BoundPod, bool
|
|||||||
return fk.podByNameFunc(namespace, name)
|
return fk.podByNameFunc(namespace, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fk *fakeKubelet) GetPodInfo(name string, uid util.UID) (api.PodInfo, error) {
|
func (fk *fakeKubelet) GetPodInfo(name string, uid types.UID) (api.PodInfo, error) {
|
||||||
return fk.infoFunc(name)
|
return fk.infoFunc(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fk *fakeKubelet) GetContainerInfo(podFullName string, uid util.UID, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error) {
|
func (fk *fakeKubelet) GetContainerInfo(podFullName string, uid types.UID, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error) {
|
||||||
return fk.containerInfoFunc(podFullName, uid, containerName, req)
|
return fk.containerInfoFunc(podFullName, uid, containerName, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ func (fk *fakeKubelet) GetKubeletContainerLogs(podFullName, containerName, tail
|
|||||||
return fk.containerLogsFunc(podFullName, containerName, tail, follow, stdout, stderr)
|
return fk.containerLogsFunc(podFullName, containerName, tail, follow, stdout, stderr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fk *fakeKubelet) RunInContainer(podFullName string, uid util.UID, containerName string, cmd []string) ([]byte, error) {
|
func (fk *fakeKubelet) RunInContainer(podFullName string, uid types.UID, containerName string, cmd []string) ([]byte, error) {
|
||||||
return fk.runFunc(podFullName, uid, containerName, cmd)
|
return fk.runFunc(podFullName, uid, containerName, cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ func TestContainerInfo(t *testing.T) {
|
|||||||
podID := "somepod"
|
podID := "somepod"
|
||||||
expectedPodID := "somepod" + ".default.etcd"
|
expectedPodID := "somepod" + ".default.etcd"
|
||||||
expectedContainerName := "goodcontainer"
|
expectedContainerName := "goodcontainer"
|
||||||
fw.fakeKubelet.containerInfoFunc = func(podID string, uid util.UID, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error) {
|
fw.fakeKubelet.containerInfoFunc = func(podID string, uid types.UID, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error) {
|
||||||
if podID != expectedPodID || containerName != expectedContainerName {
|
if podID != expectedPodID || containerName != expectedContainerName {
|
||||||
return nil, fmt.Errorf("bad podID or containerName: podID=%v; containerName=%v", podID, containerName)
|
return nil, fmt.Errorf("bad podID or containerName: podID=%v; containerName=%v", podID, containerName)
|
||||||
}
|
}
|
||||||
@ -192,7 +192,7 @@ func TestContainerInfoWithUidNamespace(t *testing.T) {
|
|||||||
expectedPodID := "somepod" + "." + expectedNamespace + ".etcd"
|
expectedPodID := "somepod" + "." + expectedNamespace + ".etcd"
|
||||||
expectedContainerName := "goodcontainer"
|
expectedContainerName := "goodcontainer"
|
||||||
expectedUid := "9b01b80f-8fb4-11e4-95ab-4200af06647"
|
expectedUid := "9b01b80f-8fb4-11e4-95ab-4200af06647"
|
||||||
fw.fakeKubelet.containerInfoFunc = func(podID string, uid util.UID, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error) {
|
fw.fakeKubelet.containerInfoFunc = func(podID string, uid types.UID, containerName string, req *info.ContainerInfoRequest) (*info.ContainerInfo, error) {
|
||||||
if podID != expectedPodID || string(uid) != expectedUid || containerName != expectedContainerName {
|
if podID != expectedPodID || string(uid) != expectedUid || containerName != expectedContainerName {
|
||||||
return nil, fmt.Errorf("bad podID or uid or containerName: podID=%v; uid=%v; containerName=%v", podID, uid, containerName)
|
return nil, fmt.Errorf("bad podID or uid or containerName: podID=%v; uid=%v; containerName=%v", podID, uid, containerName)
|
||||||
}
|
}
|
||||||
@ -297,7 +297,7 @@ func TestServeRunInContainer(t *testing.T) {
|
|||||||
expectedPodName := podName + "." + podNamespace + ".etcd"
|
expectedPodName := podName + "." + podNamespace + ".etcd"
|
||||||
expectedContainerName := "baz"
|
expectedContainerName := "baz"
|
||||||
expectedCommand := "ls -a"
|
expectedCommand := "ls -a"
|
||||||
fw.fakeKubelet.runFunc = func(podFullName string, uid util.UID, containerName string, cmd []string) ([]byte, error) {
|
fw.fakeKubelet.runFunc = func(podFullName string, uid types.UID, containerName string, cmd []string) ([]byte, error) {
|
||||||
if podFullName != expectedPodName {
|
if podFullName != expectedPodName {
|
||||||
t.Errorf("expected %s, got %s", expectedPodName, podFullName)
|
t.Errorf("expected %s, got %s", expectedPodName, podFullName)
|
||||||
}
|
}
|
||||||
@ -338,7 +338,7 @@ func TestServeRunInContainerWithUID(t *testing.T) {
|
|||||||
expectedUID := "7e00838d_-_3523_-_11e4_-_8421_-_42010af0a720"
|
expectedUID := "7e00838d_-_3523_-_11e4_-_8421_-_42010af0a720"
|
||||||
expectedContainerName := "baz"
|
expectedContainerName := "baz"
|
||||||
expectedCommand := "ls -a"
|
expectedCommand := "ls -a"
|
||||||
fw.fakeKubelet.runFunc = func(podFullName string, uid util.UID, containerName string, cmd []string) ([]byte, error) {
|
fw.fakeKubelet.runFunc = func(podFullName string, uid types.UID, containerName string, cmd []string) ([]byte, error) {
|
||||||
if podFullName != expectedPodName {
|
if podFullName != expectedPodName {
|
||||||
t.Errorf("expected %s, got %s", expectedPodName, podFullName)
|
t.Errorf("expected %s, got %s", expectedPodName, podFullName)
|
||||||
}
|
}
|
||||||
|
18
pkg/types/doc.go
Normal file
18
pkg/types/doc.go
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2015 Google Inc. All rights reserved.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Package types implements various generic types used throughout kubernetes.
|
||||||
|
package types
|
22
pkg/types/uid.go
Normal file
22
pkg/types/uid.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2015 Google Inc. All rights reserved.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package types
|
||||||
|
|
||||||
|
// UID is a type that holds unique ID values, including UUIDs. Because we
|
||||||
|
// don't ONLY use UUIDs, this is an alias to string. Being a type captures
|
||||||
|
// intent and helps make sure that UIDs and names do not get conflated.
|
||||||
|
type UID string
|
@ -21,13 +21,9 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"code.google.com/p/go-uuid/uuid"
|
"code.google.com/p/go-uuid/uuid"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// UID is a type that holds unique ID values, including UUIDs. Because we
|
|
||||||
// don't ONLY use UUIDs, this is an alias to string. Being a type captures
|
|
||||||
// intent and helps make sure that UIDs and names do not get conflated.
|
|
||||||
type UID string
|
|
||||||
|
|
||||||
var uuidLock sync.Mutex
|
var uuidLock sync.Mutex
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,12 +32,12 @@ var uuidLock sync.Mutex
|
|||||||
* Blocks in a go routine, so that the caller doesn't have to wait.
|
* Blocks in a go routine, so that the caller doesn't have to wait.
|
||||||
* TODO: save old unused UUIDs so that no one has to block.
|
* TODO: save old unused UUIDs so that no one has to block.
|
||||||
*/
|
*/
|
||||||
func NewUUID() UID {
|
func NewUUID() types.UID {
|
||||||
uuidLock.Lock()
|
uuidLock.Lock()
|
||||||
result := uuid.NewUUID()
|
result := uuid.NewUUID()
|
||||||
go func() {
|
go func() {
|
||||||
time.Sleep(200 * time.Nanosecond)
|
time.Sleep(200 * time.Nanosecond)
|
||||||
uuidLock.Unlock()
|
uuidLock.Unlock()
|
||||||
}()
|
}()
|
||||||
return UID(result.String())
|
return types.UID(result.String())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user