-
Notifications
You must be signed in to change notification settings - Fork 695
fix: BUILDKIT_HOST env parsing when doing system prune #4115
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
Conversation
@Shubhranshu153 Also, do we need to keep calling |
helpers.AddStringFlag -> This one i want to remove from all places as i feel we are manipulating behavior artificially. |
As the GetBuildkitHost() is kind of high level function used in 3 different places do you think we should move it to inside buildkitutils? |
ff6f1b1
to
848a4bf
Compare
1c5f8d4
to
29a42b6
Compare
Personal opinion: |
Linking latest failures to their tickets:
|
29a42b6
to
491775d
Compare
491775d
to
f7710a0
Compare
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.
One last comment on a test, but otherwise looks fine.
cc @AkihiroSuda @fahedouch for formal maintainer review.
@@ -253,6 +253,14 @@ func GetBuildkitHost(cmd *cobra.Command, namespace string) (string, error) { | |||
} | |||
return buildkitHost, nil | |||
} | |||
|
|||
if buildkitHost := os.Getenv("BUILDKIT_HOST"); buildkitHost != "" { |
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.
Wouldn't it be more logical to introduce the --buildkit-host
flag in the prune
command?
Unless I'm mistaken, we wanted to have a single entry point for CLI flag and parameters, which is cmd
. I think this ensures better management of flags, environment variables, and parameters related to the CLI.
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.
Probably this should be a global flag as in --address
($CONTAINERD_ADDRESS
)
Line 169 in 9791bbc
helpers.AddPersistentStringFlag(rootCmd, "address", []string{"a", "H"}, nil, []string{"host"}, aliasToBeInherited, cfg.Address, "CONTAINERD_ADDRESS", `containerd address, optionally with "unix://" prefix`) |
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 can add that as well along with the change.
But we should not deprecate the current flags for backward compatibility. Global flag will be overridden by the cmd specific options?
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.
A global flag can be specified for a subcommand too, so the compatibility is not affected AFAICS
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.
ok i can add it to the global flag and refactor the code. Makes sense to me.
Thanks
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 started doing this change but i feel this requires a larger refactor and some testing, will want to put it in a separate PR.
Needs rebase |
How is |
I think @Shubhranshu153 was talking about |
eg: my understanding is that |
619191a
to
83abfb9
Compare
@Shubhranshu153 main is bust right now. Suggesting you wait for #4128 then rebase. |
83abfb9
to
afbc1ba
Compare
Tagging unrelated failure: #4068 |
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.
One minor question about NoParallel on the first test, but otherwise LGTM.
Thanks @Shubhranshu153 !
Signed-off-by: Shubharanshu Mahapatra <shubhum@amazon.com>
afbc1ba
to
95fc284
Compare
Can we merge this? Thanks |
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.
Thanks
Currently when we set "BUILDKIT_HOST" as env variable, nerdctl doesnt take that into consideration for system prune.
With the change:
Note: helpers.AddStringFlag(cmd, "buildkit-host", nil, "", "BUILDKIT_HOST", "BuildKit address") this masks the logic for build commands but for prune command it doesn't work correctly
Would like to refactor not have the helper commands to parse it as this only works when we have the specific flag but for buildctl config BUILDKIT_HOST can be also set for commands which may not have the buildkit-host flag specifically: eg: system prune. Of we add other options like du etc for buildctl this will be also relevant