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

Improve "flux resume" error message on non-existent object #5146

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cmd/flux/resume.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (resume resumeCommand) run(cmd *cobra.Command, args []string) error {
// If the args slice is empty, it patches all resumable objects in the given namespace.
func (resume *resumeCommand) getPatchedResumables(ctx context.Context, args []string) ([]resumable, error) {
if len(args) < 1 {
objs, err := resume.patch(ctx, []client.ListOption{
objs, err := resume.patch(ctx, args, []client.ListOption{
client.InNamespace(resume.namespace),
})
if err != nil {
Expand All @@ -151,7 +151,7 @@ func (resume *resumeCommand) getPatchedResumables(ctx context.Context, args []st
}
processed[arg] = struct{}{}

objs, err := resume.patch(ctx, []client.ListOption{
objs, err := resume.patch(ctx, args, []client.ListOption{
client.InNamespace(resume.namespace),
client.MatchingFields{
"metadata.name": arg,
Expand All @@ -169,13 +169,13 @@ func (resume *resumeCommand) getPatchedResumables(ctx context.Context, args []st

// Patches resumable objects by setting their status to unsuspended.
// Returns a slice of resumables that have been patched and any error encountered during patching.
func (resume resumeCommand) patch(ctx context.Context, listOpts []client.ListOption) ([]resumable, error) {
func (resume resumeCommand) patch(ctx context.Context, args []string, listOpts []client.ListOption) ([]resumable, error) {
if err := resume.client.List(ctx, resume.list.asClientList(), listOpts...); err != nil {
return nil, err
}

if resume.list.len() == 0 {
logger.Failuref("no %s objects found in %s namespace", resume.kind, resume.namespace)
logger.Failuref("%s object '%s' not found in %s namespace", resume.kind, args[0], resume.namespace)
sjorsholtrop-ritense marked this conversation as resolved.
Show resolved Hide resolved
return nil, nil
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
► resuming kustomization tkfg in {{ .ns }} namespace
✔ kustomization resumed
no Kustomization objects found in {{ .ns }} namespace
✗ Kustomization object 'tkfg' not found in {{ .ns }} namespace
◎ waiting for Kustomization reconciliation
✔ Kustomization tkfg reconciliation completed
✔ applied revision 6.3.5@sha1:67e2c98a60dc92283531412a9e604dd4bae005a9