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

postpone connecting to remote cluster until when needed #2402

Merged

Conversation

maralavi
Copy link
Contributor

@maralavi maralavi commented May 18, 2022

What this PR does / why we need it

This is to postpone connecting to remote cluster until when needed

Which issue(s) this PR fixes

Fixes #2401

Describe testing done for PR

Existing unit/env tests

Release note

package-based-lcm: postpone connecting to remote cluster until when needed

PR Checklist

  • Squash the commits into one or a small number of logical commits
  • Use good commit messages
  • Ensure PR contains terms all contributors can understand and links all contributors can access

Additional information

Special notes for your reviewer

okToRemoveFinalizers := false
var err error

remoteClient, err := util.GetClusterClient(r.context, r.Client, r.Scheme, clusterapiutil.ObjectKey(cluster))
if err != nil {
log.Error(err, "Error getting remote cluster client")
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: Don't log errors unless you're adding extra debug info. Instead, wrap it and return it like:

return ctrl.Result{Requeue: true}, fmt.Errorf("failed to get remote cluster client: %w", err)

Copy link
Contributor Author

@maralavi maralavi May 18, 2022

Choose a reason for hiding this comment

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

Thanks for the comment. I addressed this one, but noticed there are about 50 other cases in this file to fix. I'll add an issue and do those after the testings as it is of less priority

@@ -213,6 +208,11 @@ func (r *ClusterBootstrapReconciler) reconcileNormal(cluster *clusterapiv1beta1.
return ctrl.Result{}, err
}

remoteClient, err := util.GetClusterClient(r.context, r.Client, r.Scheme, clusterapiutil.ObjectKey(cluster))
if err != nil {
return ctrl.Result{Requeue: true}, fmt.Errorf("failed to get remote cluster client: %w", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a delay with RequeueAfter: constants.RequeueAfterDuration. At this point the cluster is "ready" based on cluster api but the api-server may need a while to accept requests.

remoteClient, err := util.GetClusterClient(r.context, r.Client, r.Scheme, clusterapiutil.ObjectKey(cluster))
if err != nil {
log.Error(err, "Error getting remote cluster client")
return ctrl.Result{Requeue: true}, err
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment, add a delay.

@@ -0,0 +1,173 @@
Running Suite: Addon Controller Suite
Copy link
Contributor

Choose a reason for hiding this comment

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

Delete file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Omg, how this one has been committed! Definitely, thanks for actually noticing it

Copy link
Contributor

@vijaykatam vijaykatam left a comment

Choose a reason for hiding this comment

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

LGTM

@maralavi
Copy link
Contributor Author

@vijaykatam @rajathagasthya Could I please get a merge approval label for this PR? Thanks

@vijaykatam vijaykatam added the ok-to-merge PRs should be labelled with this before merging label May 18, 2022
@maralavi maralavi merged commit 8b7d792 into vmware-tanzu:main May 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla-not-required ok-to-merge PRs should be labelled with this before merging
Projects
None yet
4 participants