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

fix: asgNeedsUpdates invalid condition (pointers) #3264

Merged
merged 1 commit into from Mar 17, 2022

Conversation

mweibel
Copy link
Contributor

@mweibel mweibel commented Mar 1, 2022

What type of PR is this?
/kind bug

What this PR does / why we need it:
machinePoolScope.MachinePool.Spec.Replicas and existingASG.DesiredCapacity are both pointers.
The previous condition compared memory addresses instead of integer values.

Special notes for your reviewer:
I'm not sure if the check for existingASG.DesiredCapacity == nil is needed (i.e. can it happen at all?) but I played a bit on the safe side here. The check could still fail overall if machinePoolScope.MachinePool.Spec.Replicas is nil, but I guess that should never happen. Or does it?

Checklist:

  • squashed commits
  • includes documentation
  • adds unit tests
  • adds or updates e2e tests

Release note:

fixes logic for determining if an AutoScalingGroup needs updates

@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. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Mar 1, 2022
@k8s-ci-robot
Copy link
Contributor

@mweibel: This issue is currently awaiting triage.

If CAPA/CAPI contributors 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 the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 1, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @mweibel. Thanks for your PR.

I'm waiting for a kubernetes-sigs 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 size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 1, 2022
@k8s-ci-robot k8s-ci-robot requested a review from pydctw March 1, 2022 15:59
@pydctw
Copy link
Contributor

pydctw commented Mar 1, 2022

/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 Mar 1, 2022
@pydctw
Copy link
Contributor

pydctw commented Mar 1, 2022

I'm not sure if the check for existingASG.DesiredCapacity == nil is needed (i.e. can it happen at all?) but I played a bit on the safe side here. The check could still fail overall if machinePoolScope.MachinePool.Spec.Replicas is nil, but I guess that should never happen. Or does it?

As existingASG.DesiredCapacity is a pointer, it can be nil. Same for MachinePool replicas spec. When a field is defined as a pointer, it is usually to distinguish between explicit zero and not specified.

Whether that is a real use case is a different story but we will need to check those conditions.

@pydctw
Copy link
Contributor

pydctw commented Mar 1, 2022

FYI, MachinePool spec replicas is defaulted to 1 if nil.
https://github.com/kubernetes-sigs/cluster-api/blob/main/exp/api/v1beta1/machinepool_webhook.go#L51-L53

`machinePoolScope.MachinePool.Spec.Replicas` and `existingASG.DesiredCapacity` are both pointers.
The previous condition compared memory addresses instead of integer
values.
@mweibel
Copy link
Contributor Author

mweibel commented Mar 2, 2022

As existingASG.DesiredCapacity is a pointer, it can be nil. Same for MachinePool replicas spec. When a field is defined as a pointer, it is usually to distinguish between explicit zero and not specified.

Whether that is a real use case is a different story but we will need to check those conditions.

Makes sense.

I added another condition to ensure it does return true when Replicas is nil, even though the Webhook should take care of this part. Hope that's fine, otherwise please let me know :)

@mweibel
Copy link
Contributor Author

mweibel commented Mar 2, 2022

restarting the timed out test (not sure if I can do that)

/test pull-cluster-api-provider-aws-verify

@shivi28
Copy link
Contributor

shivi28 commented Mar 2, 2022

/test pull-cluster-api-provider-aws-test

@pydctw
Copy link
Contributor

pydctw commented Mar 2, 2022

Thanks for adding missing tests in addition to what you are fixing in the PR.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 2, 2022
@mweibel
Copy link
Contributor Author

mweibel commented Mar 4, 2022

/assign @enxebre

@Ankitasw
Copy link
Member

Ankitasw commented Mar 7, 2022

/unassign @enxebre
/assign @richardcase
for approval

@k8s-ci-robot k8s-ci-robot assigned richardcase and unassigned enxebre Mar 7, 2022
@richardcase
Copy link
Member

/test ?

@k8s-ci-robot
Copy link
Contributor

@richardcase: The following commands are available to trigger required jobs:

  • /test pull-cluster-api-provider-aws-build
  • /test pull-cluster-api-provider-aws-test
  • /test pull-cluster-api-provider-aws-verify

The following commands are available to trigger optional jobs:

  • /test pull-cluster-api-provider-aws-apidiff-main
  • /test pull-cluster-api-provider-aws-e2e
  • /test pull-cluster-api-provider-aws-e2e-blocking
  • /test pull-cluster-api-provider-aws-e2e-conformance
  • /test pull-cluster-api-provider-aws-e2e-conformance-with-ci-artifacts
  • /test pull-cluster-api-provider-aws-e2e-eks

Use /test all to run the following jobs that were automatically triggered:

  • pull-cluster-api-provider-aws-apidiff-main
  • pull-cluster-api-provider-aws-build
  • pull-cluster-api-provider-aws-test
  • pull-cluster-api-provider-aws-verify

In response to this:

/test ?

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.

@richardcase
Copy link
Member

/test pull-cluster-api-provider-aws-e2e-eks
/test pull-cluster-api-provider-aws-e2e

@mweibel
Copy link
Contributor Author

mweibel commented Mar 17, 2022

tests ran through 👍 thanks for retesting.

@richardcase
Copy link
Member

Both sets of e2e are passing so:

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: richardcase

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 Mar 17, 2022
@k8s-ci-robot k8s-ci-robot merged commit 25db80a into kubernetes-sigs:main Mar 17, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.x milestone Mar 17, 2022
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority 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. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants