Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

CPIConfigController also Enqueue cluster event #3318

Merged
merged 1 commit into from
Sep 20, 2022

Conversation

lubronzhan
Copy link
Contributor

@lubronzhan lubronzhan commented Sep 12, 2022

What this PR does / why we need it

VSphereCPIConfigController also relies on underlying Cluster object. The controller should watch on Cluster's event as well
Otherwise, it will cause delay when creating the cluster.
Currently it will just silently exit and might cause 20 minutes delay when creating management cluster, if the VSphereCPIConfig is created before the Cluster object

Which issue(s) this PR fixes

Fixes ##3317

Describe testing done for PR

Enqueue corresponding VSphereCPIConfig when there is Cluster event.
Also error out when VSphereCPIConfig's owner Clusteris not found

Release note

VSphereCPIConfig Controller watch on Cluster event now

Additional information

Special notes for your reviewer

@lubronzhan lubronzhan force-pushed the enqueue_cluster_changes branch 2 times, most recently from 7d05c22 to 89ae2a4 Compare September 13, 2022 17:58
@lubronzhan lubronzhan requested review from a team as code owners September 13, 2022 17:58
@github-actions
Copy link

Cluster Generation A/B Results:
https://storage.googleapis.com/tkg-clustergen/3318/20220913181033/clustergen.diff.txt
Author/reviewers:
Please review to verify that the effects on the generated cluster configurations are exactly what the PR intended, and give a thumbs-up if so.

@github-actions
Copy link

Cluster Generation A/B Results:
https://storage.googleapis.com/tkg-clustergen/3318/20220913202520/clustergen.diff.txt
Author/reviewers:
Please review to verify that the effects on the generated cluster configurations are exactly what the PR intended, and give a thumbs-up if so.

@lubronzhan lubronzhan force-pushed the enqueue_cluster_changes branch from 6f367f1 to e736d07 Compare September 13, 2022 21:00
@github-actions
Copy link

Cluster Generation A/B Results:
https://storage.googleapis.com/tkg-clustergen/3318/20220913211018/clustergen.diff.txt
Author/reviewers:
Please review to verify that the effects on the generated cluster configurations are exactly what the PR intended, and give a thumbs-up if so.

@github-actions
Copy link

Cluster Generation A/B Results:
https://storage.googleapis.com/tkg-clustergen/3318/20220913222114/clustergen.diff.txt
Author/reviewers:
Please review to verify that the effects on the generated cluster configurations are exactly what the PR intended, and give a thumbs-up if so.

@codecov
Copy link

codecov bot commented Sep 14, 2022

Codecov Report

Merging #3318 (a685a40) into main (c9c5555) will not change coverage.
The diff coverage is n/a.

❗ Current head a685a40 differs from pull request most recent head 975271d. Consider uploading reports for the commit 975271d to get more accurate results

@@           Coverage Diff           @@
##             main    #3318   +/-   ##
=======================================
  Coverage   46.63%   46.63%           
=======================================
  Files         281      281           
  Lines       29654    29654           
=======================================
  Hits        13828    13828           
  Misses      14569    14569           
  Partials     1257     1257           
Impacted Files Coverage Δ
addons/pkg/util/cluster_util.go 4.34% <0.00%> (ø)
addons/webhooks/cluster_pause_webhook.go 80.00% <0.00%> (ø)
addons/controllers/clusterbootstrap_controller.go 63.52% <0.00%> (ø)
...ons/controllers/packageinstallstatus_controller.go 79.15% <0.00%> (ø)
addons/pkg/webhooks/webhooks.go
addons/pkg/webhooks/certificates.go
pkg/v1/webhooks/certificates.go 15.95% <0.00%> (ø)
pkg/v1/webhooks/webhooks.go 0.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@DanielXiao
Copy link
Contributor

Not related to this PR, but I think we should only use 1 way either name or ownerreference to match its owner cluster. If 2 configs belong to the same cluster, how should we handle it?

@lubronzhan
Copy link
Contributor Author

Not related to this PR, but I think we should only use 1 way either name or ownerreference to match its owner cluster. If 2 configs belong to the same cluster, how should we handle it?

That's an issue with current design. I created a Jira for it

@lubronzhan lubronzhan force-pushed the enqueue_cluster_changes branch 2 times, most recently from f7e72b2 to 0b2ebb4 Compare September 15, 2022 17:56
@github-actions
Copy link

Cluster Generation A/B Results:
https://storage.googleapis.com/tkg-clustergen/3318/20220915180903/clustergen.diff.txt
Author/reviewers:
Please review to verify that the effects on the generated cluster configurations are exactly what the PR intended, and give a thumbs-up if so.

@github-actions
Copy link

