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

[release-1.11] ASO: Return readyErr over not done err when tags fail #4380

Merged

Conversation

nojnhuh
Copy link
Contributor

@nojnhuh nojnhuh commented Dec 13, 2023

What type of PR is this?
/kind bug

What this PR does / why we need it:

Manual cherry-pick of #4371:

When tags are reconciled for ASO resources, CAPZ waits for the spec and status of the ASO resource's tags to match (#4149). In cases where that convergence will never happen because there is a different issue preventing ASO from reconciling the resource reflected in its Ready condition, a not-very-helpful "not done" error is bubbled up into the CAPZ resource status because the spec and status of the ASO resource do not match.

This PR instead bubbles up the error matching what's in the ASO resource's Ready condition instead when reconciling tags fails because the spec and status do not match, since that is closer to the root of the problem.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Special notes for your reviewer:

  • cherry-pick candidate

TODOs:

  • squashed commits
  • includes documentation
  • adds unit tests

Release note:

Propagate error affecting ASO resources' `Ready` conditions when tags cannot yet be reconciled.

@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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Dec 13, 2023
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 13, 2023
@@ -155,6 +155,9 @@ func (s *Service) CreateOrUpdateResource(ctx context.Context, spec azure.ASOReso

if t, ok := spec.(TagsGetterSetter); ok {
if err := reconcileTags(t, existing, parameters); err != nil {
if azure.IsOperationNotDoneError(err) && readyErr != nil {
return nil, readyErr
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line was the cause for the merge conflict, so this changes zero to nil from the original PR to account for the generics changes that were introduced for 1.12.

@nojnhuh
Copy link
Contributor Author

nojnhuh commented Dec 13, 2023

/retitle [release-1.11] ASO: Return readyErr over not done err when tags fail

@k8s-ci-robot k8s-ci-robot changed the title ASO: Return readyErr over not done err when tags fail [release-1.11] ASO: Return readyErr over not done err when tags fail Dec 13, 2023
Copy link
Contributor

@CecileRobertMichon CecileRobertMichon left a comment

Choose a reason for hiding this comment

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

/lgtm

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

LGTM label has been added.

Git tree hash: 46da547f3847eed612ce6720c5d169354200f56d

Copy link
Contributor

@mboersma mboersma left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mboersma

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 Dec 13, 2023
@nojnhuh nojnhuh force-pushed the aso-tags-and-ready-error branch from d6ed634 to 7bf55a1 Compare December 13, 2023 20:28
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 13, 2023
@@ -65,6 +65,8 @@ func New(ctrlClient client.Client, clusterName string) *Service {

// CreateOrUpdateResource implements the logic for creating a new or updating an
// existing resource with ASO.
//
//nolint:gocyclo // This function is necessarily complex.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

:(

I've looked before for any low-hanging fruit to split any decent-sized chunk of this into its own function, but there's enough shared state generated within this function that I think any new helper function would end up taking a lot of random-looking parameters and return a lot of random-looking values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mboersma @CecileRobertMichon Had to drop the lgtm to add this change, PTAL.

Copy link

codecov bot commented Dec 13, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (b2d0b51) 56.70% compared to head (7bf55a1) 56.71%.
Report is 1 commits behind head on release-1.11.

Additional details and impacted files
@@               Coverage Diff                @@
##           release-1.11    #4380      +/-   ##
================================================
+ Coverage         56.70%   56.71%   +0.01%     
================================================
  Files               187      187              
  Lines             19222    19224       +2     
================================================
+ Hits              10899    10903       +4     
+ Misses             7693     7691       -2     
  Partials            630      630              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nawazkh
Copy link
Member

nawazkh commented Dec 13, 2023

/lgtm

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

LGTM label has been added.

Git tree hash: 3a62a63753a75ff5f40ae4324be336b2749832d0

@k8s-ci-robot k8s-ci-robot merged commit 6d656f9 into kubernetes-sigs:release-1.11 Dec 13, 2023
18 checks passed
@nojnhuh nojnhuh deleted the aso-tags-and-ready-error branch December 19, 2023 16:34
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. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants