mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
Set default status to pending for pods from non-apiserver sources
This commit is contained in:
parent
d351a0f626
commit
dc5b35a570
@ -70,6 +70,9 @@ func applyDefaults(pod *api.Pod, source string, isFile bool, nodeName string) er
|
|||||||
}
|
}
|
||||||
// The generated UID is the hash of the file.
|
// The generated UID is the hash of the file.
|
||||||
pod.Annotations[kubetypes.ConfigHashAnnotationKey] = string(pod.UID)
|
pod.Annotations[kubetypes.ConfigHashAnnotationKey] = string(pod.UID)
|
||||||
|
|
||||||
|
// Set the default status to pending.
|
||||||
|
pod.Status.Phase = api.PodPending
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,6 +93,9 @@ func TestReadPodsFromFile(t *testing.T) {
|
|||||||
Containers: []api.Container{{Name: "image", Image: "test/image", SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults()}},
|
Containers: []api.Container{{Name: "image", Image: "test/image", SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults()}},
|
||||||
SecurityContext: &api.PodSecurityContext{},
|
SecurityContext: &api.PodSecurityContext{},
|
||||||
},
|
},
|
||||||
|
Status: api.PodStatus{
|
||||||
|
Phase: api.PodPending,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
expected: CreatePodUpdate(kubetypes.SET, kubetypes.FileSource, &api.Pod{
|
expected: CreatePodUpdate(kubetypes.SET, kubetypes.FileSource, &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
@ -115,6 +118,9 @@ func TestReadPodsFromFile(t *testing.T) {
|
|||||||
SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults()}},
|
SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults()}},
|
||||||
SecurityContext: &api.PodSecurityContext{},
|
SecurityContext: &api.PodSecurityContext{},
|
||||||
},
|
},
|
||||||
|
Status: api.PodStatus{
|
||||||
|
Phase: api.PodPending,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -147,6 +147,9 @@ func TestExtractPodsFromHTTP(t *testing.T) {
|
|||||||
Containers: []api.Container{{Name: "1", Image: "foo", ImagePullPolicy: api.PullAlways}},
|
Containers: []api.Container{{Name: "1", Image: "foo", ImagePullPolicy: api.PullAlways}},
|
||||||
SecurityContext: &api.PodSecurityContext{},
|
SecurityContext: &api.PodSecurityContext{},
|
||||||
},
|
},
|
||||||
|
Status: api.PodStatus{
|
||||||
|
Phase: api.PodPending,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
expected: CreatePodUpdate(kubetypes.SET,
|
expected: CreatePodUpdate(kubetypes.SET,
|
||||||
kubetypes.HTTPSource,
|
kubetypes.HTTPSource,
|
||||||
@ -172,6 +175,9 @@ func TestExtractPodsFromHTTP(t *testing.T) {
|
|||||||
ImagePullPolicy: "Always",
|
ImagePullPolicy: "Always",
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
|
Status: api.PodStatus{
|
||||||
|
Phase: api.PodPending,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -192,6 +198,9 @@ func TestExtractPodsFromHTTP(t *testing.T) {
|
|||||||
Containers: []api.Container{{Name: "1", Image: "foo", ImagePullPolicy: api.PullAlways}},
|
Containers: []api.Container{{Name: "1", Image: "foo", ImagePullPolicy: api.PullAlways}},
|
||||||
SecurityContext: &api.PodSecurityContext{},
|
SecurityContext: &api.PodSecurityContext{},
|
||||||
},
|
},
|
||||||
|
Status: api.PodStatus{
|
||||||
|
Phase: api.PodPending,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
@ -203,6 +212,9 @@ func TestExtractPodsFromHTTP(t *testing.T) {
|
|||||||
Containers: []api.Container{{Name: "2", Image: "bar:bartag", ImagePullPolicy: ""}},
|
Containers: []api.Container{{Name: "2", Image: "bar:bartag", ImagePullPolicy: ""}},
|
||||||
SecurityContext: &api.PodSecurityContext{},
|
SecurityContext: &api.PodSecurityContext{},
|
||||||
},
|
},
|
||||||
|
Status: api.PodStatus{
|
||||||
|
Phase: api.PodPending,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -230,6 +242,9 @@ func TestExtractPodsFromHTTP(t *testing.T) {
|
|||||||
ImagePullPolicy: "Always",
|
ImagePullPolicy: "Always",
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
|
Status: api.PodStatus{
|
||||||
|
Phase: api.PodPending,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
&api.Pod{
|
&api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
@ -253,6 +268,9 @@ func TestExtractPodsFromHTTP(t *testing.T) {
|
|||||||
ImagePullPolicy: "IfNotPresent",
|
ImagePullPolicy: "IfNotPresent",
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
|
Status: api.PodStatus{
|
||||||
|
Phase: api.PodPending,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user