-
Notifications
You must be signed in to change notification settings - Fork 152
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
Enable wait for RepositoryServer CR to get ready functionality for actionsets #2228
Conversation
Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com>
Thanks for submitting this pull request 🎉. The team will review it soon and get back to you. If you haven't already, please take a moment to review our project contributing guideline and Code of Conduct document. |
pkg/kanctl/actionset.go
Outdated
@@ -105,6 +107,7 @@ func newActionSetCmd() *cobra.Command { | |||
cmd.Flags().String(selectorNamespaceFlag, "", "namespace to apply selector on. Used along with the selector specified using --selector/-l") | |||
cmd.Flags().StringSliceP(namespaceTargetsFlagName, "T", []string{}, "namespaces for the action set, comma separated list of namespaces (eg: --namespacetargets namespace1,namespace2)") | |||
cmd.Flags().StringSliceP(objectsFlagName, "O", []string{}, "objects for the action set, comma separated list of object references (eg: --objects group/version/resource/namespace1/name1,group/version/resource/namespace2/name2)") | |||
cmd.Flags().BoolP(waitForReadyFlagName, "w", false, "wait for resources to get in ready state") |
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.
The wait
flag seems a bit ambiguous. Is it for waiting for actionset to complete, or repo server to be ready or resources to be ready? We can have something --wait-for-reposerver
?
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.
Done !
pkg/kanctl/actionset.go
Outdated
@@ -121,7 +124,7 @@ func initializeAndPerform(cmd *cobra.Command, args []string) error { | |||
ctx := context.Background() | |||
valFlag, _ := cmd.Flags().GetBool(skipValidationFlag) | |||
if !valFlag { | |||
err = verifyParams(ctx, params, cli, crCli, osCli) | |||
err = verifyParams(cmd, ctx, params, cli, crCli, osCli) |
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.
instead of passing whole cmd
object just to get value to wait
flag can we parse it here and just pass the boolean parameter?
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.
Done !
pkg/kanctl/actionset.go
Outdated
if wait { | ||
err = waitForKopiaRepositoryServerReady(ctx, crCli, rs) | ||
if err != nil { | ||
return err | ||
} | ||
} else { | ||
if rs.Status.Progress != crv1alpha1.Ready { | ||
err = errors.New("Repository Server Not Ready") | ||
return errors.Wrapf(err, "Please make sure that Repository Server CR '%s' is in Ready State", repoServer.Name) | ||
} | ||
} |
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.
if wait { | |
err = waitForKopiaRepositoryServerReady(ctx, crCli, rs) | |
if err != nil { | |
return err | |
} | |
} else { | |
if rs.Status.Progress != crv1alpha1.Ready { | |
err = errors.New("Repository Server Not Ready") | |
return errors.Wrapf(err, "Please make sure that Repository Server CR '%s' is in Ready State", repoServer.Name) | |
} | |
} | |
if wait { | |
return waitForKopiaRepositoryServerReady(ctx, crCli, rs) | |
} | |
if rs.Status.Progress != crv1alpha1.Ready { | |
err = errors.New("Repository Server Not Ready") | |
return errors.Wrapf(err, "Please make sure that Repository Server CR '%s' is in Ready State", repoServer.Name) | |
} |
We can get rid of else
block
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.
Done !
pkg/kanctl/actionset.go
Outdated
if repositoryServer.Status.Progress == crv1alpha1.Ready && err == nil { | ||
return true, nil | ||
} | ||
return false, 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.
if repositoryServer.Status.Progress == crv1alpha1.Ready && err == nil { | |
return true, nil | |
} | |
return false, err | |
return repositoryServer.Status.Progress == crv1alpha1.Ready, 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.
Done !
Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com>
Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com>
timeoutCtx, waitCancel := context.WithTimeout(ctx, contextWaitTimeout) | ||
defer waitCancel() | ||
pollErr := poll.Wait(timeoutCtx, func(ctx context.Context) (bool, error) { | ||
repositoryServer, err := crCli.CrV1alpha1().RepositoryServers(rs.GetNamespace()).Get(ctx, rs.GetName(), metav1.GetOptions{}) |
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 should continue checking if the supplied repo server doesn't exist right? Something like
if apierrors.IsNotFound(errors.Cause(err)) {
return false, 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.
@pavannd1 we're calling this function i.e waitForKopiaRepositoryServerReady
in verifyRepositoryServerParams
function and there we're checking if the Repository Server is present or not.
So before polling, we're making sure that RepositoryServer CR exists
pkg/kanctl/actionset.go
Outdated
@@ -755,7 +759,7 @@ func generateActionSetName(p *PerformParams) (string, error) { | |||
return "", errMissingFieldActionName | |||
} | |||
|
|||
func verifyRepositoryServerParams(repoServer *crv1alpha1.ObjectReference, crCli versioned.Interface, ctx context.Context) error { | |||
func verifyRepositoryServerParams(waitForRepoServerReady bool, repoServer *crv1alpha1.ObjectReference, crCli versioned.Interface, ctx context.Context) error { |
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.
Not in this PR but we should change the order of arguments here. The convention is
context, clis..., other args...
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.
Done !
Co-authored-by: Pavan Navarathna <6504783+pavannd1@users.noreply.github.com>
Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com>
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.
LGTM
Change Overview
Enable wait for resources to get ready functionality for actionsets
Add
--wait-for-repository-server
flag while Actionset creation, if provided waits forRepositoryServer
to get inReady
state before creating ActionsetsPull request type
Please check the type of change your PR introduces:
Issues
Test Plan
Manual Testing Steps
1) Build
kando
command line tool2) Create Actionset