-
Notifications
You must be signed in to change notification settings - Fork 1.6k
KEP 753: SidecarContainers is GA #5081
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
46408fc
to
ee4c27a
Compare
PRR shadow:
Can you update this to reflect the reality for GA? I think the TBD should be filled out here as part of the GA promotion. |
It looks like there are no unit tests for enabling/disabling the SidecarContainers feature. Most likely, a test like the following should have been added to TestSidecarContainersEnablementfunc TestSidecarContainersEnablement(t *testing.T) {
containerRestartPolicyAlways := api.ContainerRestartPolicyAlways
defaultTerminationGracePeriodSeconds := int64(30)
getInitContainerRestartPolicy := func(pod *api.Pod) *api.ContainerRestartPolicy {
return pod.Spec.InitContainers[0].RestartPolicy
}
podWithInitContainerRestartPolicy := func() *api.Pod {
return &api.Pod{
ObjectMeta: metav1.ObjectMeta{
Namespace: "default",
Name: "foo",
ResourceVersion: "1",
},
Spec: api.PodSpec{
DNSPolicy: api.DNSDefault,
RestartPolicy: api.RestartPolicyAlways,
InitContainers: []api.Container{
{
Name: "restartable1",
Image: "image",
ImagePullPolicy: "IfNotPresent",
TerminationMessagePolicy: "File",
RestartPolicy: &containerRestartPolicyAlways,
},
},
Containers: []api.Container{
{
Name: "regular1",
Image: "image",
ImagePullPolicy: "IfNotPresent",
TerminationMessagePolicy: "File",
},
},
TerminationGracePeriodSeconds: &defaultTerminationGracePeriodSeconds,
},
}
}
podWithoutInitContainerRestartPolicy := func() *api.Pod {
return &api.Pod{
ObjectMeta: metav1.ObjectMeta{
Namespace: "default",
Name: "foo",
ResourceVersion: "1",
},
Spec: api.PodSpec{
DNSPolicy: api.DNSDefault,
RestartPolicy: api.RestartPolicyAlways,
InitContainers: []api.Container{
{
Name: "restartable1",
Image: "image",
ImagePullPolicy: "IfNotPresent",
TerminationMessagePolicy: "File",
},
},
Containers: []api.Container{
{
Name: "regular1",
Image: "image",
ImagePullPolicy: "IfNotPresent",
TerminationMessagePolicy: "File",
},
},
TerminationGracePeriodSeconds: &defaultTerminationGracePeriodSeconds,
},
}
}
testCases := []struct {
description string
gateEnabled bool
newPod *api.Pod
wantPod *api.Pod
}{
{
description: "gate enabled, creating pods with init container's restart policy",
gateEnabled: true,
newPod: podWithInitContainerRestartPolicy(),
wantPod: podWithInitContainerRestartPolicy(),
},
{
description: "gate disabled, creating pods with init container's restart policy",
gateEnabled: false,
newPod: podWithInitContainerRestartPolicy(),
wantPod: podWithoutInitContainerRestartPolicy(),
},
}
for _, tc := range testCases {
t.Run(tc.description, func(t *testing.T) {
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.SidecarContainers, tc.gateEnabled)
newPod := tc.newPod
Strategy.PrepareForCreate(genericapirequest.NewContext(), newPod)
if errs := Strategy.Validate(genericapirequest.NewContext(), newPod); len(errs) != 0 {
t.Errorf("Unexpected error: %v", errs.ToAggregate())
}
if diff := cmp.Diff(getInitContainerRestartPolicy(newPod), getInitContainerRestartPolicy(tc.wantPod)); diff != "" {
t.Fatalf("Unexpected modification to container restart policy; diff (-got +want)\n%s", diff)
}
})
}
} However, once the SidecarContainers feature reaches GA and is locked to default in kubernetes/kubernetes#129731, the above test will no longer work and will need to be removed within that PR. I also looked at other KEPs, and in most cases, there are no unit tests for feature enablement/disablement. So, would simply updating the description be sufficient? Edit: As shown in kubernetes/kubernetes#129731, using |
Two out of the three are already covered by E2E tests. So, should we just add links to the E2E tests?
The last one is about unintended use case. I think that explaining it in the Sidecar Containers's best practice would make implementing a test in Kubernetes unnecessary. Writing a test for this could be a bit tricky, but if it's absolutely necessary, I can look into whether it can be implemented. |
ee4c27a
to
311294d
Compare
thanks all, updated! |
9bf05fb
to
4a64601
Compare
/approve |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jpbetz, mrunalp, SergeyKanzhelev, swatisehgal The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
SidecarContainer feature is going GA.
#753
All bugs listed were reviewed and are not critical for GA promotion.