Cluster Generation A/B Results:
https://storage.googleapis.com/tkg-clustergen/3318/20220915181039/clustergen.diff.txt
Author/reviewers:
Please review to verify that the effects on the generated cluster configurations are exactly what the PR intended, and give a thumbs-up if so.

@github-actions
Copy link

Cluster Generation A/B Results:
https://storage.googleapis.com/tkg-clustergen/3318/20220915181109/clustergen.diff.txt
Author/reviewers:
Please review to verify that the effects on the generated cluster configurations are exactly what the PR intended, and give a thumbs-up if so.

@lubronzhan lubronzhan force-pushed the enqueue_cluster_changes branch 2 times, most recently from 7deb5d9 to 3beb3f5 Compare September 16, 2022 00:11
@lubronzhan lubronzhan force-pushed the enqueue_cluster_changes branch 2 times, most recently from a765d3c to 50458d5 Compare September 19, 2022 01:00
Copy link
Contributor

@HanFa HanFa left a comment

Choose a reason for hiding this comment

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

lgtm

Error out when the owner cluster of a VSphereCPIConfig is not found

Fix logger

Resolve conmment

Enqueue VSphereCluster intead of Cluster

Fix readme for lint

Rmove log

Fix the cluster type

Skip cpiconfig if it's template

Add
@lubronzhan lubronzhan force-pushed the enqueue_cluster_changes branch from 50458d5 to 975271d Compare September 20, 2022 17:40
Copy link
Contributor

@haoranleo haoranleo left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for adding filters for template config in the event handler!

@lubronzhan
Copy link
Contributor Author

Thanks @HL-EverGreen could you take a look at this simialr PR as well? https://github.com/vmware-tanzu/tanzu-framework/pull/3377/files

@haoranleo haoranleo added the ok-to-merge PRs should be labelled with this before merging label Sep 20, 2022
@lubronzhan lubronzhan merged commit 331b259 into vmware-tanzu:main Sep 20, 2022
@lubronzhan lubronzhan deleted the enqueue_cluster_changes branch September 20, 2022 23:41
Name: cluster.Name,
UID: cluster.UID,
}
if clusterapiutil.HasOwnerRef(config.OwnerReferences, ownerReference) || config.Name == fmt.Sprintf("%s-%s-package", cluster.Name, constants.CPIAddonName) {
Copy link
Contributor

@12345lcr 12345lcr Sep 21, 2022

Choose a reason for hiding this comment

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

I am confused with fmt.Sprintf("%s-%s-package", cluster.Name, constants.CPIAddonName) as package name and cluster name as package name.

Here we are filtering the cpiConfig to enqueue those who has ownRef to an existing clusters, or who has the "clustername"-"package-prefix"-package name where the cluster is exist.

But in below we only reconcile those who has ownRef to an existing clusters, or who has the name of an existing cluster.

https://github.com/lubronzhan/tanzu-framework/blob/975271dee7d6ecb0c60fc271d1d29805ecf6f18c/addons/controllers/cpi/vspherecpiconfig_utils.go#L403-L427

Copy link
Contributor

@12345lcr 12345lcr Sep 21, 2022

Choose a reason for hiding this comment

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

And ALL the AddonConfig test cases are based on cluster name as cpiConfig name for controller testing. Like

https://github.com/lubronzhan/tanzu-framework/blob/975271dee7d6ecb0c60fc271d1d29805ecf6f18c/addons/controllers/testdata/test-vsphere-cpi-non-paravirtual.yaml

This means after this fix, the user customized AddonConfig which has name of the cluster name will never be enqueued base on the cluster event. But also this cluster name based reconcile seems useless now, since it will be copied to "cluster name"-"package prefix"-package for actual use.

The confusion between cluster name as AddonConfig name and "cluster name"-"package prefix"-package as AddonConfig name has bring a lot of unsync, I think we really should make this clear.

Per my understanding, the name format of "cluster name"-"package prefix"-package was never a part of the design doc, yet originally generated based on the copy of the ClusterBootstrapTemplate. All other customized cases are following the cluster name as AddonConfig name. Now this "cluster name"-"package prefix"-package naming conversion becomes primary, that the Bootstrap Controller will copy both the customized and the default provider configs as this pattern. I think maybe we should eliminate the concept of one of them totally.

cc @vijaykatam @DanielXiao @HanFa

Copy link
Contributor

@vijaykatam vijaykatam Sep 21, 2022

Choose a reason for hiding this comment

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

We are relying on "cluster name"-"package shortName"-package now. The original design was for "cluster name" but a refactor(I think cloning for webhook) changed it. I would like us to continue down this path of updated name because this has already shipped with vSphere 8.0 integration.

Edit: Docs were updated to reflect this.https://github.com/vmware-tanzu/tanzu-framework/tree/main/addons#pre-create-specific-config-cr

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
cla-not-required ok-to-merge PRs should be labelled with this before merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants