Skip to content

[feat] Add cloud load-zone list command - #6142

Merged
joanlopez merged 10 commits into
masterfrom
add-cloud-load-zone-list
Jul 28, 2026
Merged

[feat] Add cloud load-zone list command#6142
joanlopez merged 10 commits into
masterfrom
add-cloud-load-zone-list

Conversation

@dgzlopes

Copy link
Copy Markdown
Member

What?

Add a new k6 cloud load-zone list subcommand that lists the load zones available in the configured Grafana Cloud k6 stack, mirroring the existing cloud project list command. Supports table and --json output.

➜ ./k6 cloud load-zone list
Load zones for https://daniellopes.grafana.net:

ID                     NAME                     TYPE      AVAILABLE
amazon:us:ashburn      Ashburn, US (Amazon)     public    yes
amazon:sa:cape town    Cape Town, SA (Amazon)   public    yes
amazon:us:columbus     Columbus, US (Amazon)    public    yes

Why?

My agent should have access to this information... so it can actually tell me Private Load Zone X is usable.

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)

Add a new `k6 cloud load-zone list` subcommand that lists the load zones
available in the configured Grafana Cloud k6 stack, mirroring the existing
`cloud project list` command. Supports table and --json output.

The table surfaces each zone's k6 load zone ID, name, whether it is a
public (Grafana-managed) or private zone, and its availability. The
`public` and `available` flags are not yet modeled by the cloud OpenAPI
SDK, so they are read best-effort from the untyped response fields and
default to false when absent.
@dgzlopes
dgzlopes temporarily deployed to azure-trusted-signing July 11, 2026 17:14 — with GitHub Actions Inactive
@dgzlopes
dgzlopes temporarily deployed to azure-trusted-signing July 11, 2026 17:16 — with GitHub Actions Inactive
- Name ListLoadZones' error return so a body-close error from
  closeResponse propagates instead of being silently dropped.
- Extract the shared v6 client setup (config load, login check, client
  creation, stack ID wiring) into newCloudV6ClientFromConfig and a
  cloudStackName helper, used by both `cloud project list` and
  `cloud load-zone list` instead of duplicating ~35 lines.
- Add a test covering the best-effort default: a load zone that omits
  the untyped public/available fields must default them to false.
- Rename cloud_loadzone*.go to cloud_load_zone*.go to match the command
  spelling and the test file name.
@dgzlopes
dgzlopes requested a review from oleiade July 11, 2026 20:27
@dgzlopes
dgzlopes marked this pull request as ready for review July 11, 2026 20:27
@dgzlopes
dgzlopes requested a review from a team as a code owner July 11, 2026 20:27
@dgzlopes
dgzlopes requested review from joanlopez and removed request for a team July 11, 2026 20:27
@dgzlopes dgzlopes added the cloud label Jul 11, 2026
@dgzlopes
dgzlopes temporarily deployed to azure-trusted-signing July 11, 2026 20:32 — with GitHub Actions Inactive
@dgzlopes
dgzlopes temporarily deployed to azure-trusted-signing July 11, 2026 20:34 — with GitHub Actions Inactive
ankur22
ankur22 previously approved these changes Jul 13, 2026

@ankur22 ankur22 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice! LGTM 🚀

Comment thread internal/cmd/cloud.go
Comment thread internal/cloudapi/v6/api.go Outdated
Comment on lines +182 to +183
Public: boolFromAny(zone.AdditionalProperties["public"]),
Available: boolFromAny(zone.AdditionalProperties["available"]),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see why AdditionalProperties is needed with the currently pinned generated client. AI pointed out that in newer version of k6-cloud-openapi-client-go those are zone's fields directly. Would it be possible, and reasonably easy to bump k6-cloud-openapi-client-go as part of this PR? That would let us use its typed Public and Available fields instead?

If the dependency update must happen separately, could we document that follow-up and reconsider whether silently defaulting required fields is the desired behavior?

- Route cmdCloudTestList.run() through the shared newCloudV6ClientFromConfig
  helper too, so project, test, and load-zone list all use one setup path
  instead of each carrying its own config load / auth check / client
  construction / stack-ID wiring.
- Expand the load-zone public/available comment into a TODO(#6142) tracking
  the k6-cloud-openapi-client-go bump that will replace the untyped
  AdditionalProperties reads with the SDK's typed fields, and note that both
  are required API fields so the false default only guards a contract
  violation.
@dgzlopes
dgzlopes temporarily deployed to azure-trusted-signing July 13, 2026 22:08 — with GitHub Actions Inactive
@dgzlopes
dgzlopes temporarily deployed to azure-trusted-signing July 13, 2026 22:10 — with GitHub Actions Inactive
@andrewslotin

Copy link
Copy Markdown
Contributor

@dgzlopes, how about cloud lz list for brevity and typing convenience?

@oleiade

oleiade commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

how about cloud lz list for brevity and typing convenience?
@dgzlopes agreed, either loadzone or lz but having a dash in a command name never feels right to me 🙇

@oleiade
oleiade self-requested a review July 16, 2026 10:08

@oleiade oleiade left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looking into this, gcx uses load-zones, which is plural, and not what we want, but we should aim to be consistent with their naming? So in hindsight, I'm okay with load-zone with dash and being singular 🙇🏻

@oleiade
oleiade self-requested a review July 16, 2026 10:09
oleiade
oleiade previously approved these changes Jul 16, 2026
ankur22
ankur22 previously approved these changes Jul 16, 2026
@ankur22

ankur22 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

@dgzlopes could you please resolve conflicts? 🙇

…-list

# Conflicts:
#	internal/cmd/cloud_loadtest_list.go
#	internal/cmd/cloud_project_list.go
@dgzlopes
dgzlopes dismissed stale reviews from ankur22 and oleiade via 7c7e327 July 24, 2026 11:53
@dgzlopes
dgzlopes temporarily deployed to azure-trusted-signing July 24, 2026 11:59 — with GitHub Actions Inactive
@dgzlopes
dgzlopes requested review from ankur22 and oleiade July 24, 2026 21:18
@dgzlopes
dgzlopes temporarily deployed to azure-trusted-signing July 24, 2026 21:24 — with GitHub Actions Inactive
@dgzlopes
dgzlopes temporarily deployed to azure-trusted-signing July 24, 2026 21:26 — with GitHub Actions Inactive
ankur22
ankur22 previously approved these changes Jul 27, 2026
@joanlopez joanlopez added this to the v2.2.0 milestone Jul 27, 2026
Comment thread internal/cmd/cloud_load_zone_list.go Outdated
Comment thread internal/cmd/cloud_load_zone_list.go Outdated
joanlopez
joanlopez previously approved these changes Jul 27, 2026

@joanlopez joanlopez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great job @dgzlopes! Thanks for the contribution! 🙌🏻

Looks good! ✅

Do you folks (@dgzlope/@ankur22) think the "availability" thing I mentioned worths being polished before merging it? If not, feel free to click on merge yourselves! 👍🏻

Co-authored-by: Joan López de la Franca Beltran <5459617+joanlopez@users.noreply.github.com>
@dgzlopes
dgzlopes dismissed stale reviews from joanlopez and ankur22 via 9a872b0 July 27, 2026 12:11
dgzlopes and others added 2 commits July 27, 2026 14:12
Co-authored-by: Joan López de la Franca Beltran <5459617+joanlopez@users.noreply.github.com>
@dgzlopes
dgzlopes requested review from ankur22 and joanlopez July 27, 2026 12:12
@dgzlopes
dgzlopes temporarily deployed to azure-trusted-signing July 27, 2026 12:18 — with GitHub Actions Inactive
@dgzlopes
dgzlopes temporarily deployed to azure-trusted-signing July 27, 2026 12:21 — with GitHub Actions Inactive
Comment thread internal/cmd/cloud_load_zone.go Outdated
@joanlopez
joanlopez temporarily deployed to azure-trusted-signing July 27, 2026 16:44 — with GitHub Actions Inactive
@joanlopez
joanlopez temporarily deployed to azure-trusted-signing July 27, 2026 16:46 — with GitHub Actions Inactive
@joanlopez
joanlopez merged commit c3c5b24 into master Jul 28, 2026
58 checks passed
@joanlopez
joanlopez deleted the add-cloud-load-zone-list branch July 28, 2026 08:43
moko-poi added a commit to moko-poi/k6 that referenced this pull request Aug 2, 2026
Brings the branch up to date with master (5880ca9) and resolves the
overlap with the cloud changes that landed in the meantime:

- grafana#6142 added `k6 cloud load-zone`, whose constructor took the `*cmdCloud`
  this branch removes. `getCmdCloudLoadZone` now takes a `*state.GlobalState`,
  like the `project` and `test` constructors already do here.
- grafana#6208 dropped the run flag set from the parent `k6 cloud` command and pinned
  that with a test. This branch had bound those flags to throwaway values to
  keep the help output unchanged, which is now both unnecessary and wrong, so
  that block is gone.
- grafana#6171 added `--no-cloud-logs`. Its validation stays in `cmdCloudRun.preRun`,
  followed by `applyCloudEnvOverrides` instead of the parent's `preRun`.
- master's new `newCloudV6ClientFromConfig` and `cloudStackName` helpers are
  kept as they are.

No behaviour change beyond what the merged commits already do.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants