-
Notifications
You must be signed in to change notification settings - Fork 614
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
Implement flux debug kustomization
command
#5117
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
} | ||
testEnv.CreateObjectFile(objectFile, tmpl, t) | ||
|
||
cases := []struct { |
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.
Can we add 2 more tests: one for both flags set, and one for neither flags set?
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 failure in LoadVariables()
, maybe due to non-optional, non-existing substitute from object can also be a test case to make sure the command fails, instead of skipping such failures.
return err | ||
} | ||
|
||
if len(ks.Spec.PostBuild.Substitute) > 0 { |
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.
PostBuild
is a pointer and the absence of any post build configuration results in a panic here.
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.
Added a check at the top
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.
@darkowlzz great catch!
if err != nil { | ||
return err | ||
} | ||
rootCmd.Print(string(status)) |
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 scaled KC to 0 and created a Kustomization to see the result.
$ flux -n default debug kustomization podinfo --show-status
observedGeneration: -1
I know what it means, but it feels like being a debug command for troubleshooting, we should be able to do some simple analysis and provide some human readable result to help the user understand what's going on, especially in cases like this.
In the usual case, the presence of conditions may help provide some sense of what could be wrong. But in this case, there's no hint of what it means.
If we go ahead and start providing some summary of the result, I think that would increase the scope of what can be done and make it more useful, but complex. Depending on the state, instead of trying to analyze, we can also provide a link to status docs of the respective resource, which the users can read and make sense of themselves. For example https://fluxcd.io/flux/components/kustomize/kustomizations/#kustomization-status.
For the above scenario, we may need to add a line in the docs about what -1 observed generation means.
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 think we should show something like "Resource not initialised" for -1
, when we'll implement the debug report.
For the --show-status
output, I'm going to take your suggestion and add a link to the status doc on both commands, as a YAML comment.
|
||
if len(ks.Spec.PostBuild.Substitute) > 0 { | ||
for k, v := range ks.Spec.PostBuild.Substitute { | ||
finalVars[k] = strings.ReplaceAll(v, "\n", "") |
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.
This string replacement of the value without any context is confusing. Maybe a link to https://github.com/fluxcd/pkg/blob/main/kustomize/kustomize_varsub.go or a helper function from there with more context would make it more readable to understand why this is being done here. The value transformation can also be tested in one central location and used everywhere.
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.
Comment added
} | ||
testEnv.CreateObjectFile(objectFile, tmpl, t) | ||
|
||
cases := []struct { |
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 failure in LoadVariables()
, maybe due to non-optional, non-existing substitute from object can also be a test case to make sure the command fails, instead of skipping such failures.
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
This PR implements the
flux debug ks
command as specified in #5109Followup: #5106
Closes: #5109