Skip to content

skip binary provisioning for run command #4731

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

Merged

Conversation

pablochacin
Copy link
Contributor

@pablochacin pablochacin commented Apr 23, 2025

What?

skip binary provisioning for k6 run command

Why?

Binary provisioning is currently supported only for users who have a cloud account, because it requires authenticating to GCK6.
Enabling binary provisioning only for cloud command (e.g. k6 cloud run) offers a more consistent user experience. The exception to this are the k6 archive and k6 inspect commands that are require for the users to upload tests to the cloud.

Checklist

  • I have performed a self-review of my code.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests for my changes.
  • I have run linter and tests locally (make check) and all pass.

Checklist: Documentation (only for k6 maintainers and if relevant)

Please do not merge this PR until the following items are filled out.

  • I have added the correct milestone and labels to the PR.
  • I have updated the release notes: link
  • I have updated or added an issue to the k6-documentation: grafana/k6-docs#NUMBER if applicable
  • I have updated or added an issue to the TypeScript definitions: grafana/k6-DefinitelyTyped#NUMBER if applicable

Related PR(s)/Issue(s)

@pablochacin pablochacin requested a review from a team as a code owner April 23, 2025 16:23
@pablochacin pablochacin requested review from mstoykov, inancgumus and codebien and removed request for a team, mstoykov and inancgumus April 23, 2025 16:23
Copy link
Contributor

@codebien codebien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Binary provisioning feature is enabled. If one of the commands between `cloud run`, `cloud run --local-exeuction`, `archive` or `inspect` is used then k6 will try to provision a new k6 binary.

I think we need a better UX, because if someone now tries k6 run it won't be able to get why it doesn't work as expected.

@pablochacin pablochacin requested a review from codebien April 24, 2025 08:12

deps, err := analyze(l.gs, l.gs.CmdArgs[1:])
if err != nil {
l.gs.Logger.
WithError(err).
Error("Failed to analyze the required dependencies. Please, make sure to report this issue by" +
Error("Binary provisioning enabled but failed to analyze dependencies. Please, make sure to report this issue by" +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Error("Binary provisioning enabled but failed to analyze dependencies. Please, make sure to report this issue by" +
Error("Binary provisioning is enabled but it failed to analyze the dependencies. Please, make sure to report this issue by" +

@@ -76,22 +77,21 @@ func (l *Launcher) Launch() {
// if the command does not have dependencies or a custom build
if !customBuildRequired(build.Version, deps) {
l.gs.Logger.
Debug("The current k6 binary already satisfies all the required dependencies," +
" it isn't required to provision a new binary.")
Debug("Binary provisioning is not required to execute this command.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the previous message better because it explains the why. Can we restore it?

@@ -194,7 +194,7 @@ func k6buildProvision(gs *state.GlobalState, deps k6deps.Dependencies) (commandE
}

if config.BuildServiceAuth == "" {
return nil, errors.New("k6 cloud token is required when Binary provisioning feature is enabled." +
return nil, errors.New("k6 cloud token is required when the binary provisioning feature is enabled." +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return nil, errors.New("k6 cloud token is required when the binary provisioning feature is enabled." +
return nil, errors.New("k6 cloud token is required when the binary provisioning feature is enabled." +

I'm using Binary provisioning because it is the name of the feature. So, any name requires to be capitalized.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be "Binary Provisioning"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is fine to me, go for it 👍

@@ -249,6 +249,8 @@ func analyze(gs *state.GlobalState, args []string) (k6deps.Dependencies, error)
}

if !isScriptRequired(args) {
gs.Logger.
Debug("command does not require binary provisioning")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Debug("command does not require binary provisioning")
Debug("The command to execute does not require binary provisioning")

A follow-up improvement might be to return the identified command from isScriptRequired function and log it here. However, it can be a low priority improvement for the future.

Signed-off-by: Pablo Chacin <[email protected]>
Signed-off-by: Pablo Chacin <[email protected]>
@codebien codebien merged commit dec77b0 into feat/binary-provisioning Apr 24, 2025
28 checks passed
@codebien codebien deleted the skip-binary-provisioning-for-run-command branch April 24, 2025 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants