Skip to content

[KEP-3521] Part 3: Bug fixes, integration & E2E Test#113442

Merged
k8s-ci-robot merged 3 commits intokubernetes:masterfrom
Huang-Wei:kep-3521-C
Nov 8, 2022
Merged

[KEP-3521] Part 3: Bug fixes, integration & E2E Test#113442
k8s-ci-robot merged 3 commits intokubernetes:masterfrom
Huang-Wei:kep-3521-C

Conversation

@Huang-Wei
Copy link
Copy Markdown
Member

@Huang-Wei Huang-Wei commented Oct 29, 2022

What type of PR is this?

/kind feature
/sig scheduling

What this PR does / why we need it:

This PR is rebased atop Part 1 (#113274) & Part 2 (#113275), covering the following logic:

Meanwhile, I'm creating a draft PR in test-infra kubernetes/test-infra#27862 to enable it in CI.

Which issue(s) this PR fixes:

Part of #113269

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

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

- [KEP]: https://github.com/kubernetes/enhancements/tree/master/keps/sig-scheduling/3521-pod-scheduling-readiness

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/feature Categorizes issue or PR as related to a new feature. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. area/code-generation area/e2e-test-framework Issues or PRs related to refactoring the kubernetes e2e test framework needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. area/stable-metrics Issues or PRs involving stable metrics area/test needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Oct 29, 2022
@k8s-ci-robot k8s-ci-robot added kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels Oct 29, 2022
@Huang-Wei
Copy link
Copy Markdown
Member Author

Huang-Wei commented Oct 29, 2022

E2E test is WIP. Completed.

@k8s-triage-robot
Copy link
Copy Markdown

This PR may require stable metrics review.

Stable metrics are guaranteed to not change. Please review the documentation for the requirements and lifecycle of stable metrics and ensure that your metrics meet these guidelines.

@k8s-triage-robot
Copy link
Copy Markdown

This PR may require API review.

If so, when the changes are ready, complete the pre-review checklist and request an API review.

Status of requested reviews is tracked in the API Review project.

@alculquicondor
Copy link
Copy Markdown
Member

/assign @ahg-g

@fedebongio
Copy link
Copy Markdown
Contributor

/remove-sig api-machinery

@k8s-ci-robot k8s-ci-robot removed the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Nov 1, 2022
@k8s-ci-robot k8s-ci-robot added the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Nov 1, 2022
@Huang-Wei
Copy link
Copy Markdown
Member Author

E2E is now only tested locally:

  • Create a local cluster having the feature enabled:
    FEATURE_GATES=PodSchedulingReadiness=true hack/local-up-cluster.sh
    
  • Building e2e test binary:
    make WHAT=test/e2e/e2e.test
    
  • Running e2e test
    _output/bin/e2e.test --provider=local --ginkgo.focus='PodSchedulingReadiness'
    
  • Test log: e2e.log

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is good to have for sure, but I assume that podInfo for a gated pod should never have its Timestamp set beyond the first time we observed the pod (on Add(...)) because we should have never attempted to schedule the pod (i.e., Attempts should always be zero), and so Timestamp shouldn't be reset.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, attempts is always zero, so duration := p.calculateBackoffDuration(podInfo) would always return podInitialBackoffDuration. In other words, if the duration between the pod is added and updated less than podInitialBackoffDuration, isPodBackingOff would return true.

This bug can be observed by running hack/local-up-cluster.sh with the following diff:

diff --git a/hack/local-up-cluster.sh b/hack/local-up-cluster.sh
index 6ec7f1ded28..e2c67dd0e34 100755
--- a/hack/local-up-cluster.sh
+++ b/hack/local-up-cluster.sh
@@ -869,6 +869,8 @@ clientConnection:
   kubeconfig: ${CERT_DIR}/scheduler.kubeconfig
 leaderElection:
   leaderElect: false
+podInitialBackoffSeconds: 120
+podMaxBackoffSeconds: 200
 EOF
     ${CONTROLPLANE_SUDO} "${GO_OUT}/kube-scheduler" \
       --v="${LOG_LEVEL}" \

@ahg-g
Copy link
Copy Markdown
Member

ahg-g commented Nov 8, 2022

looks good to me, pls squash

- test generic integration in plugins_test.go
- test integration with SchedulingGates plugin in queue_test.go
@Huang-Wei
Copy link
Copy Markdown
Member Author

Huang-Wei commented Nov 8, 2022

Oh I need one test owner to approve the test/* changes. @dims do you have some cycles to review and approve this? (Dims is out today)

@ahg-g
Copy link
Copy Markdown
Member

ahg-g commented Nov 8, 2022

/lgtm
/approve

for the scheduler

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 8, 2022
@Huang-Wei
Copy link
Copy Markdown
Member Author

/retest

},
{
name: "pod is not admitted to enqueue",
pod: st.MakePod().Name("p").Namespace(testCtx.NS.Name).SchedulingGates([]string{"foo"}).Container("pause").Obj(),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is it a problem that both testcases use a pod with the same name?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

it's fine as in an integration test, each sub-test's context/env is destroyed, and is supposed to run statelessly.

testutils.CleanupPods(testCtx.ClientSet, t, []*v1.Pod{pod})

for _, idx := range tt.rmPodsSchedulingGates {
patch := `{"spec": {"schedulingGates": null}}`
podName := tt.pods[idx].Name
if _, err := cs.CoreV1().Pods(ns).Patch(ctx, podName, types.StrategicMergePatchType, []byte(patch), metav1.PatchOptions{}); err != nil {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

not an expert on these things, but I can see that the strategy is `merge``

// +patchStrategy=merge
// +listType=map
// +listMapKey=name
SchedulingGates []PodSchedulingGate `json:"schedulingGates,omitempty" patchStrategy:"merge" patchMergeKey:"name" protobuf:"bytes,38,opt,name=schedulingGates"`

is this patch removing the gates?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes, it's removing all scheduling gates.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yeah, for strategic merge patch;

  • foo: null deletes the whole field
  • foo: [{"name":"bar"}] adds or overwrites the existing entry with name=bar
  • foo: [{"$patch":"delete", "name":"bar"}] deletes the existing entry with name=bar

Comment thread test/e2e/framework/pod/wait.go Outdated
Copy link
Copy Markdown
Member

@aojea aojea Nov 8, 2022

Choose a reason for hiding this comment

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

the functions says evaluate if a certain amount of pods in given ns are running., but this doesn't checked yet that there are numpods running.
Maybe you can exit fast if len(pods) < num after the Pods().List, this guarantee that nonMatchingPods == 0 => runningPods == num

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

oh, thanks for the catch. I should have rewritten it to the style in WaitForPodsSchedulingGated() but somehow missed it. Let me update.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

updated.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 8, 2022
@fedebongio
Copy link
Copy Markdown
Contributor

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Nov 8, 2022
@Huang-Wei
Copy link
Copy Markdown
Member Author

/retest

@aojea
Copy link
Copy Markdown
Member

aojea commented Nov 8, 2022

+1 on the mechanics, I don't have enough knowledge to review the feature and its logic
Thanks for working on tests

@Huang-Wei
Copy link
Copy Markdown
Member Author

@aojea really appreciate your time! Logic-wise, @ahg-g has signed off reviewing, so it'd be good if you can /approve the test changes, then we're in good shape to 🚢.

@aojea
Copy link
Copy Markdown
Member

aojea commented Nov 8, 2022

/approve

for tests

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahg-g, aojea, Huang-Wei, logicalhan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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 Nov 8, 2022
@aojea
Copy link
Copy Markdown
Member

aojea commented Nov 8, 2022

/lgtm /approve

for the scheduler

carrying over the lgtm since the diff was only about the comments on the tests and is close to code freeze

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 8, 2022
@k8s-ci-robot k8s-ci-robot merged commit d619f60 into kubernetes:master Nov 8, 2022
@Huang-Wei Huang-Wei deleted the kep-3521-C branch November 8, 2022 23:14
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/code-generation area/e2e-test-framework Issues or PRs related to refactoring the kubernetes e2e test framework area/stable-metrics Issues or PRs involving stable metrics area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API 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. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. 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. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants