-
Notifications
You must be signed in to change notification settings - Fork 402
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
[Feature][kubectl-plugin]'ray log command' Add check and cleanup directory when no ray node exist #2473
[Feature][kubectl-plugin]'ray log command' Add check and cleanup directory when no ray node exist #2473
Conversation
kubectl-plugin/pkg/cmd/log/log.go
Outdated
options.outputDir = options.ResourceName | ||
err := os.MkdirAll(options.outputDir, 0o755) | ||
if err != nil { | ||
return fmt.Errorf("could not create directory with cluster name %s: %w", options.outputDir, err) | ||
} | ||
genereatedDirectory = true |
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 tracking a global env var here, can you check options.outputDir == ""
in Run()?
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 options.outputDir
is filled in Validations if the user does not input a outputDir. It then becomes difficult to know if we were the one that generated the dir or its user input.
if len(rayNodes.Items) == 0 { | ||
// Clean up the empty directory if the directory was generated. Since it will always be in current dir, only Remove() is used. | ||
if genereatedDirectory { | ||
os.Remove(options.outputDir) |
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.
Alternatively, could we consider a preflight check that at least 1 node exists before we create the directory?
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.
I've also considered that option, but I thought this option was less complex then doing a preflight check in Validations(). Please let me know if you think its a better choice to do a preflight check before we generate the file.
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, just left a minor nit
38627e2
to
b3a8f8a
Compare
…ctory when no ray node exist
b3a8f8a
to
f0d34fa
Compare
Why are these changes needed?
Currently, if there is no nodes found when using
kubectl ray log
, the command ends silently. If noout-dir
was specified and directory is generated, it just leaves an empty dir. This PR adds a check and return error if no ray node was found as well as clean up the empty directory if directory was generated.Before change:
After change:
Related issue number
Checks