mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
update PodSpec.Host to PodSpec.NodeName in /pkg/api/types.go and /pkg/api/v1beta3/types.go
This commit is contained in:
parent
9b67435cf3
commit
9c1153322e
@ -237,8 +237,8 @@ func podsOnMinions(c *client.Client, podNamespace string, labelSelector labels.S
|
|||||||
for i := range pods.Items {
|
for i := range pods.Items {
|
||||||
pod := pods.Items[i]
|
pod := pods.Items[i]
|
||||||
podString := fmt.Sprintf("%q/%q", pod.Namespace, pod.Name)
|
podString := fmt.Sprintf("%q/%q", pod.Namespace, pod.Name)
|
||||||
glog.Infof("Check whether pod %q exists on node %q", podString, pod.Spec.Host)
|
glog.Infof("Check whether pod %q exists on node %q", podString, pod.Spec.NodeName)
|
||||||
if len(pod.Spec.Host) == 0 {
|
if len(pod.Spec.NodeName) == 0 {
|
||||||
glog.Infof("Pod %q is not bound to a host yet", podString)
|
glog.Infof("Pod %q is not bound to a host yet", podString)
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
@ -301,7 +301,7 @@ Late Initialization
|
|||||||
Late initialization is when resource fields are set by a system controller
|
Late initialization is when resource fields are set by a system controller
|
||||||
after an object is created/updated.
|
after an object is created/updated.
|
||||||
|
|
||||||
For example, the scheduler sets the pod.spec.host field after the pod is created.
|
For example, the scheduler sets the pod.spec.nodeName field after the pod is created.
|
||||||
|
|
||||||
Late-initializers should only make the following types of modifications:
|
Late-initializers should only make the following types of modifications:
|
||||||
- Setting previously unset fields
|
- Setting previously unset fields
|
||||||
|
@ -171,7 +171,7 @@ for version in "${kube_api_versions[@]}"; do
|
|||||||
kube::test::get_object_assert 'pod/valid-pod' "{{$id_field}}" 'valid-pod'
|
kube::test::get_object_assert 'pod/valid-pod' "{{$id_field}}" 'valid-pod'
|
||||||
kube::test::get_object_assert 'pods/valid-pod' "{{$id_field}}" 'valid-pod'
|
kube::test::get_object_assert 'pods/valid-pod' "{{$id_field}}" 'valid-pod'
|
||||||
# Describe command should print detailed information
|
# Describe command should print detailed information
|
||||||
kube::test::describe_object_assert pods 'valid-pod' "Name:" "Image(s):" "Host:" "Labels:" "Status:" "Replication Controllers"
|
kube::test::describe_object_assert pods 'valid-pod' "Name:" "Image(s):" "Node:" "Labels:" "Status:" "Replication Controllers"
|
||||||
|
|
||||||
### Dump current valid-pod POD
|
### Dump current valid-pod POD
|
||||||
output_pod=$(kubectl get pod valid-pod -o yaml --output-version=v1beta3 "${kube_flags[@]}")
|
output_pod=$(kubectl get pod valid-pod -o yaml --output-version=v1beta3 "${kube_flags[@]}")
|
||||||
|
@ -1374,7 +1374,7 @@ func deepCopy_api_PodSpec(in PodSpec, out *PodSpec, c *conversion.Cloner) error
|
|||||||
out.NodeSelector = nil
|
out.NodeSelector = nil
|
||||||
}
|
}
|
||||||
out.ServiceAccount = in.ServiceAccount
|
out.ServiceAccount = in.ServiceAccount
|
||||||
out.Host = in.Host
|
out.NodeName = in.NodeName
|
||||||
out.HostNetwork = in.HostNetwork
|
out.HostNetwork = in.HostNetwork
|
||||||
if in.ImagePullSecrets != nil {
|
if in.ImagePullSecrets != nil {
|
||||||
out.ImagePullSecrets = make([]LocalObjectReference, len(in.ImagePullSecrets))
|
out.ImagePullSecrets = make([]LocalObjectReference, len(in.ImagePullSecrets))
|
||||||
|
@ -868,10 +868,10 @@ type PodSpec struct {
|
|||||||
// The pod will be allowed to use secrets referenced by the ServiceAccount
|
// The pod will be allowed to use secrets referenced by the ServiceAccount
|
||||||
ServiceAccount string `json:"serviceAccount"`
|
ServiceAccount string `json:"serviceAccount"`
|
||||||
|
|
||||||
// Host is a request to schedule this pod onto a specific host. If it is non-empty,
|
// NodeName is a request to schedule this pod onto a specific node. If it is non-empty,
|
||||||
// the the scheduler simply schedules this pod onto that host, assuming that it fits
|
// the scheduler simply schedules this pod onto that node, assuming that it fits resource
|
||||||
// resource requirements.
|
// requirements.
|
||||||
Host string `json:"host,omitempty"`
|
NodeName string `json:"nodeName,omitempty"`
|
||||||
// Uses the host's network namespace. If this option is set, the ports that will be
|
// Uses the host's network namespace. If this option is set, the ports that will be
|
||||||
// used must be specified.
|
// used must be specified.
|
||||||
// Optional: Default to false.
|
// Optional: Default to false.
|
||||||
|
@ -1513,7 +1513,7 @@ func convert_api_PodSpec_To_v1_PodSpec(in *api.PodSpec, out *PodSpec, s conversi
|
|||||||
out.NodeSelector = nil
|
out.NodeSelector = nil
|
||||||
}
|
}
|
||||||
out.ServiceAccount = in.ServiceAccount
|
out.ServiceAccount = in.ServiceAccount
|
||||||
out.Host = in.Host
|
out.NodeName = in.NodeName
|
||||||
out.HostNetwork = in.HostNetwork
|
out.HostNetwork = in.HostNetwork
|
||||||
if in.ImagePullSecrets != nil {
|
if in.ImagePullSecrets != nil {
|
||||||
out.ImagePullSecrets = make([]LocalObjectReference, len(in.ImagePullSecrets))
|
out.ImagePullSecrets = make([]LocalObjectReference, len(in.ImagePullSecrets))
|
||||||
@ -3787,7 +3787,7 @@ func convert_v1_PodSpec_To_api_PodSpec(in *PodSpec, out *api.PodSpec, s conversi
|
|||||||
out.NodeSelector = nil
|
out.NodeSelector = nil
|
||||||
}
|
}
|
||||||
out.ServiceAccount = in.ServiceAccount
|
out.ServiceAccount = in.ServiceAccount
|
||||||
out.Host = in.Host
|
out.NodeName = in.NodeName
|
||||||
out.HostNetwork = in.HostNetwork
|
out.HostNetwork = in.HostNetwork
|
||||||
if in.ImagePullSecrets != nil {
|
if in.ImagePullSecrets != nil {
|
||||||
out.ImagePullSecrets = make([]api.LocalObjectReference, len(in.ImagePullSecrets))
|
out.ImagePullSecrets = make([]api.LocalObjectReference, len(in.ImagePullSecrets))
|
||||||
|
@ -1305,7 +1305,7 @@ func deepCopy_v1_PodSpec(in PodSpec, out *PodSpec, c *conversion.Cloner) error {
|
|||||||
out.NodeSelector = nil
|
out.NodeSelector = nil
|
||||||
}
|
}
|
||||||
out.ServiceAccount = in.ServiceAccount
|
out.ServiceAccount = in.ServiceAccount
|
||||||
out.Host = in.Host
|
out.NodeName = in.NodeName
|
||||||
out.HostNetwork = in.HostNetwork
|
out.HostNetwork = in.HostNetwork
|
||||||
if in.ImagePullSecrets != nil {
|
if in.ImagePullSecrets != nil {
|
||||||
out.ImagePullSecrets = make([]LocalObjectReference, len(in.ImagePullSecrets))
|
out.ImagePullSecrets = make([]LocalObjectReference, len(in.ImagePullSecrets))
|
||||||
|
@ -862,10 +862,10 @@ type PodSpec struct {
|
|||||||
// ServiceAccount is the name of the ServiceAccount to use to run this pod
|
// ServiceAccount is the name of the ServiceAccount to use to run this pod
|
||||||
ServiceAccount string `json:"serviceAccount,omitempty" description:"name of the ServiceAccount to use to run this pod"`
|
ServiceAccount string `json:"serviceAccount,omitempty" description:"name of the ServiceAccount to use to run this pod"`
|
||||||
|
|
||||||
// Host is a request to schedule this pod onto a specific host. If it is non-empty,
|
// NodeName is a request to schedule this pod onto a specific node. If it is non-empty,
|
||||||
// the the scheduler simply schedules this pod onto that host, assuming that it fits
|
// the scheduler simply schedules this pod onto that node, assuming that it fits resource
|
||||||
// resource requirements.
|
// requirements.
|
||||||
Host string `json:"host,omitempty" description:"host requested for this pod"`
|
NodeName string `json:"nodeName,omitempty" description:"node requested for this pod"`
|
||||||
// Uses the host's network namespace. If this option is set, the ports that will be
|
// Uses the host's network namespace. If this option is set, the ports that will be
|
||||||
// used must be specified.
|
// used must be specified.
|
||||||
// Optional: Default to false.
|
// Optional: Default to false.
|
||||||
|
@ -226,14 +226,14 @@ func addConversionFuncs() {
|
|||||||
if err := s.Convert(&in, &out.Manifest, 0); err != nil {
|
if err := s.Convert(&in, &out.Manifest, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
out.Host = in.Host
|
out.Host = in.NodeName
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
func(in *PodState, out *api.PodSpec, s conversion.Scope) error {
|
func(in *PodState, out *api.PodSpec, s conversion.Scope) error {
|
||||||
if err := s.Convert(&in.Manifest, &out, 0); err != nil {
|
if err := s.Convert(&in.Manifest, &out, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
out.Host = in.Host
|
out.NodeName = in.Host
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -375,8 +375,8 @@ func addConversionFuncs() {
|
|||||||
if err := s.Convert(&in.Spec, &out.DesiredState.Manifest, 0); err != nil {
|
if err := s.Convert(&in.Spec, &out.DesiredState.Manifest, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
out.DesiredState.Host = in.Spec.Host
|
out.DesiredState.Host = in.Spec.NodeName
|
||||||
out.CurrentState.Host = in.Spec.Host
|
out.CurrentState.Host = in.Spec.NodeName
|
||||||
out.ServiceAccount = in.Spec.ServiceAccount
|
out.ServiceAccount = in.Spec.ServiceAccount
|
||||||
if err := s.Convert(&in.Status, &out.CurrentState, 0); err != nil {
|
if err := s.Convert(&in.Status, &out.CurrentState, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -399,7 +399,7 @@ func addConversionFuncs() {
|
|||||||
if err := s.Convert(&in.DesiredState.Manifest, &out.Spec, 0); err != nil {
|
if err := s.Convert(&in.DesiredState.Manifest, &out.Spec, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
out.Spec.Host = in.DesiredState.Host
|
out.Spec.NodeName = in.DesiredState.Host
|
||||||
out.Spec.ServiceAccount = in.ServiceAccount
|
out.Spec.ServiceAccount = in.ServiceAccount
|
||||||
if err := s.Convert(&in.CurrentState, &out.Status, 0); err != nil {
|
if err := s.Convert(&in.CurrentState, &out.Status, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -504,7 +504,7 @@ func addConversionFuncs() {
|
|||||||
if err := s.Convert(&in.Spec, &out.DesiredState.Manifest, 0); err != nil {
|
if err := s.Convert(&in.Spec, &out.DesiredState.Manifest, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
out.DesiredState.Host = in.Spec.Host
|
out.DesiredState.Host = in.Spec.NodeName
|
||||||
out.ServiceAccount = in.Spec.ServiceAccount
|
out.ServiceAccount = in.Spec.ServiceAccount
|
||||||
if err := s.Convert(&in.Spec.NodeSelector, &out.NodeSelector, 0); err != nil {
|
if err := s.Convert(&in.Spec.NodeSelector, &out.NodeSelector, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -521,7 +521,7 @@ func addConversionFuncs() {
|
|||||||
if err := s.Convert(&in.DesiredState.Manifest, &out.Spec, 0); err != nil {
|
if err := s.Convert(&in.DesiredState.Manifest, &out.Spec, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
out.Spec.Host = in.DesiredState.Host
|
out.Spec.NodeName = in.DesiredState.Host
|
||||||
out.Spec.ServiceAccount = in.ServiceAccount
|
out.Spec.ServiceAccount = in.ServiceAccount
|
||||||
if err := s.Convert(&in.NodeSelector, &out.Spec.NodeSelector, 0); err != nil {
|
if err := s.Convert(&in.NodeSelector, &out.Spec.NodeSelector, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -178,8 +178,8 @@ func addConversionFuncs() {
|
|||||||
if err := s.Convert(&in.Spec, &out.DesiredState.Manifest, 0); err != nil {
|
if err := s.Convert(&in.Spec, &out.DesiredState.Manifest, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
out.DesiredState.Host = in.Spec.Host
|
out.DesiredState.Host = in.Spec.NodeName
|
||||||
out.CurrentState.Host = in.Spec.Host
|
out.CurrentState.Host = in.Spec.NodeName
|
||||||
out.ServiceAccount = in.Spec.ServiceAccount
|
out.ServiceAccount = in.Spec.ServiceAccount
|
||||||
if err := s.Convert(&in.Status, &out.CurrentState, 0); err != nil {
|
if err := s.Convert(&in.Status, &out.CurrentState, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -203,7 +203,7 @@ func addConversionFuncs() {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
out.Spec.ServiceAccount = in.ServiceAccount
|
out.Spec.ServiceAccount = in.ServiceAccount
|
||||||
out.Spec.Host = in.DesiredState.Host
|
out.Spec.NodeName = in.DesiredState.Host
|
||||||
if err := s.Convert(&in.CurrentState, &out.Status, 0); err != nil {
|
if err := s.Convert(&in.CurrentState, &out.Status, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -283,7 +283,7 @@ func addConversionFuncs() {
|
|||||||
if err := s.Convert(&in.Spec, &out.DesiredState.Manifest, 0); err != nil {
|
if err := s.Convert(&in.Spec, &out.DesiredState.Manifest, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
out.DesiredState.Host = in.Spec.Host
|
out.DesiredState.Host = in.Spec.NodeName
|
||||||
out.ServiceAccount = in.Spec.ServiceAccount
|
out.ServiceAccount = in.Spec.ServiceAccount
|
||||||
if err := s.Convert(&in.Spec.NodeSelector, &out.NodeSelector, 0); err != nil {
|
if err := s.Convert(&in.Spec.NodeSelector, &out.NodeSelector, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -300,7 +300,7 @@ func addConversionFuncs() {
|
|||||||
if err := s.Convert(&in.DesiredState.Manifest, &out.Spec, 0); err != nil {
|
if err := s.Convert(&in.DesiredState.Manifest, &out.Spec, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
out.Spec.Host = in.DesiredState.Host
|
out.Spec.NodeName = in.DesiredState.Host
|
||||||
out.Spec.ServiceAccount = in.ServiceAccount
|
out.Spec.ServiceAccount = in.ServiceAccount
|
||||||
if err := s.Convert(&in.NodeSelector, &out.Spec.NodeSelector, 0); err != nil {
|
if err := s.Convert(&in.NodeSelector, &out.Spec.NodeSelector, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -660,14 +660,14 @@ func addConversionFuncs() {
|
|||||||
if err := s.Convert(&in, &out.Manifest, 0); err != nil {
|
if err := s.Convert(&in, &out.Manifest, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
out.Host = in.Host
|
out.Host = in.NodeName
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
func(in *PodState, out *api.PodSpec, s conversion.Scope) error {
|
func(in *PodState, out *api.PodSpec, s conversion.Scope) error {
|
||||||
if err := s.Convert(&in.Manifest, &out, 0); err != nil {
|
if err := s.Convert(&in.Manifest, &out, 0); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
out.Host = in.Host
|
out.NodeName = in.Host
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
func(in *api.Service, out *Service, s conversion.Scope) error {
|
func(in *api.Service, out *Service, s conversion.Scope) error {
|
||||||
|
@ -31,6 +31,8 @@ func addConversionFuncs() {
|
|||||||
convert_api_Container_To_v1beta3_Container,
|
convert_api_Container_To_v1beta3_Container,
|
||||||
convert_v1beta3_ServiceSpec_To_api_ServiceSpec,
|
convert_v1beta3_ServiceSpec_To_api_ServiceSpec,
|
||||||
convert_api_ServiceSpec_To_v1beta3_ServiceSpec,
|
convert_api_ServiceSpec_To_v1beta3_ServiceSpec,
|
||||||
|
convert_v1beta3_PodSpec_To_api_PodSpec,
|
||||||
|
convert_api_PodSpec_To_v1beta3_PodSpec,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// If one of the conversion functions is malformed, detect it immediately.
|
// If one of the conversion functions is malformed, detect it immediately.
|
||||||
@ -420,3 +422,127 @@ func convert_api_ServiceSpec_To_v1beta3_ServiceSpec(in *api.ServiceSpec, out *Se
|
|||||||
out.SessionAffinity = ServiceAffinity(in.SessionAffinity)
|
out.SessionAffinity = ServiceAffinity(in.SessionAffinity)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func convert_v1beta3_PodSpec_To_api_PodSpec(in *PodSpec, out *api.PodSpec, s conversion.Scope) error {
|
||||||
|
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||||
|
defaulting.(func(*PodSpec))(in)
|
||||||
|
}
|
||||||
|
if in.Volumes != nil {
|
||||||
|
out.Volumes = make([]api.Volume, len(in.Volumes))
|
||||||
|
for i := range in.Volumes {
|
||||||
|
if err := convert_v1beta3_Volume_To_api_Volume(&in.Volumes[i], &out.Volumes[i], s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
out.Volumes = nil
|
||||||
|
}
|
||||||
|
if in.Containers != nil {
|
||||||
|
out.Containers = make([]api.Container, len(in.Containers))
|
||||||
|
for i := range in.Containers {
|
||||||
|
if err := convert_v1beta3_Container_To_api_Container(&in.Containers[i], &out.Containers[i], s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
out.Containers = nil
|
||||||
|
}
|
||||||
|
out.RestartPolicy = api.RestartPolicy(in.RestartPolicy)
|
||||||
|
if in.TerminationGracePeriodSeconds != nil {
|
||||||
|
out.TerminationGracePeriodSeconds = new(int64)
|
||||||
|
*out.TerminationGracePeriodSeconds = *in.TerminationGracePeriodSeconds
|
||||||
|
} else {
|
||||||
|
out.TerminationGracePeriodSeconds = nil
|
||||||
|
}
|
||||||
|
if in.ActiveDeadlineSeconds != nil {
|
||||||
|
out.ActiveDeadlineSeconds = new(int64)
|
||||||
|
*out.ActiveDeadlineSeconds = *in.ActiveDeadlineSeconds
|
||||||
|
} else {
|
||||||
|
out.ActiveDeadlineSeconds = nil
|
||||||
|
}
|
||||||
|
out.DNSPolicy = api.DNSPolicy(in.DNSPolicy)
|
||||||
|
if in.NodeSelector != nil {
|
||||||
|
out.NodeSelector = make(map[string]string)
|
||||||
|
for key, val := range in.NodeSelector {
|
||||||
|
out.NodeSelector[key] = val
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
out.NodeSelector = nil
|
||||||
|
}
|
||||||
|
out.ServiceAccount = in.ServiceAccount
|
||||||
|
out.NodeName = in.Host
|
||||||
|
out.HostNetwork = in.HostNetwork
|
||||||
|
if in.ImagePullSecrets != nil {
|
||||||
|
out.ImagePullSecrets = make([]api.LocalObjectReference, len(in.ImagePullSecrets))
|
||||||
|
for i := range in.ImagePullSecrets {
|
||||||
|
if err := convert_v1beta3_LocalObjectReference_To_api_LocalObjectReference(&in.ImagePullSecrets[i], &out.ImagePullSecrets[i], s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
out.ImagePullSecrets = nil
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func convert_api_PodSpec_To_v1beta3_PodSpec(in *api.PodSpec, out *PodSpec, s conversion.Scope) error {
|
||||||
|
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||||
|
defaulting.(func(*api.PodSpec))(in)
|
||||||
|
}
|
||||||
|
if in.Volumes != nil {
|
||||||
|
out.Volumes = make([]Volume, len(in.Volumes))
|
||||||
|
for i := range in.Volumes {
|
||||||
|
if err := convert_api_Volume_To_v1beta3_Volume(&in.Volumes[i], &out.Volumes[i], s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
out.Volumes = nil
|
||||||
|
}
|
||||||
|
if in.Containers != nil {
|
||||||
|
out.Containers = make([]Container, len(in.Containers))
|
||||||
|
for i := range in.Containers {
|
||||||
|
if err := convert_api_Container_To_v1beta3_Container(&in.Containers[i], &out.Containers[i], s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
out.Containers = nil
|
||||||
|
}
|
||||||
|
out.RestartPolicy = RestartPolicy(in.RestartPolicy)
|
||||||
|
if in.TerminationGracePeriodSeconds != nil {
|
||||||
|
out.TerminationGracePeriodSeconds = new(int64)
|
||||||
|
*out.TerminationGracePeriodSeconds = *in.TerminationGracePeriodSeconds
|
||||||
|
} else {
|
||||||
|
out.TerminationGracePeriodSeconds = nil
|
||||||
|
}
|
||||||
|
if in.ActiveDeadlineSeconds != nil {
|
||||||
|
out.ActiveDeadlineSeconds = new(int64)
|
||||||
|
*out.ActiveDeadlineSeconds = *in.ActiveDeadlineSeconds
|
||||||
|
} else {
|
||||||
|
out.ActiveDeadlineSeconds = nil
|
||||||
|
}
|
||||||
|
out.DNSPolicy = DNSPolicy(in.DNSPolicy)
|
||||||
|
if in.NodeSelector != nil {
|
||||||
|
out.NodeSelector = make(map[string]string)
|
||||||
|
for key, val := range in.NodeSelector {
|
||||||
|
out.NodeSelector[key] = val
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
out.NodeSelector = nil
|
||||||
|
}
|
||||||
|
out.ServiceAccount = in.ServiceAccount
|
||||||
|
out.Host = in.NodeName
|
||||||
|
out.HostNetwork = in.HostNetwork
|
||||||
|
if in.ImagePullSecrets != nil {
|
||||||
|
out.ImagePullSecrets = make([]LocalObjectReference, len(in.ImagePullSecrets))
|
||||||
|
for i := range in.ImagePullSecrets {
|
||||||
|
if err := convert_api_LocalObjectReference_To_v1beta3_LocalObjectReference(&in.ImagePullSecrets[i], &out.ImagePullSecrets[i], s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
out.ImagePullSecrets = nil
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -1373,68 +1373,6 @@ func convert_api_PodProxyOptions_To_v1beta3_PodProxyOptions(in *api.PodProxyOpti
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func convert_api_PodSpec_To_v1beta3_PodSpec(in *api.PodSpec, out *PodSpec, s conversion.Scope) error {
|
|
||||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
|
||||||
defaulting.(func(*api.PodSpec))(in)
|
|
||||||
}
|
|
||||||
if in.Volumes != nil {
|
|
||||||
out.Volumes = make([]Volume, len(in.Volumes))
|
|
||||||
for i := range in.Volumes {
|
|
||||||
if err := convert_api_Volume_To_v1beta3_Volume(&in.Volumes[i], &out.Volumes[i], s); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
out.Volumes = nil
|
|
||||||
}
|
|
||||||
if in.Containers != nil {
|
|
||||||
out.Containers = make([]Container, len(in.Containers))
|
|
||||||
for i := range in.Containers {
|
|
||||||
if err := convert_api_Container_To_v1beta3_Container(&in.Containers[i], &out.Containers[i], s); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
out.Containers = nil
|
|
||||||
}
|
|
||||||
out.RestartPolicy = RestartPolicy(in.RestartPolicy)
|
|
||||||
if in.TerminationGracePeriodSeconds != nil {
|
|
||||||
out.TerminationGracePeriodSeconds = new(int64)
|
|
||||||
*out.TerminationGracePeriodSeconds = *in.TerminationGracePeriodSeconds
|
|
||||||
} else {
|
|
||||||
out.TerminationGracePeriodSeconds = nil
|
|
||||||
}
|
|
||||||
if in.ActiveDeadlineSeconds != nil {
|
|
||||||
out.ActiveDeadlineSeconds = new(int64)
|
|
||||||
*out.ActiveDeadlineSeconds = *in.ActiveDeadlineSeconds
|
|
||||||
} else {
|
|
||||||
out.ActiveDeadlineSeconds = nil
|
|
||||||
}
|
|
||||||
out.DNSPolicy = DNSPolicy(in.DNSPolicy)
|
|
||||||
if in.NodeSelector != nil {
|
|
||||||
out.NodeSelector = make(map[string]string)
|
|
||||||
for key, val := range in.NodeSelector {
|
|
||||||
out.NodeSelector[key] = val
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
out.NodeSelector = nil
|
|
||||||
}
|
|
||||||
out.ServiceAccount = in.ServiceAccount
|
|
||||||
out.Host = in.Host
|
|
||||||
out.HostNetwork = in.HostNetwork
|
|
||||||
if in.ImagePullSecrets != nil {
|
|
||||||
out.ImagePullSecrets = make([]LocalObjectReference, len(in.ImagePullSecrets))
|
|
||||||
for i := range in.ImagePullSecrets {
|
|
||||||
if err := convert_api_LocalObjectReference_To_v1beta3_LocalObjectReference(&in.ImagePullSecrets[i], &out.ImagePullSecrets[i], s); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
out.ImagePullSecrets = nil
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func convert_api_PodStatus_To_v1beta3_PodStatus(in *api.PodStatus, out *PodStatus, s conversion.Scope) error {
|
func convert_api_PodStatus_To_v1beta3_PodStatus(in *api.PodStatus, out *PodStatus, s conversion.Scope) error {
|
||||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||||
defaulting.(func(*api.PodStatus))(in)
|
defaulting.(func(*api.PodStatus))(in)
|
||||||
@ -3580,68 +3518,6 @@ func convert_v1beta3_PodProxyOptions_To_api_PodProxyOptions(in *PodProxyOptions,
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func convert_v1beta3_PodSpec_To_api_PodSpec(in *PodSpec, out *api.PodSpec, s conversion.Scope) error {
|
|
||||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
|
||||||
defaulting.(func(*PodSpec))(in)
|
|
||||||
}
|
|
||||||
if in.Volumes != nil {
|
|
||||||
out.Volumes = make([]api.Volume, len(in.Volumes))
|
|
||||||
for i := range in.Volumes {
|
|
||||||
if err := convert_v1beta3_Volume_To_api_Volume(&in.Volumes[i], &out.Volumes[i], s); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
out.Volumes = nil
|
|
||||||
}
|
|
||||||
if in.Containers != nil {
|
|
||||||
out.Containers = make([]api.Container, len(in.Containers))
|
|
||||||
for i := range in.Containers {
|
|
||||||
if err := convert_v1beta3_Container_To_api_Container(&in.Containers[i], &out.Containers[i], s); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
out.Containers = nil
|
|
||||||
}
|
|
||||||
out.RestartPolicy = api.RestartPolicy(in.RestartPolicy)
|
|
||||||
if in.TerminationGracePeriodSeconds != nil {
|
|
||||||
out.TerminationGracePeriodSeconds = new(int64)
|
|
||||||
*out.TerminationGracePeriodSeconds = *in.TerminationGracePeriodSeconds
|
|
||||||
} else {
|
|
||||||
out.TerminationGracePeriodSeconds = nil
|
|
||||||
}
|
|
||||||
if in.ActiveDeadlineSeconds != nil {
|
|
||||||
out.ActiveDeadlineSeconds = new(int64)
|
|
||||||
*out.ActiveDeadlineSeconds = *in.ActiveDeadlineSeconds
|
|
||||||
} else {
|
|
||||||
out.ActiveDeadlineSeconds = nil
|
|
||||||
}
|
|
||||||
out.DNSPolicy = api.DNSPolicy(in.DNSPolicy)
|
|
||||||
if in.NodeSelector != nil {
|
|
||||||
out.NodeSelector = make(map[string]string)
|
|
||||||
for key, val := range in.NodeSelector {
|
|
||||||
out.NodeSelector[key] = val
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
out.NodeSelector = nil
|
|
||||||
}
|
|
||||||
out.ServiceAccount = in.ServiceAccount
|
|
||||||
out.Host = in.Host
|
|
||||||
out.HostNetwork = in.HostNetwork
|
|
||||||
if in.ImagePullSecrets != nil {
|
|
||||||
out.ImagePullSecrets = make([]api.LocalObjectReference, len(in.ImagePullSecrets))
|
|
||||||
for i := range in.ImagePullSecrets {
|
|
||||||
if err := convert_v1beta3_LocalObjectReference_To_api_LocalObjectReference(&in.ImagePullSecrets[i], &out.ImagePullSecrets[i], s); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
out.ImagePullSecrets = nil
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func convert_v1beta3_PodStatus_To_api_PodStatus(in *PodStatus, out *api.PodStatus, s conversion.Scope) error {
|
func convert_v1beta3_PodStatus_To_api_PodStatus(in *PodStatus, out *api.PodStatus, s conversion.Scope) error {
|
||||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||||
defaulting.(func(*PodStatus))(in)
|
defaulting.(func(*PodStatus))(in)
|
||||||
@ -4514,7 +4390,6 @@ func init() {
|
|||||||
convert_api_PodList_To_v1beta3_PodList,
|
convert_api_PodList_To_v1beta3_PodList,
|
||||||
convert_api_PodLogOptions_To_v1beta3_PodLogOptions,
|
convert_api_PodLogOptions_To_v1beta3_PodLogOptions,
|
||||||
convert_api_PodProxyOptions_To_v1beta3_PodProxyOptions,
|
convert_api_PodProxyOptions_To_v1beta3_PodProxyOptions,
|
||||||
convert_api_PodSpec_To_v1beta3_PodSpec,
|
|
||||||
convert_api_PodStatusResult_To_v1beta3_PodStatusResult,
|
convert_api_PodStatusResult_To_v1beta3_PodStatusResult,
|
||||||
convert_api_PodStatus_To_v1beta3_PodStatus,
|
convert_api_PodStatus_To_v1beta3_PodStatus,
|
||||||
convert_api_PodTemplateList_To_v1beta3_PodTemplateList,
|
convert_api_PodTemplateList_To_v1beta3_PodTemplateList,
|
||||||
@ -4626,7 +4501,6 @@ func init() {
|
|||||||
convert_v1beta3_PodList_To_api_PodList,
|
convert_v1beta3_PodList_To_api_PodList,
|
||||||
convert_v1beta3_PodLogOptions_To_api_PodLogOptions,
|
convert_v1beta3_PodLogOptions_To_api_PodLogOptions,
|
||||||
convert_v1beta3_PodProxyOptions_To_api_PodProxyOptions,
|
convert_v1beta3_PodProxyOptions_To_api_PodProxyOptions,
|
||||||
convert_v1beta3_PodSpec_To_api_PodSpec,
|
|
||||||
convert_v1beta3_PodStatusResult_To_api_PodStatusResult,
|
convert_v1beta3_PodStatusResult_To_api_PodStatusResult,
|
||||||
convert_v1beta3_PodStatus_To_api_PodStatus,
|
convert_v1beta3_PodStatus_To_api_PodStatus,
|
||||||
convert_v1beta3_PodTemplateList_To_api_PodTemplateList,
|
convert_v1beta3_PodTemplateList_To_api_PodTemplateList,
|
||||||
|
@ -1007,8 +1007,8 @@ func ValidatePodStatusUpdate(newPod, oldPod *api.Pod) errs.ValidationErrorList {
|
|||||||
allErrs = append(allErrs, ValidateObjectMetaUpdate(&oldPod.ObjectMeta, &newPod.ObjectMeta).Prefix("metadata")...)
|
allErrs = append(allErrs, ValidateObjectMetaUpdate(&oldPod.ObjectMeta, &newPod.ObjectMeta).Prefix("metadata")...)
|
||||||
|
|
||||||
// TODO: allow change when bindings are properly decoupled from pods
|
// TODO: allow change when bindings are properly decoupled from pods
|
||||||
if newPod.Spec.Host != oldPod.Spec.Host {
|
if newPod.Spec.NodeName != oldPod.Spec.NodeName {
|
||||||
allErrs = append(allErrs, errs.NewFieldInvalid("status.host", newPod.Spec.Host, "pod host cannot be changed directly"))
|
allErrs = append(allErrs, errs.NewFieldInvalid("status.nodeName", newPod.Spec.NodeName, "pod nodename cannot be changed directly"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// For status update we ignore changes to pod spec.
|
// For status update we ignore changes to pod spec.
|
||||||
|
@ -1049,7 +1049,7 @@ func TestValidatePodSpec(t *testing.T) {
|
|||||||
NodeSelector: map[string]string{
|
NodeSelector: map[string]string{
|
||||||
"key": "value",
|
"key": "value",
|
||||||
},
|
},
|
||||||
Host: "foobar",
|
NodeName: "foobar",
|
||||||
DNSPolicy: api.DNSClusterFirst,
|
DNSPolicy: api.DNSClusterFirst,
|
||||||
ActiveDeadlineSeconds: &activeDeadlineSeconds,
|
ActiveDeadlineSeconds: &activeDeadlineSeconds,
|
||||||
},
|
},
|
||||||
@ -1116,7 +1116,7 @@ func TestValidatePodSpec(t *testing.T) {
|
|||||||
NodeSelector: map[string]string{
|
NodeSelector: map[string]string{
|
||||||
"key": "value",
|
"key": "value",
|
||||||
},
|
},
|
||||||
Host: "foobar",
|
NodeName: "foobar",
|
||||||
DNSPolicy: api.DNSClusterFirst,
|
DNSPolicy: api.DNSClusterFirst,
|
||||||
ActiveDeadlineSeconds: &activeDeadlineSeconds,
|
ActiveDeadlineSeconds: &activeDeadlineSeconds,
|
||||||
},
|
},
|
||||||
@ -1151,7 +1151,7 @@ func TestValidatePod(t *testing.T) {
|
|||||||
NodeSelector: map[string]string{
|
NodeSelector: map[string]string{
|
||||||
"key": "value",
|
"key": "value",
|
||||||
},
|
},
|
||||||
Host: "foobar",
|
NodeName: "foobar",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -425,7 +425,7 @@ func (nc *NodeController) deletePods(nodeID string) error {
|
|||||||
}
|
}
|
||||||
for _, pod := range pods.Items {
|
for _, pod := range pods.Items {
|
||||||
// Defensive check, also needed for tests.
|
// Defensive check, also needed for tests.
|
||||||
if pod.Spec.Host != nodeID {
|
if pod.Spec.NodeName != nodeID {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
glog.V(2).Infof("Delete pod %v", pod.Name)
|
glog.V(2).Infof("Delete pod %v", pod.Name)
|
||||||
|
@ -566,7 +566,7 @@ func newNode(name string) *api.Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newPod(name, host string) *api.Pod {
|
func newPod(name, host string) *api.Pod {
|
||||||
return &api.Pod{ObjectMeta: api.ObjectMeta{Name: name}, Spec: api.PodSpec{Host: host}}
|
return &api.Pod{ObjectMeta: api.ObjectMeta{Name: name}, Spec: api.PodSpec{NodeName: host}}
|
||||||
}
|
}
|
||||||
|
|
||||||
func sortedNodeNames(nodes []*api.Node) []string {
|
func sortedNodeNames(nodes []*api.Node) []string {
|
||||||
|
@ -274,7 +274,7 @@ func (s activePods) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
|||||||
|
|
||||||
func (s activePods) Less(i, j int) bool {
|
func (s activePods) Less(i, j int) bool {
|
||||||
// Unassigned < assigned
|
// Unassigned < assigned
|
||||||
if s[i].Spec.Host == "" && s[j].Spec.Host != "" {
|
if s[i].Spec.NodeName == "" && s[j].Spec.NodeName != "" {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// PodPending < PodUnknown < PodRunning
|
// PodPending < PodUnknown < PodRunning
|
||||||
|
@ -436,19 +436,19 @@ func TestSortingActivePods(t *testing.T) {
|
|||||||
pods[i] = &podList.Items[i]
|
pods[i] = &podList.Items[i]
|
||||||
}
|
}
|
||||||
// pods[0] is not scheduled yet.
|
// pods[0] is not scheduled yet.
|
||||||
pods[0].Spec.Host = ""
|
pods[0].Spec.NodeName = ""
|
||||||
pods[0].Status.Phase = api.PodPending
|
pods[0].Status.Phase = api.PodPending
|
||||||
// pods[1] is scheduled but pending.
|
// pods[1] is scheduled but pending.
|
||||||
pods[1].Spec.Host = "bar"
|
pods[1].Spec.NodeName = "bar"
|
||||||
pods[1].Status.Phase = api.PodPending
|
pods[1].Status.Phase = api.PodPending
|
||||||
// pods[2] is unknown.
|
// pods[2] is unknown.
|
||||||
pods[2].Spec.Host = "foo"
|
pods[2].Spec.NodeName = "foo"
|
||||||
pods[2].Status.Phase = api.PodUnknown
|
pods[2].Status.Phase = api.PodUnknown
|
||||||
// pods[3] is running but not ready.
|
// pods[3] is running but not ready.
|
||||||
pods[3].Spec.Host = "foo"
|
pods[3].Spec.NodeName = "foo"
|
||||||
pods[3].Status.Phase = api.PodRunning
|
pods[3].Status.Phase = api.PodRunning
|
||||||
// pods[4] is running and ready.
|
// pods[4] is running and ready.
|
||||||
pods[4].Spec.Host = "foo"
|
pods[4].Spec.NodeName = "foo"
|
||||||
pods[4].Status.Phase = api.PodRunning
|
pods[4].Status.Phase = api.PodRunning
|
||||||
pods[4].Status.Conditions = []api.PodCondition{{Type: api.PodReady, Status: api.ConditionTrue}}
|
pods[4].Status.Conditions = []api.PodCondition{{Type: api.PodReady, Status: api.ConditionTrue}}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ func TestMerge(t *testing.T) {
|
|||||||
Name: "baz",
|
Name: "baz",
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Host: "bar",
|
NodeName: "bar",
|
||||||
RestartPolicy: api.RestartPolicyAlways,
|
RestartPolicy: api.RestartPolicyAlways,
|
||||||
DNSPolicy: api.DNSClusterFirst,
|
DNSPolicy: api.DNSClusterFirst,
|
||||||
},
|
},
|
||||||
|
@ -269,7 +269,7 @@ func describePod(pod *api.Pod, rcs []api.ReplicationController, events *api.Even
|
|||||||
return tabbedString(func(out io.Writer) error {
|
return tabbedString(func(out io.Writer) error {
|
||||||
fmt.Fprintf(out, "Name:\t%s\n", pod.Name)
|
fmt.Fprintf(out, "Name:\t%s\n", pod.Name)
|
||||||
fmt.Fprintf(out, "Image(s):\t%s\n", makeImageList(&pod.Spec))
|
fmt.Fprintf(out, "Image(s):\t%s\n", makeImageList(&pod.Spec))
|
||||||
fmt.Fprintf(out, "Host:\t%s\n", pod.Spec.Host+"/"+pod.Status.HostIP)
|
fmt.Fprintf(out, "Node:\t%s\n", pod.Spec.NodeName+"/"+pod.Status.HostIP)
|
||||||
fmt.Fprintf(out, "Labels:\t%s\n", formatLabels(pod.Labels))
|
fmt.Fprintf(out, "Labels:\t%s\n", formatLabels(pod.Labels))
|
||||||
fmt.Fprintf(out, "Status:\t%s\n", string(pod.Status.Phase))
|
fmt.Fprintf(out, "Status:\t%s\n", string(pod.Status.Phase))
|
||||||
fmt.Fprintf(out, "Replication Controllers:\t%s\n", printReplicationControllersByLabels(rcs))
|
fmt.Fprintf(out, "Replication Controllers:\t%s\n", printReplicationControllersByLabels(rcs))
|
||||||
@ -612,7 +612,7 @@ func (d *NodeDescriber) Describe(namespace, name string) (string, error) {
|
|||||||
}
|
}
|
||||||
for i := range allPods.Items {
|
for i := range allPods.Items {
|
||||||
pod := &allPods.Items[i]
|
pod := &allPods.Items[i]
|
||||||
if pod.Spec.Host != name {
|
if pod.Spec.NodeName != name {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
pods = append(pods, pod)
|
pods = append(pods, pod)
|
||||||
|
@ -406,7 +406,7 @@ func printPod(pod *api.Pod, w io.Writer, withNamespace bool) error {
|
|||||||
name,
|
name,
|
||||||
pod.Status.PodIP,
|
pod.Status.PodIP,
|
||||||
"", "",
|
"", "",
|
||||||
podHostString(pod.Spec.Host, pod.Status.HostIP),
|
podHostString(pod.Spec.NodeName, pod.Status.HostIP),
|
||||||
formatLabels(pod.Labels),
|
formatLabels(pod.Labels),
|
||||||
pod.Status.Phase,
|
pod.Status.Phase,
|
||||||
translateTimestamp(pod.CreationTimestamp),
|
translateTimestamp(pod.CreationTimestamp),
|
||||||
|
@ -68,7 +68,7 @@ func applyDefaults(pod *api.Pod, source string, isFile bool, hostname string) er
|
|||||||
glog.V(5).Infof("Using namespace %q for pod %q from %s", pod.Namespace, pod.Name, source)
|
glog.V(5).Infof("Using namespace %q for pod %q from %s", pod.Namespace, pod.Name, source)
|
||||||
|
|
||||||
// Set the Host field to indicate this pod is scheduled on the current node.
|
// Set the Host field to indicate this pod is scheduled on the current node.
|
||||||
pod.Spec.Host = hostname
|
pod.Spec.NodeName = hostname
|
||||||
|
|
||||||
pod.ObjectMeta.SelfLink = getSelfLink(pod.Name, pod.Namespace)
|
pod.ObjectMeta.SelfLink = getSelfLink(pod.Name, pod.Namespace)
|
||||||
return nil
|
return nil
|
||||||
|
@ -99,7 +99,7 @@ func TestReadContainerManifestFromFile(t *testing.T) {
|
|||||||
SelfLink: getSelfLink("test-"+hostname, kubelet.NamespaceDefault),
|
SelfLink: getSelfLink("test-"+hostname, kubelet.NamespaceDefault),
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Host: hostname,
|
NodeName: hostname,
|
||||||
RestartPolicy: api.RestartPolicyAlways,
|
RestartPolicy: api.RestartPolicyAlways,
|
||||||
DNSPolicy: api.DNSClusterFirst,
|
DNSPolicy: api.DNSClusterFirst,
|
||||||
Containers: []api.Container{{
|
Containers: []api.Container{{
|
||||||
@ -126,7 +126,7 @@ func TestReadContainerManifestFromFile(t *testing.T) {
|
|||||||
SelfLink: getSelfLink("12345-"+hostname, kubelet.NamespaceDefault),
|
SelfLink: getSelfLink("12345-"+hostname, kubelet.NamespaceDefault),
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Host: hostname,
|
NodeName: hostname,
|
||||||
RestartPolicy: api.RestartPolicyAlways,
|
RestartPolicy: api.RestartPolicyAlways,
|
||||||
DNSPolicy: api.DNSClusterFirst,
|
DNSPolicy: api.DNSClusterFirst,
|
||||||
Containers: []api.Container{{
|
Containers: []api.Container{{
|
||||||
@ -196,7 +196,7 @@ func TestReadPodsFromFile(t *testing.T) {
|
|||||||
SelfLink: getSelfLink("test-"+hostname, "mynamespace"),
|
SelfLink: getSelfLink("test-"+hostname, "mynamespace"),
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Host: hostname,
|
NodeName: hostname,
|
||||||
RestartPolicy: api.RestartPolicyAlways,
|
RestartPolicy: api.RestartPolicyAlways,
|
||||||
DNSPolicy: api.DNSClusterFirst,
|
DNSPolicy: api.DNSClusterFirst,
|
||||||
Containers: []api.Container{{
|
Containers: []api.Container{{
|
||||||
@ -231,7 +231,7 @@ func TestReadPodsFromFile(t *testing.T) {
|
|||||||
SelfLink: getSelfLink("12345-"+hostname, kubelet.NamespaceDefault),
|
SelfLink: getSelfLink("12345-"+hostname, kubelet.NamespaceDefault),
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Host: hostname,
|
NodeName: hostname,
|
||||||
RestartPolicy: api.RestartPolicyAlways,
|
RestartPolicy: api.RestartPolicyAlways,
|
||||||
DNSPolicy: api.DNSClusterFirst,
|
DNSPolicy: api.DNSClusterFirst,
|
||||||
Containers: []api.Container{{
|
Containers: []api.Container{{
|
||||||
@ -371,7 +371,7 @@ func exampleManifestAndPod(id string) (v1beta1.ContainerManifest, *api.Pod) {
|
|||||||
SelfLink: getSelfLink(id+"-"+hostname, kubelet.NamespaceDefault),
|
SelfLink: getSelfLink(id+"-"+hostname, kubelet.NamespaceDefault),
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Host: hostname,
|
NodeName: hostname,
|
||||||
Containers: []api.Container{
|
Containers: []api.Container{
|
||||||
{
|
{
|
||||||
Name: "c" + id,
|
Name: "c" + id,
|
||||||
|
@ -145,7 +145,7 @@ func TestExtractManifestFromHTTP(t *testing.T) {
|
|||||||
SelfLink: getSelfLink("foo-"+hostname, kubelet.NamespaceDefault),
|
SelfLink: getSelfLink("foo-"+hostname, kubelet.NamespaceDefault),
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Host: hostname,
|
NodeName: hostname,
|
||||||
RestartPolicy: api.RestartPolicyAlways,
|
RestartPolicy: api.RestartPolicyAlways,
|
||||||
DNSPolicy: api.DNSClusterFirst,
|
DNSPolicy: api.DNSClusterFirst,
|
||||||
Containers: []api.Container{{
|
Containers: []api.Container{{
|
||||||
@ -172,7 +172,7 @@ func TestExtractManifestFromHTTP(t *testing.T) {
|
|||||||
SelfLink: getSelfLink("111-"+hostname, kubelet.NamespaceDefault),
|
SelfLink: getSelfLink("111-"+hostname, kubelet.NamespaceDefault),
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Host: hostname,
|
NodeName: hostname,
|
||||||
RestartPolicy: api.RestartPolicyAlways,
|
RestartPolicy: api.RestartPolicyAlways,
|
||||||
DNSPolicy: api.DNSClusterFirst,
|
DNSPolicy: api.DNSClusterFirst,
|
||||||
Containers: []api.Container{{
|
Containers: []api.Container{{
|
||||||
@ -199,7 +199,7 @@ func TestExtractManifestFromHTTP(t *testing.T) {
|
|||||||
SelfLink: getSelfLink("foo-"+hostname, kubelet.NamespaceDefault),
|
SelfLink: getSelfLink("foo-"+hostname, kubelet.NamespaceDefault),
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Host: hostname,
|
NodeName: hostname,
|
||||||
RestartPolicy: api.RestartPolicyAlways,
|
RestartPolicy: api.RestartPolicyAlways,
|
||||||
DNSPolicy: api.DNSClusterFirst,
|
DNSPolicy: api.DNSClusterFirst,
|
||||||
Containers: []api.Container{{
|
Containers: []api.Container{{
|
||||||
@ -230,7 +230,7 @@ func TestExtractManifestFromHTTP(t *testing.T) {
|
|||||||
SelfLink: getSelfLink("foo-"+hostname, kubelet.NamespaceDefault),
|
SelfLink: getSelfLink("foo-"+hostname, kubelet.NamespaceDefault),
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Host: hostname,
|
NodeName: hostname,
|
||||||
RestartPolicy: api.RestartPolicyAlways,
|
RestartPolicy: api.RestartPolicyAlways,
|
||||||
DNSPolicy: api.DNSClusterFirst,
|
DNSPolicy: api.DNSClusterFirst,
|
||||||
Containers: []api.Container{{
|
Containers: []api.Container{{
|
||||||
@ -250,7 +250,7 @@ func TestExtractManifestFromHTTP(t *testing.T) {
|
|||||||
SelfLink: getSelfLink("bar-"+hostname, kubelet.NamespaceDefault),
|
SelfLink: getSelfLink("bar-"+hostname, kubelet.NamespaceDefault),
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Host: hostname,
|
NodeName: hostname,
|
||||||
RestartPolicy: api.RestartPolicyAlways,
|
RestartPolicy: api.RestartPolicyAlways,
|
||||||
DNSPolicy: api.DNSClusterFirst,
|
DNSPolicy: api.DNSClusterFirst,
|
||||||
Containers: []api.Container{{
|
Containers: []api.Container{{
|
||||||
@ -328,7 +328,7 @@ func TestExtractPodsFromHTTP(t *testing.T) {
|
|||||||
Namespace: "mynamespace",
|
Namespace: "mynamespace",
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Host: hostname,
|
NodeName: hostname,
|
||||||
Containers: []api.Container{{Name: "1", Image: "foo", ImagePullPolicy: api.PullAlways}},
|
Containers: []api.Container{{Name: "1", Image: "foo", ImagePullPolicy: api.PullAlways}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -343,7 +343,7 @@ func TestExtractPodsFromHTTP(t *testing.T) {
|
|||||||
SelfLink: getSelfLink("foo-"+hostname, "mynamespace"),
|
SelfLink: getSelfLink("foo-"+hostname, "mynamespace"),
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Host: hostname,
|
NodeName: hostname,
|
||||||
RestartPolicy: api.RestartPolicyAlways,
|
RestartPolicy: api.RestartPolicyAlways,
|
||||||
DNSPolicy: api.DNSClusterFirst,
|
DNSPolicy: api.DNSClusterFirst,
|
||||||
Containers: []api.Container{{
|
Containers: []api.Container{{
|
||||||
@ -369,7 +369,7 @@ func TestExtractPodsFromHTTP(t *testing.T) {
|
|||||||
UID: "111",
|
UID: "111",
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Host: hostname,
|
NodeName: hostname,
|
||||||
Containers: []api.Container{{Name: "1", Image: "foo", ImagePullPolicy: api.PullAlways}},
|
Containers: []api.Container{{Name: "1", Image: "foo", ImagePullPolicy: api.PullAlways}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -379,7 +379,7 @@ func TestExtractPodsFromHTTP(t *testing.T) {
|
|||||||
UID: "222",
|
UID: "222",
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Host: hostname,
|
NodeName: hostname,
|
||||||
Containers: []api.Container{{Name: "2", Image: "bar", ImagePullPolicy: ""}},
|
Containers: []api.Container{{Name: "2", Image: "bar", ImagePullPolicy: ""}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -396,7 +396,7 @@ func TestExtractPodsFromHTTP(t *testing.T) {
|
|||||||
SelfLink: getSelfLink("foo-"+hostname, kubelet.NamespaceDefault),
|
SelfLink: getSelfLink("foo-"+hostname, kubelet.NamespaceDefault),
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Host: hostname,
|
NodeName: hostname,
|
||||||
RestartPolicy: api.RestartPolicyAlways,
|
RestartPolicy: api.RestartPolicyAlways,
|
||||||
DNSPolicy: api.DNSClusterFirst,
|
DNSPolicy: api.DNSClusterFirst,
|
||||||
Containers: []api.Container{{
|
Containers: []api.Container{{
|
||||||
@ -416,7 +416,7 @@ func TestExtractPodsFromHTTP(t *testing.T) {
|
|||||||
SelfLink: getSelfLink("bar-"+hostname, kubelet.NamespaceDefault),
|
SelfLink: getSelfLink("bar-"+hostname, kubelet.NamespaceDefault),
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Host: hostname,
|
NodeName: hostname,
|
||||||
RestartPolicy: api.RestartPolicyAlways,
|
RestartPolicy: api.RestartPolicyAlways,
|
||||||
DNSPolicy: api.DNSClusterFirst,
|
DNSPolicy: api.DNSClusterFirst,
|
||||||
Containers: []api.Container{{
|
Containers: []api.Container{{
|
||||||
|
@ -1869,7 +1869,7 @@ func failedState(cName string) api.ContainerStatus {
|
|||||||
|
|
||||||
func TestPodPhaseWithRestartAlways(t *testing.T) {
|
func TestPodPhaseWithRestartAlways(t *testing.T) {
|
||||||
desiredState := api.PodSpec{
|
desiredState := api.PodSpec{
|
||||||
Host: "machine",
|
NodeName: "machine",
|
||||||
Containers: []api.Container{
|
Containers: []api.Container{
|
||||||
{Name: "containerA"},
|
{Name: "containerA"},
|
||||||
{Name: "containerB"},
|
{Name: "containerB"},
|
||||||
@ -1944,7 +1944,7 @@ func TestPodPhaseWithRestartAlways(t *testing.T) {
|
|||||||
|
|
||||||
func TestPodPhaseWithRestartNever(t *testing.T) {
|
func TestPodPhaseWithRestartNever(t *testing.T) {
|
||||||
desiredState := api.PodSpec{
|
desiredState := api.PodSpec{
|
||||||
Host: "machine",
|
NodeName: "machine",
|
||||||
Containers: []api.Container{
|
Containers: []api.Container{
|
||||||
{Name: "containerA"},
|
{Name: "containerA"},
|
||||||
{Name: "containerB"},
|
{Name: "containerB"},
|
||||||
@ -2032,7 +2032,7 @@ func TestPodPhaseWithRestartNever(t *testing.T) {
|
|||||||
|
|
||||||
func TestPodPhaseWithRestartOnFailure(t *testing.T) {
|
func TestPodPhaseWithRestartOnFailure(t *testing.T) {
|
||||||
desiredState := api.PodSpec{
|
desiredState := api.PodSpec{
|
||||||
Host: "machine",
|
NodeName: "machine",
|
||||||
Containers: []api.Container{
|
Containers: []api.Container{
|
||||||
{Name: "containerA"},
|
{Name: "containerA"},
|
||||||
{Name: "containerB"},
|
{Name: "containerB"},
|
||||||
|
@ -123,11 +123,11 @@ func (everythingMatcher) MatchesSingle() (string, bool) {
|
|||||||
func TestEtcdList(t *testing.T) {
|
func TestEtcdList(t *testing.T) {
|
||||||
podA := &api.Pod{
|
podA := &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||||
Spec: api.PodSpec{Host: "machine"},
|
Spec: api.PodSpec{NodeName: "machine"},
|
||||||
}
|
}
|
||||||
podB := &api.Pod{
|
podB := &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||||
Spec: api.PodSpec{Host: "machine"},
|
Spec: api.PodSpec{NodeName: "machine"},
|
||||||
}
|
}
|
||||||
|
|
||||||
singleElemListResp := &etcd.Response{
|
singleElemListResp := &etcd.Response{
|
||||||
@ -230,11 +230,11 @@ func TestEtcdList(t *testing.T) {
|
|||||||
func TestEtcdCreate(t *testing.T) {
|
func TestEtcdCreate(t *testing.T) {
|
||||||
podA := &api.Pod{
|
podA := &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
||||||
Spec: api.PodSpec{Host: "machine"},
|
Spec: api.PodSpec{NodeName: "machine"},
|
||||||
}
|
}
|
||||||
podB := &api.Pod{
|
podB := &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
||||||
Spec: api.PodSpec{Host: "machine2"},
|
Spec: api.PodSpec{NodeName: "machine2"},
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeWithPodA := tools.EtcdResponseWithError{
|
nodeWithPodA := tools.EtcdResponseWithError{
|
||||||
@ -308,11 +308,11 @@ func TestEtcdCreate(t *testing.T) {
|
|||||||
func TestEtcdCreateWithName(t *testing.T) {
|
func TestEtcdCreateWithName(t *testing.T) {
|
||||||
podA := &api.Pod{
|
podA := &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
||||||
Spec: api.PodSpec{Host: "machine"},
|
Spec: api.PodSpec{NodeName: "machine"},
|
||||||
}
|
}
|
||||||
podB := &api.Pod{
|
podB := &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
||||||
Spec: api.PodSpec{Host: "machine2"},
|
Spec: api.PodSpec{NodeName: "machine2"},
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeWithPodA := tools.EtcdResponseWithError{
|
nodeWithPodA := tools.EtcdResponseWithError{
|
||||||
@ -384,11 +384,11 @@ func TestEtcdCreateWithName(t *testing.T) {
|
|||||||
func TestEtcdUpdate(t *testing.T) {
|
func TestEtcdUpdate(t *testing.T) {
|
||||||
podA := &api.Pod{
|
podA := &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault},
|
||||||
Spec: api.PodSpec{Host: "machine"},
|
Spec: api.PodSpec{NodeName: "machine"},
|
||||||
}
|
}
|
||||||
podB := &api.Pod{
|
podB := &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault, ResourceVersion: "1"},
|
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: api.NamespaceDefault, ResourceVersion: "1"},
|
||||||
Spec: api.PodSpec{Host: "machine2"},
|
Spec: api.PodSpec{NodeName: "machine2"},
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeWithPodA := tools.EtcdResponseWithError{
|
nodeWithPodA := tools.EtcdResponseWithError{
|
||||||
@ -499,11 +499,11 @@ func TestEtcdUpdate(t *testing.T) {
|
|||||||
func TestEtcdUpdateWithName(t *testing.T) {
|
func TestEtcdUpdateWithName(t *testing.T) {
|
||||||
podA := &api.Pod{
|
podA := &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||||
Spec: api.PodSpec{Host: "machine"},
|
Spec: api.PodSpec{NodeName: "machine"},
|
||||||
}
|
}
|
||||||
podB := &api.Pod{
|
podB := &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
|
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
|
||||||
Spec: api.PodSpec{Host: "machine2"},
|
Spec: api.PodSpec{NodeName: "machine2"},
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeWithPodA := tools.EtcdResponseWithError{
|
nodeWithPodA := tools.EtcdResponseWithError{
|
||||||
@ -574,7 +574,7 @@ func TestEtcdUpdateWithName(t *testing.T) {
|
|||||||
func TestEtcdGet(t *testing.T) {
|
func TestEtcdGet(t *testing.T) {
|
||||||
podA := &api.Pod{
|
podA := &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
|
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
|
||||||
Spec: api.PodSpec{Host: "machine"},
|
Spec: api.PodSpec{NodeName: "machine"},
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeWithPodA := tools.EtcdResponseWithError{
|
nodeWithPodA := tools.EtcdResponseWithError{
|
||||||
@ -630,7 +630,7 @@ func TestEtcdGet(t *testing.T) {
|
|||||||
func TestEtcdDelete(t *testing.T) {
|
func TestEtcdDelete(t *testing.T) {
|
||||||
podA := &api.Pod{
|
podA := &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
|
ObjectMeta: api.ObjectMeta{Name: "foo", ResourceVersion: "1"},
|
||||||
Spec: api.PodSpec{Host: "machine"},
|
Spec: api.PodSpec{NodeName: "machine"},
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeWithPodA := tools.EtcdResponseWithError{
|
nodeWithPodA := tools.EtcdResponseWithError{
|
||||||
@ -699,7 +699,7 @@ func TestEtcdWatch(t *testing.T) {
|
|||||||
Namespace: api.NamespaceDefault,
|
Namespace: api.NamespaceDefault,
|
||||||
ResourceVersion: "1",
|
ResourceVersion: "1",
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{Host: "machine"},
|
Spec: api.PodSpec{NodeName: "machine"},
|
||||||
}
|
}
|
||||||
respWithPodA := &etcd.Response{
|
respWithPodA := &etcd.Response{
|
||||||
Node: &etcd.Node{
|
Node: &etcd.Node{
|
||||||
|
@ -147,10 +147,10 @@ func (r *BindingREST) setPodHostAndAnnotations(ctx api.Context, podID, oldMachin
|
|||||||
if !ok {
|
if !ok {
|
||||||
return nil, 0, fmt.Errorf("unexpected object: %#v", obj)
|
return nil, 0, fmt.Errorf("unexpected object: %#v", obj)
|
||||||
}
|
}
|
||||||
if pod.Spec.Host != oldMachine {
|
if pod.Spec.NodeName != oldMachine {
|
||||||
return nil, 0, fmt.Errorf("pod %v is already assigned to host %q", pod.Name, pod.Spec.Host)
|
return nil, 0, fmt.Errorf("pod %v is already assigned to node %q", pod.Name, pod.Spec.NodeName)
|
||||||
}
|
}
|
||||||
pod.Spec.Host = machine
|
pod.Spec.NodeName = machine
|
||||||
if pod.Annotations == nil {
|
if pod.Annotations == nil {
|
||||||
pod.Annotations = make(map[string]string)
|
pod.Annotations = make(map[string]string)
|
||||||
}
|
}
|
||||||
|
@ -231,14 +231,14 @@ func TestListPodList(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||||
Spec: api.PodSpec{Host: "machine"},
|
Spec: api.PodSpec{NodeName: "machine"},
|
||||||
Status: api.PodStatus{Phase: api.PodRunning},
|
Status: api.PodStatus{Phase: api.PodRunning},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||||
Spec: api.PodSpec{Host: "machine"},
|
Spec: api.PodSpec{NodeName: "machine"},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -255,10 +255,10 @@ func TestListPodList(t *testing.T) {
|
|||||||
if len(pods.Items) != 2 {
|
if len(pods.Items) != 2 {
|
||||||
t.Errorf("Unexpected pod list: %#v", pods)
|
t.Errorf("Unexpected pod list: %#v", pods)
|
||||||
}
|
}
|
||||||
if pods.Items[0].Name != "foo" || pods.Items[0].Status.Phase != api.PodRunning || pods.Items[0].Spec.Host != "machine" {
|
if pods.Items[0].Name != "foo" || pods.Items[0].Status.Phase != api.PodRunning || pods.Items[0].Spec.NodeName != "machine" {
|
||||||
t.Errorf("Unexpected pod: %#v", pods.Items[0])
|
t.Errorf("Unexpected pod: %#v", pods.Items[0])
|
||||||
}
|
}
|
||||||
if pods.Items[1].Name != "bar" || pods.Items[1].Spec.Host != "machine" {
|
if pods.Items[1].Name != "bar" || pods.Items[1].Spec.NodeName != "machine" {
|
||||||
t.Errorf("Unexpected pod: %#v", pods.Items[1])
|
t.Errorf("Unexpected pod: %#v", pods.Items[1])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -278,7 +278,7 @@ func TestListPodListSelection(t *testing.T) {
|
|||||||
})},
|
})},
|
||||||
{Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
{Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||||
Spec: api.PodSpec{Host: "barhost"},
|
Spec: api.PodSpec{NodeName: "barhost"},
|
||||||
})},
|
})},
|
||||||
{Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
{Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{Name: "baz"},
|
ObjectMeta: api.ObjectMeta{Name: "baz"},
|
||||||
@ -388,7 +388,7 @@ func TestPodDecode(t *testing.T) {
|
|||||||
func TestGet(t *testing.T) {
|
func TestGet(t *testing.T) {
|
||||||
expect := validNewPod()
|
expect := validNewPod()
|
||||||
expect.Status.Phase = api.PodRunning
|
expect.Status.Phase = api.PodRunning
|
||||||
expect.Spec.Host = "machine"
|
expect.Spec.NodeName = "machine"
|
||||||
|
|
||||||
fakeEtcdClient, helper := newHelper(t)
|
fakeEtcdClient, helper := newHelper(t)
|
||||||
key := etcdtest.AddPrefix("/pods/test/foo")
|
key := etcdtest.AddPrefix("/pods/test/foo")
|
||||||
@ -485,7 +485,7 @@ func TestUpdateWithConflictingNamespace(t *testing.T) {
|
|||||||
Node: &etcd.Node{
|
Node: &etcd.Node{
|
||||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: "default"},
|
ObjectMeta: api.ObjectMeta{Name: "foo", Namespace: "default"},
|
||||||
Spec: api.PodSpec{Host: "machine"},
|
Spec: api.PodSpec{NodeName: "machine"},
|
||||||
}),
|
}),
|
||||||
ModifiedIndex: 1,
|
ModifiedIndex: 1,
|
||||||
},
|
},
|
||||||
@ -645,7 +645,7 @@ func TestDeletePod(t *testing.T) {
|
|||||||
Name: "foo",
|
Name: "foo",
|
||||||
Namespace: api.NamespaceDefault,
|
Namespace: api.NamespaceDefault,
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{Host: "machine"},
|
Spec: api.PodSpec{NodeName: "machine"},
|
||||||
}),
|
}),
|
||||||
ModifiedIndex: 1,
|
ModifiedIndex: 1,
|
||||||
CreatedIndex: 1,
|
CreatedIndex: 1,
|
||||||
@ -1035,8 +1035,8 @@ func TestEtcdCreateBinding(t *testing.T) {
|
|||||||
pod, err := registry.Get(ctx, validNewPod().ObjectMeta.Name)
|
pod, err := registry.Get(ctx, validNewPod().ObjectMeta.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("%s: unexpected error: %v", k, err)
|
t.Errorf("%s: unexpected error: %v", k, err)
|
||||||
} else if pod.(*api.Pod).Spec.Host != test.binding.Target.Name {
|
} else if pod.(*api.Pod).Spec.NodeName != test.binding.Target.Name {
|
||||||
t.Errorf("%s: expected: %v, got: %v", k, pod.(*api.Pod).Spec.Host, test.binding.Target.Name)
|
t.Errorf("%s: expected: %v, got: %v", k, pod.(*api.Pod).Spec.NodeName, test.binding.Target.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1107,7 +1107,7 @@ func TestEtcdUpdateScheduled(t *testing.T) {
|
|||||||
Namespace: api.NamespaceDefault,
|
Namespace: api.NamespaceDefault,
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Host: "machine",
|
NodeName: "machine",
|
||||||
Containers: []api.Container{
|
Containers: []api.Container{
|
||||||
{
|
{
|
||||||
Name: "foobar",
|
Name: "foobar",
|
||||||
@ -1127,7 +1127,7 @@ func TestEtcdUpdateScheduled(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Host: "machine",
|
NodeName: "machine",
|
||||||
Containers: []api.Container{
|
Containers: []api.Container{
|
||||||
{
|
{
|
||||||
Name: "foobar",
|
Name: "foobar",
|
||||||
@ -1170,7 +1170,7 @@ func TestEtcdUpdateStatus(t *testing.T) {
|
|||||||
Namespace: api.NamespaceDefault,
|
Namespace: api.NamespaceDefault,
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Host: "machine",
|
NodeName: "machine",
|
||||||
Containers: []api.Container{
|
Containers: []api.Container{
|
||||||
{
|
{
|
||||||
Image: "foo:v1",
|
Image: "foo:v1",
|
||||||
@ -1190,7 +1190,7 @@ func TestEtcdUpdateStatus(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Host: "machine",
|
NodeName: "machine",
|
||||||
Containers: []api.Container{
|
Containers: []api.Container{
|
||||||
{
|
{
|
||||||
Image: "foo:v2",
|
Image: "foo:v2",
|
||||||
@ -1238,7 +1238,7 @@ func TestEtcdDeletePod(t *testing.T) {
|
|||||||
key = etcdtest.AddPrefix(key)
|
key = etcdtest.AddPrefix(key)
|
||||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||||
Spec: api.PodSpec{Host: "machine"},
|
Spec: api.PodSpec{NodeName: "machine"},
|
||||||
}), 0)
|
}), 0)
|
||||||
_, err := registry.Delete(ctx, "foo", api.NewDeleteOptions(0))
|
_, err := registry.Delete(ctx, "foo", api.NewDeleteOptions(0))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1260,7 +1260,7 @@ func TestEtcdDeletePodMultipleContainers(t *testing.T) {
|
|||||||
key = etcdtest.AddPrefix(key)
|
key = etcdtest.AddPrefix(key)
|
||||||
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
fakeClient.Set(key, runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||||
Spec: api.PodSpec{Host: "machine"},
|
Spec: api.PodSpec{NodeName: "machine"},
|
||||||
}), 0)
|
}), 0)
|
||||||
_, err := registry.Delete(ctx, "foo", api.NewDeleteOptions(0))
|
_, err := registry.Delete(ctx, "foo", api.NewDeleteOptions(0))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1330,13 +1330,13 @@ func TestEtcdList(t *testing.T) {
|
|||||||
{
|
{
|
||||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||||
Spec: api.PodSpec{Host: "machine"},
|
Spec: api.PodSpec{NodeName: "machine"},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
Value: runtime.EncodeOrDie(latest.Codec, &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
ObjectMeta: api.ObjectMeta{Name: "bar"},
|
||||||
Spec: api.PodSpec{Host: "machine"},
|
Spec: api.PodSpec{NodeName: "machine"},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1353,8 +1353,8 @@ func TestEtcdList(t *testing.T) {
|
|||||||
if len(pods.Items) != 2 || pods.Items[0].Name != "foo" || pods.Items[1].Name != "bar" {
|
if len(pods.Items) != 2 || pods.Items[0].Name != "foo" || pods.Items[1].Name != "bar" {
|
||||||
t.Errorf("Unexpected pod list: %#v", pods)
|
t.Errorf("Unexpected pod list: %#v", pods)
|
||||||
}
|
}
|
||||||
if pods.Items[0].Spec.Host != "machine" ||
|
if pods.Items[0].Spec.NodeName != "machine" ||
|
||||||
pods.Items[1].Spec.Host != "machine" {
|
pods.Items[1].Spec.NodeName != "machine" {
|
||||||
t.Errorf("Failed to populate host name.")
|
t.Errorf("Failed to populate host name.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ func MatchPod(label labels.Selector, field fields.Selector) generic.Matcher {
|
|||||||
func PodToSelectableFields(pod *api.Pod) fields.Set {
|
func PodToSelectableFields(pod *api.Pod) fields.Set {
|
||||||
return fields.Set{
|
return fields.Set{
|
||||||
"metadata.name": pod.Name,
|
"metadata.name": pod.Name,
|
||||||
"spec.host": pod.Spec.Host,
|
"spec.host": pod.Spec.NodeName,
|
||||||
"status.phase": string(pod.Status.Phase),
|
"status.phase": string(pod.Status.Phase),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -199,7 +199,7 @@ func LogLocation(getter ResourceGetter, connInfo client.ConnectionInfoGetter, ct
|
|||||||
return nil, nil, errors.NewBadRequest(fmt.Sprintf("a container name must be specified for pod %s", name))
|
return nil, nil, errors.NewBadRequest(fmt.Sprintf("a container name must be specified for pod %s", name))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nodeHost := pod.Spec.Host
|
nodeHost := pod.Spec.NodeName
|
||||||
if len(nodeHost) == 0 {
|
if len(nodeHost) == 0 {
|
||||||
// If pod has not been assigned a host, return an empty location
|
// If pod has not been assigned a host, return an empty location
|
||||||
return nil, nil, nil
|
return nil, nil, nil
|
||||||
@ -242,7 +242,7 @@ func ExecLocation(getter ResourceGetter, connInfo client.ConnectionInfoGetter, c
|
|||||||
return nil, nil, errors.NewBadRequest(fmt.Sprintf("a container name must be specified for pod %s", name))
|
return nil, nil, errors.NewBadRequest(fmt.Sprintf("a container name must be specified for pod %s", name))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nodeHost := pod.Spec.Host
|
nodeHost := pod.Spec.NodeName
|
||||||
if len(nodeHost) == 0 {
|
if len(nodeHost) == 0 {
|
||||||
// If pod has not been assigned a host, return an empty location
|
// If pod has not been assigned a host, return an empty location
|
||||||
return nil, nil, fmt.Errorf("pod %s does not have a host assigned", name)
|
return nil, nil, fmt.Errorf("pod %s does not have a host assigned", name)
|
||||||
@ -284,7 +284,7 @@ func PortForwardLocation(getter ResourceGetter, connInfo client.ConnectionInfoGe
|
|||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeHost := pod.Spec.Host
|
nodeHost := pod.Spec.NodeName
|
||||||
if len(nodeHost) == 0 {
|
if len(nodeHost) == 0 {
|
||||||
// If pod has not been assigned a host, return an empty location
|
// If pod has not been assigned a host, return an empty location
|
||||||
return nil, nil, errors.NewBadRequest(fmt.Sprintf("pod %s does not have a host assigned", name))
|
return nil, nil, errors.NewBadRequest(fmt.Sprintf("pod %s does not have a host assigned", name))
|
||||||
|
@ -189,10 +189,10 @@ func (n *NodeSelector) PodSelectorMatches(pod *api.Pod, existingPods []*api.Pod,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func PodFitsHost(pod *api.Pod, existingPods []*api.Pod, node string) (bool, error) {
|
func PodFitsHost(pod *api.Pod, existingPods []*api.Pod, node string) (bool, error) {
|
||||||
if len(pod.Spec.Host) == 0 {
|
if len(pod.Spec.NodeName) == 0 {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
return pod.Spec.Host == node, nil
|
return pod.Spec.NodeName == node, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type NodeLabelChecker struct {
|
type NodeLabelChecker struct {
|
||||||
@ -300,7 +300,7 @@ func (s *ServiceAffinity) CheckServiceAffinity(pod *api.Pod, existingPods []*api
|
|||||||
}
|
}
|
||||||
if len(nsServicePods) > 0 {
|
if len(nsServicePods) > 0 {
|
||||||
// consider any service pod and fetch the minion its hosted on
|
// consider any service pod and fetch the minion its hosted on
|
||||||
otherMinion, err := s.nodeInfo.GetNodeInfo(nsServicePods[0].Spec.Host)
|
otherMinion, err := s.nodeInfo.GetNodeInfo(nsServicePods[0].Spec.NodeName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@ -369,7 +369,7 @@ func MapPodsToMachines(lister algorithm.PodLister) (map[string][]*api.Pod, error
|
|||||||
return map[string][]*api.Pod{}, err
|
return map[string][]*api.Pod{}, err
|
||||||
}
|
}
|
||||||
for _, scheduledPod := range pods {
|
for _, scheduledPod := range pods {
|
||||||
host := scheduledPod.Spec.Host
|
host := scheduledPod.Spec.NodeName
|
||||||
machineToPods[host] = append(machineToPods[host], scheduledPod)
|
machineToPods[host] = append(machineToPods[host], scheduledPod)
|
||||||
}
|
}
|
||||||
return machineToPods, nil
|
return machineToPods, nil
|
||||||
|
@ -197,7 +197,7 @@ func TestPodFitsHost(t *testing.T) {
|
|||||||
{
|
{
|
||||||
pod: &api.Pod{
|
pod: &api.Pod{
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Host: "foo",
|
NodeName: "foo",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
node: "foo",
|
node: "foo",
|
||||||
@ -207,7 +207,7 @@ func TestPodFitsHost(t *testing.T) {
|
|||||||
{
|
{
|
||||||
pod: &api.Pod{
|
pod: &api.Pod{
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Host: "bar",
|
NodeName: "bar",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
node: "foo",
|
node: "foo",
|
||||||
@ -234,7 +234,7 @@ func newPod(host string, hostPorts ...int) *api.Pod {
|
|||||||
}
|
}
|
||||||
return &api.Pod{
|
return &api.Pod{
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Host: host,
|
NodeName: host,
|
||||||
Containers: []api.Container{
|
Containers: []api.Container{
|
||||||
{
|
{
|
||||||
Ports: networkPorts,
|
Ports: networkPorts,
|
||||||
@ -632,7 +632,7 @@ func TestServiceAffinity(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
pod: &api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector}},
|
pod: &api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector}},
|
||||||
pods: []*api.Pod{{Spec: api.PodSpec{Host: "machine1"}, ObjectMeta: api.ObjectMeta{Labels: selector}}},
|
pods: []*api.Pod{{Spec: api.PodSpec{NodeName: "machine1"}, ObjectMeta: api.ObjectMeta{Labels: selector}}},
|
||||||
node: "machine1",
|
node: "machine1",
|
||||||
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}},
|
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}},
|
||||||
fits: true,
|
fits: true,
|
||||||
@ -641,7 +641,7 @@ func TestServiceAffinity(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
pod: &api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector}},
|
pod: &api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector}},
|
||||||
pods: []*api.Pod{{Spec: api.PodSpec{Host: "machine2"}, ObjectMeta: api.ObjectMeta{Labels: selector}}},
|
pods: []*api.Pod{{Spec: api.PodSpec{NodeName: "machine2"}, ObjectMeta: api.ObjectMeta{Labels: selector}}},
|
||||||
node: "machine1",
|
node: "machine1",
|
||||||
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}},
|
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}},
|
||||||
fits: true,
|
fits: true,
|
||||||
@ -650,7 +650,7 @@ func TestServiceAffinity(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
pod: &api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector}},
|
pod: &api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector}},
|
||||||
pods: []*api.Pod{{Spec: api.PodSpec{Host: "machine3"}, ObjectMeta: api.ObjectMeta{Labels: selector}}},
|
pods: []*api.Pod{{Spec: api.PodSpec{NodeName: "machine3"}, ObjectMeta: api.ObjectMeta{Labels: selector}}},
|
||||||
node: "machine1",
|
node: "machine1",
|
||||||
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}},
|
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}},
|
||||||
fits: false,
|
fits: false,
|
||||||
@ -659,7 +659,7 @@ func TestServiceAffinity(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
pod: &api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns1"}},
|
pod: &api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns1"}},
|
||||||
pods: []*api.Pod{{Spec: api.PodSpec{Host: "machine3"}, ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns1"}}},
|
pods: []*api.Pod{{Spec: api.PodSpec{NodeName: "machine3"}, ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns1"}}},
|
||||||
node: "machine1",
|
node: "machine1",
|
||||||
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}, ObjectMeta: api.ObjectMeta{Namespace: "ns2"}}},
|
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}, ObjectMeta: api.ObjectMeta{Namespace: "ns2"}}},
|
||||||
fits: true,
|
fits: true,
|
||||||
@ -668,7 +668,7 @@ func TestServiceAffinity(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
pod: &api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns1"}},
|
pod: &api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns1"}},
|
||||||
pods: []*api.Pod{{Spec: api.PodSpec{Host: "machine3"}, ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns2"}}},
|
pods: []*api.Pod{{Spec: api.PodSpec{NodeName: "machine3"}, ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns2"}}},
|
||||||
node: "machine1",
|
node: "machine1",
|
||||||
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}, ObjectMeta: api.ObjectMeta{Namespace: "ns1"}}},
|
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}, ObjectMeta: api.ObjectMeta{Namespace: "ns1"}}},
|
||||||
fits: true,
|
fits: true,
|
||||||
@ -677,7 +677,7 @@ func TestServiceAffinity(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
pod: &api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns1"}},
|
pod: &api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns1"}},
|
||||||
pods: []*api.Pod{{Spec: api.PodSpec{Host: "machine3"}, ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns1"}}},
|
pods: []*api.Pod{{Spec: api.PodSpec{NodeName: "machine3"}, ObjectMeta: api.ObjectMeta{Labels: selector, Namespace: "ns1"}}},
|
||||||
node: "machine1",
|
node: "machine1",
|
||||||
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}, ObjectMeta: api.ObjectMeta{Namespace: "ns1"}}},
|
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}, ObjectMeta: api.ObjectMeta{Namespace: "ns1"}}},
|
||||||
fits: false,
|
fits: false,
|
||||||
@ -686,7 +686,7 @@ func TestServiceAffinity(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
pod: &api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector}},
|
pod: &api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector}},
|
||||||
pods: []*api.Pod{{Spec: api.PodSpec{Host: "machine2"}, ObjectMeta: api.ObjectMeta{Labels: selector}}},
|
pods: []*api.Pod{{Spec: api.PodSpec{NodeName: "machine2"}, ObjectMeta: api.ObjectMeta{Labels: selector}}},
|
||||||
node: "machine1",
|
node: "machine1",
|
||||||
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}},
|
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}},
|
||||||
fits: false,
|
fits: false,
|
||||||
@ -695,7 +695,7 @@ func TestServiceAffinity(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
pod: &api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector}},
|
pod: &api.Pod{ObjectMeta: api.ObjectMeta{Labels: selector}},
|
||||||
pods: []*api.Pod{{Spec: api.PodSpec{Host: "machine5"}, ObjectMeta: api.ObjectMeta{Labels: selector}}},
|
pods: []*api.Pod{{Spec: api.PodSpec{NodeName: "machine5"}, ObjectMeta: api.ObjectMeta{Labels: selector}}},
|
||||||
node: "machine4",
|
node: "machine4",
|
||||||
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}},
|
services: []api.Service{{Spec: api.ServiceSpec{Selector: selector}}},
|
||||||
fits: true,
|
fits: true,
|
||||||
|
@ -48,16 +48,16 @@ func TestLeastRequested(t *testing.T) {
|
|||||||
"baz": "blah",
|
"baz": "blah",
|
||||||
}
|
}
|
||||||
machine1Spec := api.PodSpec{
|
machine1Spec := api.PodSpec{
|
||||||
Host: "machine1",
|
NodeName: "machine1",
|
||||||
}
|
}
|
||||||
machine2Spec := api.PodSpec{
|
machine2Spec := api.PodSpec{
|
||||||
Host: "machine2",
|
NodeName: "machine2",
|
||||||
}
|
}
|
||||||
noResources := api.PodSpec{
|
noResources := api.PodSpec{
|
||||||
Containers: []api.Container{},
|
Containers: []api.Container{},
|
||||||
}
|
}
|
||||||
cpuOnly := api.PodSpec{
|
cpuOnly := api.PodSpec{
|
||||||
Host: "machine1",
|
NodeName: "machine1",
|
||||||
Containers: []api.Container{
|
Containers: []api.Container{
|
||||||
{
|
{
|
||||||
Resources: api.ResourceRequirements{
|
Resources: api.ResourceRequirements{
|
||||||
@ -76,9 +76,9 @@ func TestLeastRequested(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
cpuOnly2 := cpuOnly
|
cpuOnly2 := cpuOnly
|
||||||
cpuOnly2.Host = "machine2"
|
cpuOnly2.NodeName = "machine2"
|
||||||
cpuAndMemory := api.PodSpec{
|
cpuAndMemory := api.PodSpec{
|
||||||
Host: "machine2",
|
NodeName: "machine2",
|
||||||
Containers: []api.Container{
|
Containers: []api.Container{
|
||||||
{
|
{
|
||||||
Resources: api.ResourceRequirements{
|
Resources: api.ResourceRequirements{
|
||||||
@ -378,16 +378,16 @@ func TestBalancedResourceAllocation(t *testing.T) {
|
|||||||
"baz": "blah",
|
"baz": "blah",
|
||||||
}
|
}
|
||||||
machine1Spec := api.PodSpec{
|
machine1Spec := api.PodSpec{
|
||||||
Host: "machine1",
|
NodeName: "machine1",
|
||||||
}
|
}
|
||||||
machine2Spec := api.PodSpec{
|
machine2Spec := api.PodSpec{
|
||||||
Host: "machine2",
|
NodeName: "machine2",
|
||||||
}
|
}
|
||||||
noResources := api.PodSpec{
|
noResources := api.PodSpec{
|
||||||
Containers: []api.Container{},
|
Containers: []api.Container{},
|
||||||
}
|
}
|
||||||
cpuOnly := api.PodSpec{
|
cpuOnly := api.PodSpec{
|
||||||
Host: "machine1",
|
NodeName: "machine1",
|
||||||
Containers: []api.Container{
|
Containers: []api.Container{
|
||||||
{
|
{
|
||||||
Resources: api.ResourceRequirements{
|
Resources: api.ResourceRequirements{
|
||||||
@ -406,9 +406,9 @@ func TestBalancedResourceAllocation(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
cpuOnly2 := cpuOnly
|
cpuOnly2 := cpuOnly
|
||||||
cpuOnly2.Host = "machine2"
|
cpuOnly2.NodeName = "machine2"
|
||||||
cpuAndMemory := api.PodSpec{
|
cpuAndMemory := api.PodSpec{
|
||||||
Host: "machine2",
|
NodeName: "machine2",
|
||||||
Containers: []api.Container{
|
Containers: []api.Container{
|
||||||
{
|
{
|
||||||
Resources: api.ResourceRequirements{
|
Resources: api.ResourceRequirements{
|
||||||
|
@ -64,10 +64,10 @@ func (s *ServiceSpread) CalculateSpreadPriority(pod *api.Pod, podLister algorith
|
|||||||
counts := map[string]int{}
|
counts := map[string]int{}
|
||||||
if len(nsServicePods) > 0 {
|
if len(nsServicePods) > 0 {
|
||||||
for _, pod := range nsServicePods {
|
for _, pod := range nsServicePods {
|
||||||
counts[pod.Spec.Host]++
|
counts[pod.Spec.NodeName]++
|
||||||
// Compute the maximum number of pods hosted on any minion
|
// Compute the maximum number of pods hosted on any minion
|
||||||
if counts[pod.Spec.Host] > maxCount {
|
if counts[pod.Spec.NodeName] > maxCount {
|
||||||
maxCount = counts[pod.Spec.Host]
|
maxCount = counts[pod.Spec.NodeName]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,7 +141,7 @@ func (s *ServiceAntiAffinity) CalculateAntiAffinityPriority(pod *api.Pod, podLis
|
|||||||
|
|
||||||
podCounts := map[string]int{}
|
podCounts := map[string]int{}
|
||||||
for _, pod := range nsServicePods {
|
for _, pod := range nsServicePods {
|
||||||
label, exists := labeledMinions[pod.Spec.Host]
|
label, exists := labeledMinions[pod.Spec.NodeName]
|
||||||
if !exists {
|
if !exists {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -35,10 +35,10 @@ func TestServiceSpreadPriority(t *testing.T) {
|
|||||||
"baz": "blah",
|
"baz": "blah",
|
||||||
}
|
}
|
||||||
zone1Spec := api.PodSpec{
|
zone1Spec := api.PodSpec{
|
||||||
Host: "machine1",
|
NodeName: "machine1",
|
||||||
}
|
}
|
||||||
zone2Spec := api.PodSpec{
|
zone2Spec := api.PodSpec{
|
||||||
Host: "machine2",
|
NodeName: "machine2",
|
||||||
}
|
}
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
pod *api.Pod
|
pod *api.Pod
|
||||||
@ -191,13 +191,13 @@ func TestZoneSpreadPriority(t *testing.T) {
|
|||||||
"name": "value",
|
"name": "value",
|
||||||
}
|
}
|
||||||
zone0Spec := api.PodSpec{
|
zone0Spec := api.PodSpec{
|
||||||
Host: "machine01",
|
NodeName: "machine01",
|
||||||
}
|
}
|
||||||
zone1Spec := api.PodSpec{
|
zone1Spec := api.PodSpec{
|
||||||
Host: "machine11",
|
NodeName: "machine11",
|
||||||
}
|
}
|
||||||
zone2Spec := api.PodSpec{
|
zone2Spec := api.PodSpec{
|
||||||
Host: "machine21",
|
NodeName: "machine21",
|
||||||
}
|
}
|
||||||
labeledNodes := map[string]map[string]string{
|
labeledNodes := map[string]map[string]string{
|
||||||
"machine01": nozone, "machine02": nozone,
|
"machine01": nozone, "machine02": nozone,
|
||||||
|
@ -267,7 +267,7 @@ func (factory *ConfigFactory) makeDefaultErrorFunc(backoff *podBackoff, podQueue
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if pod.Spec.Host == "" {
|
if pod.Spec.NodeName == "" {
|
||||||
podQueue.Add(pod)
|
podQueue.Add(pod)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -142,7 +142,7 @@ func (s *Scheduler) scheduleOne() {
|
|||||||
s.config.Recorder.Eventf(pod, "scheduled", "Successfully assigned %v to %v", pod.Name, dest)
|
s.config.Recorder.Eventf(pod, "scheduled", "Successfully assigned %v to %v", pod.Name, dest)
|
||||||
// tell the model to assume that this binding took effect.
|
// tell the model to assume that this binding took effect.
|
||||||
assumed := *pod
|
assumed := *pod
|
||||||
assumed.Spec.Host = dest
|
assumed.Spec.NodeName = dest
|
||||||
s.config.Modeler.AssumePod(&assumed)
|
s.config.Modeler.AssumePod(&assumed)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ func podWithID(id, desiredHost string) *api.Pod {
|
|||||||
return &api.Pod{
|
return &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{Name: id, SelfLink: testapi.SelfLink("pods", id)},
|
ObjectMeta: api.ObjectMeta{Name: id, SelfLink: testapi.SelfLink("pods", id)},
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
Host: desiredHost,
|
NodeName: desiredHost,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ func ClusterLevelLoggingWithElasticsearch(c *client.Client) {
|
|||||||
Command: []string{"bash", "-c", fmt.Sprintf("i=0; while ((i < %d)); do echo \"%d %s $i %s\"; i=$$(($i+1)); done", countTo, i, taintName, podName)},
|
Command: []string{"bash", "-c", fmt.Sprintf("i=0; while ((i < %d)); do echo \"%d %s $i %s\"; i=$$(($i+1)); done", countTo, i, taintName, podName)},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Host: node.Name,
|
NodeName: node.Name,
|
||||||
RestartPolicy: api.RestartPolicyNever,
|
RestartPolicy: api.RestartPolicyNever,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -60,7 +60,7 @@ func LaunchNetTestPodPerNode(f *Framework, nodes *api.NodeList, name string) []s
|
|||||||
Ports: []api.ContainerPort{{ContainerPort: 8080}},
|
Ports: []api.ContainerPort{{ContainerPort: 8080}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Host: node.Name,
|
NodeName: node.Name,
|
||||||
RestartPolicy: api.RestartPolicyNever,
|
RestartPolicy: api.RestartPolicyNever,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -263,7 +263,7 @@ func testPDPod(diskName, targetHost string, readOnly bool) *api.Pod {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Host: targetHost,
|
NodeName: targetHost,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,8 +128,8 @@ func logPodStates(pods []api.Pod) {
|
|||||||
if len(pod.ObjectMeta.Name) > maxPodW {
|
if len(pod.ObjectMeta.Name) > maxPodW {
|
||||||
maxPodW = len(pod.ObjectMeta.Name)
|
maxPodW = len(pod.ObjectMeta.Name)
|
||||||
}
|
}
|
||||||
if len(pod.Spec.Host) > maxNodeW {
|
if len(pod.Spec.NodeName) > maxNodeW {
|
||||||
maxNodeW = len(pod.Spec.Host)
|
maxNodeW = len(pod.Spec.NodeName)
|
||||||
}
|
}
|
||||||
if len(pod.Status.Phase) > maxPhaseW {
|
if len(pod.Status.Phase) > maxPhaseW {
|
||||||
maxPhaseW = len(pod.Status.Phase)
|
maxPhaseW = len(pod.Status.Phase)
|
||||||
@ -145,7 +145,7 @@ func logPodStates(pods []api.Pod) {
|
|||||||
maxPodW, "POD", maxNodeW, "NODE", maxPhaseW, "PHASE", "CONDITIONS")
|
maxPodW, "POD", maxNodeW, "NODE", maxPhaseW, "PHASE", "CONDITIONS")
|
||||||
for _, pod := range pods {
|
for _, pod := range pods {
|
||||||
Logf("%-[1]*[2]s %-[3]*[4]s %-[5]*[6]s %[7]s",
|
Logf("%-[1]*[2]s %-[3]*[4]s %-[5]*[6]s %[7]s",
|
||||||
maxPodW, pod.ObjectMeta.Name, maxNodeW, pod.Spec.Host, maxPhaseW, pod.Status.Phase, pod.Status.Conditions)
|
maxPodW, pod.ObjectMeta.Name, maxNodeW, pod.Spec.NodeName, maxPhaseW, pod.Status.Phase, pod.Status.Conditions)
|
||||||
}
|
}
|
||||||
Logf("") // Final empty line helps for readability.
|
Logf("") // Final empty line helps for readability.
|
||||||
}
|
}
|
||||||
@ -156,12 +156,12 @@ func podRunningReady(p *api.Pod) (bool, error) {
|
|||||||
// Check the phase is running.
|
// Check the phase is running.
|
||||||
if p.Status.Phase != api.PodRunning {
|
if p.Status.Phase != api.PodRunning {
|
||||||
return false, fmt.Errorf("want pod '%s' on '%s' to be '%v' but was '%v'",
|
return false, fmt.Errorf("want pod '%s' on '%s' to be '%v' but was '%v'",
|
||||||
p.ObjectMeta.Name, p.Spec.Host, api.PodRunning, p.Status.Phase)
|
p.ObjectMeta.Name, p.Spec.NodeName, api.PodRunning, p.Status.Phase)
|
||||||
}
|
}
|
||||||
// Check the ready condition is true.
|
// Check the ready condition is true.
|
||||||
if !podReady(p) {
|
if !podReady(p) {
|
||||||
return false, fmt.Errorf("pod '%s' on '%s' didn't have condition {%v %v}; conditions: %v",
|
return false, fmt.Errorf("pod '%s' on '%s' didn't have condition {%v %v}; conditions: %v",
|
||||||
p.ObjectMeta.Name, p.Spec.Host, api.PodReady, api.ConditionTrue, p.Status.Conditions)
|
p.ObjectMeta.Name, p.Spec.NodeName, api.PodReady, api.ConditionTrue, p.Status.Conditions)
|
||||||
|
|
||||||
}
|
}
|
||||||
return true, nil
|
return true, nil
|
||||||
@ -532,8 +532,8 @@ func testContainerOutputInNamespace(scenarioName string, c *client.Client, pod *
|
|||||||
Failf("Failed to get pod status: %v", err)
|
Failf("Failed to get pod status: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
By(fmt.Sprintf("Trying to get logs from host %s pod %s container %s: %v",
|
By(fmt.Sprintf("Trying to get logs from node %s pod %s container %s: %v",
|
||||||
podStatus.Spec.Host, podStatus.Name, containerName, err))
|
podStatus.Spec.NodeName, podStatus.Name, containerName, err))
|
||||||
var logs []byte
|
var logs []byte
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
@ -542,15 +542,15 @@ func testContainerOutputInNamespace(scenarioName string, c *client.Client, pod *
|
|||||||
logs, err = c.Get().
|
logs, err = c.Get().
|
||||||
Prefix("proxy").
|
Prefix("proxy").
|
||||||
Resource("nodes").
|
Resource("nodes").
|
||||||
Name(podStatus.Spec.Host).
|
Name(podStatus.Spec.NodeName).
|
||||||
Suffix("containerLogs", ns, podStatus.Name, containerName).
|
Suffix("containerLogs", ns, podStatus.Name, containerName).
|
||||||
Do().
|
Do().
|
||||||
Raw()
|
Raw()
|
||||||
fmt.Sprintf("pod logs:%v\n", string(logs))
|
fmt.Sprintf("pod logs:%v\n", string(logs))
|
||||||
By(fmt.Sprintf("pod logs:%v\n", string(logs)))
|
By(fmt.Sprintf("pod logs:%v\n", string(logs)))
|
||||||
if strings.Contains(string(logs), "Internal Error") {
|
if strings.Contains(string(logs), "Internal Error") {
|
||||||
By(fmt.Sprintf("Failed to get logs from host %q pod %q container %q: %v",
|
By(fmt.Sprintf("Failed to get logs from node %q pod %q container %q: %v",
|
||||||
podStatus.Spec.Host, podStatus.Name, containerName, string(logs)))
|
podStatus.Spec.NodeName, podStatus.Name, containerName, string(logs)))
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -613,15 +613,15 @@ func Diff(oldPods *api.PodList, curPods *api.PodList) PodDiff {
|
|||||||
|
|
||||||
// New pods will show up in the curPods list but not in oldPods. They have oldhostname/phase == nonexist.
|
// New pods will show up in the curPods list but not in oldPods. They have oldhostname/phase == nonexist.
|
||||||
for _, pod := range curPods.Items {
|
for _, pod := range curPods.Items {
|
||||||
podInfoMap[pod.Name] = &podInfo{hostname: pod.Spec.Host, phase: string(pod.Status.Phase), oldHostname: nonExist, oldPhase: nonExist}
|
podInfoMap[pod.Name] = &podInfo{hostname: pod.Spec.NodeName, phase: string(pod.Status.Phase), oldHostname: nonExist, oldPhase: nonExist}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deleted pods will show up in the oldPods list but not in curPods. They have a hostname/phase == nonexist.
|
// Deleted pods will show up in the oldPods list but not in curPods. They have a hostname/phase == nonexist.
|
||||||
for _, pod := range oldPods.Items {
|
for _, pod := range oldPods.Items {
|
||||||
if info, ok := podInfoMap[pod.Name]; ok {
|
if info, ok := podInfoMap[pod.Name]; ok {
|
||||||
info.oldHostname, info.oldPhase = pod.Spec.Host, string(pod.Status.Phase)
|
info.oldHostname, info.oldPhase = pod.Spec.NodeName, string(pod.Status.Phase)
|
||||||
} else {
|
} else {
|
||||||
podInfoMap[pod.Name] = &podInfo{hostname: nonExist, phase: nonExist, oldHostname: pod.Spec.Host, oldPhase: string(pod.Status.Phase)}
|
podInfoMap[pod.Name] = &podInfo{hostname: nonExist, phase: nonExist, oldHostname: pod.Spec.NodeName, oldPhase: string(pod.Status.Phase)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return podInfoMap
|
return podInfoMap
|
||||||
@ -733,7 +733,7 @@ func RunRC(c *client.Client, name string, ns, image string, replicas int) error
|
|||||||
failedContainers = failedContainers + v.restarts
|
failedContainers = failedContainers + v.restarts
|
||||||
}
|
}
|
||||||
} else if p.Status.Phase == api.PodPending {
|
} else if p.Status.Phase == api.PodPending {
|
||||||
if p.Spec.Host == "" {
|
if p.Spec.NodeName == "" {
|
||||||
waiting++
|
waiting++
|
||||||
} else {
|
} else {
|
||||||
pending++
|
pending++
|
||||||
|
@ -102,7 +102,7 @@ func TestClient(t *testing.T) {
|
|||||||
if actual.Name != got.Name {
|
if actual.Name != got.Name {
|
||||||
t.Errorf("expected pod %#v, got %#v", got, actual)
|
t.Errorf("expected pod %#v, got %#v", got, actual)
|
||||||
}
|
}
|
||||||
if actual.Spec.Host != "" {
|
if actual.Spec.NodeName != "" {
|
||||||
t.Errorf("expected pod to be unscheduled, got %#v", actual)
|
t.Errorf("expected pod to be unscheduled, got %#v", actual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,7 @@ func StartPods(numPods int, host string, restClient *client.Client) error {
|
|||||||
|
|
||||||
// Make the rc unique to the given host.
|
// Make the rc unique to the given host.
|
||||||
controller.Spec.Replicas = numPods
|
controller.Spec.Replicas = numPods
|
||||||
controller.Spec.Template.Spec.Host = host
|
controller.Spec.Template.Spec.NodeName = host
|
||||||
controller.Name = controller.Name + host
|
controller.Name = controller.Name + host
|
||||||
controller.Spec.Selector["host"] = host
|
controller.Spec.Selector["host"] = host
|
||||||
controller.Spec.Template.Labels["host"] = host
|
controller.Spec.Template.Labels["host"] = host
|
||||||
|
@ -104,7 +104,7 @@ func podScheduled(c *client.Client, podNamespace, podName string) wait.Condition
|
|||||||
// This could be a connection error so we want to retry.
|
// This could be a connection error so we want to retry.
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
if pod.Spec.Host == "" {
|
if pod.Spec.NodeName == "" {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
return true, nil
|
return true, nil
|
||||||
|
@ -185,7 +185,7 @@ func main() {
|
|||||||
Ports: []api.ContainerPort{{ContainerPort: 9376}},
|
Ports: []api.ContainerPort{{ContainerPort: 9376}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Host: node.Name,
|
NodeName: node.Name,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
glog.V(4).Infof("Pod create %s/%s request took %v", ns, podName, time.Since(t))
|
glog.V(4).Infof("Pod create %s/%s request took %v", ns, podName, time.Since(t))
|
||||||
|
Loading…
Reference in New Issue
Block a user