Skip to content
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

Switch feature flag to beta for pod replacement policy and add e2e test #121491

Merged

Conversation

dejanzele
Copy link
Contributor

@dejanzele dejanzele commented Oct 24, 2023

What type of PR is this?

/sig apps
/kind feature

What this PR does / why we need it:

Promotes feature flag for PodReplacementPolicy to beta and adds e2e test for the Failed PodReplacementPolicy.

Which issue(s) this PR fixes:

Part of kubernetes/enhancements#3939

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Promote PodReplacementPolicy to beta.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. sig/apps Categorizes an issue or PR as relevant to SIG Apps. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Oct 24, 2023
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Oct 24, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @dejanzele. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added area/test sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels Oct 24, 2023
@kannon92
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 24, 2023
test/e2e/apps/job.go Outdated Show resolved Hide resolved
test/e2e/apps/job.go Outdated Show resolved Hide resolved
test/e2e/apps/job.go Outdated Show resolved Hide resolved
@kannon92
Copy link
Contributor

You should add a release note for this.
/release-note-edit Promote PodReplacementPolicy to beta.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Oct 24, 2023
pkg/features/kube_features.go Show resolved Hide resolved
test/e2e/apps/job.go Outdated Show resolved Hide resolved
test/e2e/apps/job.go Outdated Show resolved Hide resolved
pods, err := e2ejob.GetJobPods(ctx, f.ClientSet, f.Namespace.Name, job.Name)
framework.ExpectNoError(err, "failed to get pod list for job in namespace: %s", f.Namespace.Name)

framework.ExpectNoError(e2epod.DeletePodsWithGracePeriod(ctx, f.ClientSet, pods.Items, 0), "failed to delete pods in namespace: %s", f.Namespace.Name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually let's redesign this test:

  1. Set -termination-grace-period to something long (1min should be fine).
  2. Change DeletePodsWithGracePeriod to have a grace period (not zero).
  3. At this point (line 364, ), check that the Job status has one terminating pod and no active pods.
  4. Once we have verified the desired status, issue another DeletePodsWithGracePeriod, but this time with zero grace period. This will cause a SIGKILL and immediately delete the pods.
  5. Verify pods recreated.

pkg/features/kube_features.go Show resolved Hide resolved
test/e2e/apps/job.go Outdated Show resolved Hide resolved
test/e2e/apps/job.go Outdated Show resolved Hide resolved
test/e2e/apps/job.go Outdated Show resolved Hide resolved
Copy link
Member

@alculquicondor alculquicondor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/retitle Switch feature flag to beta for pod replacement policy and add e2e test

@k8s-ci-robot k8s-ci-robot changed the title [WIP][DO NOT MERGE] Switch feature flag to beta for pod replacement policy and add e2e test Switch feature flag to beta for pod replacement policy and add e2e test Oct 25, 2023
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 26, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: e96ce45c0275349a0d1c0d68dd6116896b4a23e5

test/e2e/apps/job.go Outdated Show resolved Hide resolved
Comment on lines +369 to +374
if job.Status.Active == 0 && job.Status.Failed == 0 && *job.Status.Terminating == 1 {
return ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what prevents the pod from finishing too fast, so that it's in a terminating state before reaching Failed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm good question, kubelet needs some time to transition it, but maybe there is a small chance it happens super fast and test fails. I don't have a good answer, do you have ideas?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's why we had the grace period in the pod itself... the tricky part is forcing a delete after sending a SIGTERM.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 26, 2023
@alculquicondor
Copy link
Member

/lgtm
/approve
/assign @soltysh

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 26, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 16e1a0a28f9962a65ecf1c8efe4b654d1db9317a

@alculquicondor
Copy link
Member

Can you squash?

update pod replacement policy feature flag comment and refactor the e2e test for pod replacement policy

minor fixes for pod replacement policy and e2e test

fix wrong assertions for pod replacement policy e2e test

more fixes to pod replacement policy e2e test

refactor PodReplacementPolicy e2e test to use finalizers

fix unit tests when pod replacement policy feature flag is promoted to beta

fix podgc controller unit tests when pod replacement feature is enabled

fix lint issue in pod replacement policy e2e test

assert no error in defer function for removing finalizer in pod replacement policy e2e test

implement test using a sh trap for pod replacement policy

reduce sleep after SIGTERM in pod replacement policy e2e test to 5s
@dejanzele
Copy link
Contributor Author

Can you squash?

done

@alculquicondor
Copy link
Member

Thanks!
/lgtm

job := e2ejob.NewTestJob("", "pod-recreate-failed", v1.RestartPolicyNever, 1, 1, nil, 1)
job.Spec.PodReplacementPolicy = ptr.To(batchv1.Failed)
job.Spec.Template.Spec.Containers[0].Command = []string{"/bin/sh", "-c", `_term(){
sleep 5
Copy link
Contributor

@mimowo mimowo Oct 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary if we follow the design proposed here: #121491 (comment)? I think we could use the "notTerminate" image, and another call for DeletePodsWithGracePeriod with 0. Then, we don't need the 5s penalty. But I'm happy to do this improvement later in the test freeze not to risk the code freeze.

EDIT: Actually, I tested locally with kubectl, that when the first delete for a sleep pod has grace-period=30, then the next executed right after with grace-period=0 does not terminate the pod quickly (still takes ~30s). This was surprising, but in that case I don't see any easy improvement.

Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alculquicondor, dejanzele, soltysh

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 27, 2023
@mimowo
Copy link
Contributor

mimowo commented Oct 27, 2023

/retest

@k8s-ci-robot k8s-ci-robot merged commit 6f4ad7a into kubernetes:master Oct 27, 2023
16 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.29 milestone Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

6 participants