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

Include "computed QoS" instead of "status QoS" in validation error when in-place resource updates result in recalculated QoS #124713

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jkyros
Copy link

@jkyros jkyros commented May 6, 2024

What type of PR is this?

/kind bug

What this PR does / why we need it:

Currently:

  • In-place resource updates can result in Pod QoS changing due to recalculation, which causes the update to fail validation
  • That validation failure error currently includes the existing QoS value from the Pod's status, rather than the new computed QoS

This PR:

  • changes the error message to output the computed QoS, so the user can know what the QoS value was recalculated to and hopefully correlate it to their attempted resource changes

Example:

Take this pod:

apiVersion: v1
kind: Pod
metadata:
  name: sleeper
  namespace: default
spec:
  containers:
  - args:
    - -c
    - sleep infinity
    command:
    - /bin/sh
    image: registry.k8s.io/ubuntu-slim:0.1
    imagePullPolicy: IfNotPresent
    name: sleeper
    resources:
      requests:
        cpu: 25m
        memory: 100Mi

Remove the resources to make it recalculate to BestEffort:

$ kubectl patch pod sleeper --type="strategic" -p'{"spec":{"containers":[{"name":"sleeper","resources":{"$patch":"delete"}}]}}'

Observe the validation output (the pod is already Burstable, but the error says Burstable is the invalid value):

The Pod "sleeper" is invalid: 
* metadata: Invalid value: "Burstable": Pod QoS is immutable
* spec: Forbidden: pod updates may not change fields other than `spec.containers[*].image`,`spec.initContainers[*].image`,`spec.activeDeadlineSeconds`,`spec.tolerations` (only additions to existing tolerations),`spec.terminationGracePeriodSeconds` (allow it to be set to 1 if it was previously negative)

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?

In-place resource updates that recalculate pod QoS now properly include the recalculated QoS value with the validation failure

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


Pod QoS is immutable, but it is a computed field, so in-place resource
changes can result in updates being rejected because they would change
the QoS class -- e.g. removing all resources from a Burstable pod would
re-compute its QoS class as BestEffort, so it's not allowed.

When we return an error for a re-computed QoS, we erroneously log the
existing/status QoS class rather than the new computed one, which makes
it very confusing, e.g. a Burstable pod getting re-calculated as
BestEffort would log that Qos could not be changed to Burstable because
it was immutable.

This commit just changes the output such that it properly logs the
computed QoS that couldn't be applied, which should make it easier for
the user to understand why their resource changes are impossible.

Signed-off-by: John Kyros <jkyros@redhat.com>
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels May 6, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @jkyros!

It looks like this is your first PR to kubernetes/kubernetes 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kubernetes has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@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 May 6, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @jkyros. 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-sigs/prow repository.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: jkyros
Once this PR has been reviewed and has the lgtm label, please assign thockin for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@jkyros
Copy link
Author

jkyros commented May 6, 2024

/sig node

@k8s-ci-robot k8s-ci-robot added the sig/node Categorizes an issue or PR as relevant to SIG Node. label May 6, 2024
@k8s-ci-robot k8s-ci-robot added sig/apps Categorizes an issue or PR as relevant to SIG Apps. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels May 6, 2024
@bart0sh bart0sh added this to Triage in SIG Node PR Triage May 7, 2024
@bart0sh
Copy link
Contributor

bart0sh commented May 8, 2024

/triage accepted
/priority important-longterm
/ok-to-test
/cc

@k8s-ci-robot k8s-ci-robot requested a review from bart0sh May 8, 2024 10:37
@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. triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels May 8, 2024
@bart0sh bart0sh moved this from Triage to Needs Reviewer in SIG Node PR Triage May 8, 2024
@bart0sh
Copy link
Contributor

bart0sh commented May 8, 2024

/retest

Comment on lines +5139 to +5141
computedNewQOS := qos.ComputePodQOS(newPod)
if qos.GetPodQOS(oldPod) != computedNewQOS {
allErrs = append(allErrs, field.Invalid(fldPath, computedNewQOS, "Pod QoS is immutable"))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit

Suggested change
computedNewQOS := qos.ComputePodQOS(newPod)
if qos.GetPodQOS(oldPod) != computedNewQOS {
allErrs = append(allErrs, field.Invalid(fldPath, computedNewQOS, "Pod QoS is immutable"))
if computedNewQOS := qos.ComputePodQOS(newPod); qos.GetPodQOS(oldPod) != computedNewQOS {
allErrs = append(allErrs, field.Invalid(fldPath, computedNewQOS, "Pod QoS is immutable"))

Comment on lines +5139 to +5141
computedNewQOS := qos.ComputePodQOS(newPod)
if qos.GetPodQOS(oldPod) != computedNewQOS {
allErrs = append(allErrs, field.Invalid(fldPath, computedNewQOS, "Pod QoS is immutable"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible/easy to understand if there's an in-place scaling taking place? If it is, the problem can be made much clearer if we mention this was caused due to a resize IMO. WDYT?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I think the only time this message can come out is when there is an in-place scaling taking place because:

  • the function we're in ( ValidatePodUpdate) seems to only validate the spec, while the QoS is in the status
  • we're comparing "old" QoS to "computed new" QoS, so "new" QoS is ignored

So I think at least here it's just kind of quietly ignoring the case where you directly change the QoS.

So hmm, keeping with the tone of the other validation errors, maybe something like pod resource changes may not change pod QoS, pod QoS is immutable ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. 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/node Categorizes an issue or PR as relevant to SIG Node. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Status: Needs Triage
Status: Needs Reviewer
SIG Node PR Triage
Needs Reviewer
Development

Successfully merging this pull request may close these issues.

None yet

4 participants