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

Added a function to determine if the attachedcluster was created in the cluster #598

Merged

Conversation

LiZhenCheng9527
Copy link
Contributor

What this PR does / why we need it:
Added a function to determine if the attachedcluster was created in the cluster. Replaces the unstable checking of clusters at fixed intervals.
Which issue(s) this PR fixes:
a part of #436

Copy link

netlify bot commented Feb 4, 2024

Deploy Preview for kurator-dev canceled.

Name Link
🔨 Latest commit 88c444d
🔍 Latest deploy log https://app.netlify.com/sites/kurator-dev/deploys/65bf766d2ca0350008572ff0


const (
// pollInterval defines the interval time for a poll operation.
pollInterval = 5 * time.Second
Copy link
Member

Choose a reason for hiding this comment

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

isn't it too long?

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 shortened the pollInterval between poll operation.

// pollInterval defines the interval time for a poll operation.
pollInterval = 5 * time.Second
// pollTimeout defines the time after which the poll operation times out.
pollTimeout = 420 * time.Second
Copy link
Member

Choose a reason for hiding this comment

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

How is this set

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 sets the timeout for getting the attachecluster resource.
You can set it up here:

func WaitAttachedClusterFitWith(client kurator.Interface, namespace, name string, fit func(attachedCluster *clusterv1a1.AttachedCluster) bool) {
	gomega.Eventually(func() bool {
		attachedClusterPresentOnCluster, err := client.ClusterV1alpha1().AttachedClusters(namespace).Get(context.TODO(), name, metav1.GetOptions{})
		if err != nil {
			return false
		}
		return fit(attachedClusterPresentOnCluster)
	}, pollTimeout, pollInterval).Should(gomega.Equal(true))
}

It will get the attachedcluster every time poolInterval until it succeeds or time over pollTimeout.

Signed-off-by: LiZhenCheng9527 <[email protected]>
Copy link
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

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

/lgtm

@kurator-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hzxuzhonghu

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

@kurator-bot kurator-bot merged commit fbb0ef7 into kurator-dev:main Feb 4, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants