-
Notifications
You must be signed in to change notification settings - Fork 248
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
cluster claim: use watch API #1874
cluster claim: use watch API #1874
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hongkailiu 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 |
/hold cancel |
Part of DPTP-2099 |
pkg/steps/artifacts_test.go
Outdated
return true, nil | ||
}, | ||
); err != nil { | ||
t.Errorf("unexpected error occurred in objectFunc: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't call this from a goroutine - not only will it not kill the test, but if you end up calling this after the test is done, it will panic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pkg/steps/artifacts_test.go
Outdated
func() (bool, error) { | ||
ctx := context.TODO() | ||
pod := &coreapi.Pod{} | ||
if err := client.Get(ctx, ctrlruntimeclient.ObjectKey{Name: podName, Namespace: ns}, pod); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What creates this Pod?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pkg/steps/cluster_claim.go
Outdated
claimNamespace := clusterPool.Namespace | ||
claim := &hivev1.ClusterClaim{ | ||
ret := &hivev1.ClusterClaim{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ret
is a bad name as it's not descriptive. Why not claim
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We keep the created one to return because it will be deleted no matter what happens in the acquire function.
Renamed the var into
which is passed to the acquire function
pkg/steps/cluster_claim.go
Outdated
} | ||
ret = claim | ||
logrus.Info("The claimed cluster is ready.") | ||
clusterDeploymentName := claim.Spec.Namespace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the utility in this local variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For improve the readability of the code.
Removed.
pkg/steps/cluster_claim.go
Outdated
logrus.WithField("clusterClaim.Namespace", clusterClaim.Namespace).WithField("clusterClaim.Name", clusterClaim.Name).Debug("Deleting cluster claim.") | ||
if err := hiveClient.Delete(ctx, clusterClaim); err != nil { | ||
if err := s.hiveClient.Delete(ctx, clusterClaim); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likely worth it to retry a couple times on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add retry.
Why it could fail in the first place? Do we do the retry on other object deleting?
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hongkailiu, stevekuznetsov 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 |
/cc @stevekuznetsov