Skip to content

make virtual machine reconcile async#1697

Merged
k8s-ci-robot merged 2 commits into
kubernetes-sigs:mainfrom
CecileRobertMichon:async-vms
Nov 4, 2021
Merged

make virtual machine reconcile async#1697
k8s-ci-robot merged 2 commits into
kubernetes-sigs:mainfrom
CecileRobertMichon:async-vms

Conversation

@CecileRobertMichon
Copy link
Copy Markdown
Contributor

@CecileRobertMichon CecileRobertMichon commented Sep 17, 2021

What type of PR is this?
/kind feature

What this PR does / why we need it: implements #1541 for virtual machines.

  • Modify CreateResource to return the resulting resource so we can store info like providerID and the IP address of the node (before we were doing this with getExisting on the next reconcile loop)
  • Change the VM create and delete to be async using async helpers, adapt the client to implement the async interfaces
  • Moves a bunch of code from virtualmachines.go into spec.go and splits it into smaller functions
  • Added unit tests and restructured existing tests to test smaller chunks

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:

Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

TODOs:

  • squashed commits
  • includes documentation
  • adds unit tests

Release note:

make virtual machine reconcile async

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/feature Categorizes issue or PR as related to a new feature. labels Sep 17, 2021
@k8s-ci-robot k8s-ci-robot added the sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. label Sep 17, 2021
@CecileRobertMichon
Copy link
Copy Markdown
Contributor Author

Tests, lint are still todo.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 17, 2021
@shysank shysank mentioned this pull request Sep 20, 2021
23 tasks
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 22, 2021
@CecileRobertMichon CecileRobertMichon force-pushed the async-vms branch 3 times, most recently from ba7876c to 49a86d5 Compare September 27, 2021 22:58
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 27, 2021
@CecileRobertMichon CecileRobertMichon force-pushed the async-vms branch 2 times, most recently from d8ed261 to 3ce3007 Compare September 27, 2021 23:03
@CecileRobertMichon CecileRobertMichon changed the title [WIP] make virtual machine reconcile async make virtual machine reconcile async Sep 27, 2021
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 27, 2021
@CecileRobertMichon
Copy link
Copy Markdown
Contributor Author

Removing [WIP] as this is ready for review but going to add a hold so it doesn't merge until after the release since it's a massive change

/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 Sep 27, 2021
@CecileRobertMichon
Copy link
Copy Markdown
Contributor Author

I know this seems like a lot of changes but... here are the main things going on:

  • Modify CreateResource to return the resulting resource so we can store info like providerID and the IP address of the node (before we were doing this with getExisting on the next reconcile loop)
  • Change the VM create and delete to be async using async helpers, adapt the client to implement the async interfaces
  • Moves a bunch of code from virtualmachines.go into spec.go and splits it into smaller functions
  • Added unit tests and restructured existing tests to test smaller chunks

And FWIW, this PR overall removes code while maintaining test coverage:

Screen Shot 2021-09-27 at 4 28 28 PM

before: https://prow.k8s.io/view/gs/kubernetes-jenkins/logs/periodic-cluster-api-provider-azure-coverage/1442449517906497536
after: https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cluster-api-provider-azure/1697/pull-cluster-api-provider-azure-coverage/1442626055931170816


osProfile, err := s.generateOSProfile(ctx, vmSpec)
// Discover addresses for NICs associated with the VM
addresses, err := s.getAddresses(ctx, vm, vmSpec.ResourceGroupName())
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

future work I'm considering: figure out how to do this without needing to get the NICs and IPs again (we created them earlier), but this would be another refactor so holding off for now since this PR already does a lot. Kept that function as-is.

@CecileRobertMichon
Copy link
Copy Markdown
Contributor Author

/retest

@CecileRobertMichon
Copy link
Copy Markdown
Contributor Author

/assign @shysank @devigned

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 2, 2021
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 11, 2021
@CecileRobertMichon
Copy link
Copy Markdown
Contributor Author

/cc @devigned @shysank @karuppiah7890 @mboersma

@k8s-ci-robot k8s-ci-robot requested a review from devigned October 18, 2021 22:58
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

@CecileRobertMichon: GitHub didn't allow me to request PR reviews from the following users: karuppiah7890.

Note that only kubernetes-sigs members and repo collaborators can review this PR, and authors cannot review their own PRs.

Details

In response to this:

/cc @devigned @shysank @karuppiah7890 @mboersma

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 requested a review from mboersma October 18, 2021 22:58
Copy link
Copy Markdown
Contributor

@devigned devigned 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 lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Oct 21, 2021
@k8s-ci-robot k8s-ci-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Nov 2, 2021
@CecileRobertMichon
Copy link
Copy Markdown
Contributor Author

rebased + squashed

this is ready to go @devigned @shysank

return err
return nil, nil, errors.Wrapf(err, "failed to get desired parameters for virtual machine %s", spec.ResourceName())
} else if vm == nil {
// nothing to do here.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

self-review: maybe this should return the result as the existing vm instead of returning nil so we can act upon the existing VM even if it already exists

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could be added in the future if needed.

Copy link
Copy Markdown
Contributor

@devigned devigned 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 Nov 3, 2021
Copy link
Copy Markdown
Contributor

@shysank shysank left a comment

Choose a reason for hiding this comment

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

/lgtm overall with one small clarification

Comment thread azure/scope/machine.go
@nader-ziada
Copy link
Copy Markdown
Contributor

went through it again now and lgtm

@nader-ziada
Copy link
Copy Markdown
Contributor

/approve

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nader-ziada

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 3, 2021
@shysank
Copy link
Copy Markdown
Contributor

shysank commented Nov 3, 2021

/test pull-cluster-api-provider-azure-e2e

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

k8s-ci-robot commented Nov 4, 2021

@CecileRobertMichon: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-cluster-api-provider-azure-apidiff 930c3ca link false /test pull-cluster-api-provider-azure-apidiff

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Details

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. I understand the commands that are listed here.

@nader-ziada
Copy link
Copy Markdown
Contributor

/test pull-cluster-api-provider-azure-e2e

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/provider/azure Issues or PRs related to azure provider 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 Denotes a PR that will be considered when it comes time to generate release notes. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants