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

add pause handling for AzureCluster controller #3735

Merged
merged 1 commit into from
Jul 27, 2023

Conversation

nojnhuh
Copy link
Contributor

@nojnhuh nojnhuh commented Jul 17, 2023

What type of PR is this?
/kind feature

What this PR does / why we need it:

This PR introduces the capability for CAPZ's Azure service interfaces (i.e. azure/services/*) to define logic to be run in reaction to a CAPZ resource being paused. The primary change is the introduction of a new reconcilePause at the same level of abstraction as reconcileNormal and reconcileDelete.

The currently-identified use case is to set the serviceoperator.azure.com/reconcile-policy annotation to skip on ASO resources to communicate CAPI's notion of "paused" to ASO's controllers.

This change modifies the AzureCluster controller, but all other controllers using the same azure.ServiceReconciler pattern will need to modified similarly, at least once they start using ASO.

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

Special notes for your reviewer:

This change only partially addresses #3525. Currently, reconcilePause will essentially no-op (aside from logging), so this PR is not expected to produce any meaningfully visible changes. Future PRs will implement the logic to add the annotation to ASO resources, handle the impending block-move CAPI annotation, and implement the same pattern for other CAPZ controllers.

  • cherry-pick candidate

TODOs:

  • squashed commits
  • includes documentation
  • adds unit tests

Release note:

NONE

@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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jul 17, 2023
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 17, 2023

// ClusterUpdatePauseChange returns a predicate that returns true for an update event when a cluster's
// Spec.Paused changes between any two distinct values.
func ClusterUpdatePauseChange(logger logr.Logger) predicate.Funcs {
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 is mostly copy-paste from CAPI's ClusterUpdateUnpaused.

ctx, _, done := tele.StartSpanWithLogger(ctx, "controllers.azureClusterService.Pause")
defer done()

for _, service := range s.services {
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 don't think the order in which services are paused is significant, at least for ASO.

@@ -51,3 +56,63 @@ var _ = Describe("AzureClusterReconciler", func() {
})
})
})

func TestAzureClusterReconcilePaused(t *testing.T) {
Copy link
Contributor Author

@nojnhuh nojnhuh Jul 18, 2023

Choose a reason for hiding this comment

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

I originally tried to specify this test like the one above with envtest, but the race detector was flagging something in the logging calls whenever two objects were being created, even serially and with a 10s sleep in between. It was easier to rework this test to use a fake client than try to fix the race which seemed unrelated to the rest of these changes. The test itself hasn't lost any fidelity during that rewrite AFAICT.

@nojnhuh
Copy link
Contributor Author

nojnhuh commented Jul 18, 2023

(squash reminder)

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 18, 2023
@codecov
Copy link

codecov bot commented Jul 18, 2023

Codecov Report

Patch coverage: 45.45% and project coverage change: +0.20% 🎉

Comparison is base (79de209) 54.05% compared to head (1c26aa9) 54.26%.

❗ Current head 1c26aa9 differs from pull request most recent head 8db012a. Consider uploading reports for the commit 8db012a to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3735      +/-   ##
==========================================
+ Coverage   54.05%   54.26%   +0.20%     
==========================================
  Files         186      186              
  Lines       18833    18898      +65     
==========================================
+ Hits        10181    10255      +74     
+ Misses       8105     8088      -17     
- Partials      547      555       +8     
Files Changed Coverage Δ
controllers/helpers.go 54.69% <8.69%> (-1.54%) ⬇️
controllers/azurecluster_controller.go 37.07% <51.61%> (+9.32%) ⬆️
controllers/azurecluster_reconciler.go 71.29% <100.00%> (+25.46%) ⬆️

... and 4 files with indirect coverage changes

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

Copy link
Contributor

@willie-yao willie-yao 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 Jul 20, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 7ed89233f583d5db13927c22afa78f31b057ff2f

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
/approve

squash and remove hold?

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CecileRobertMichon

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 Jul 25, 2023
@nojnhuh
Copy link
Contributor Author

nojnhuh commented Jul 25, 2023

squashed!
/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 25, 2023
@nojnhuh
Copy link
Contributor Author

nojnhuh commented Jul 25, 2023

/retest

3 similar comments
@nojnhuh
Copy link
Contributor Author

nojnhuh commented Jul 25, 2023

/retest

@CecileRobertMichon
Copy link
Contributor

/retest

@nojnhuh
Copy link
Contributor Author

nojnhuh commented Jul 27, 2023

/retest

@k8s-ci-robot k8s-ci-robot merged commit b07d34e into kubernetes-sigs:main Jul 27, 2023
21 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.11 milestone Jul 27, 2023
@nojnhuh nojnhuh deleted the aso-pause-azurecluster branch July 28, 2023 04:24
@nojnhuh nojnhuh mentioned this pull request May 3, 2024
4 tasks
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/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. release-note-none Denotes a PR that doesn't merit a release note. 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

4 participants