Skip to content

fix: fixes add-model response when no controllers are registered#1801

Merged
ale8k merged 4 commits intocanonical:v3from
ale8k:juju-9051/fix-add-model-no-controllers
Jan 13, 2026
Merged

fix: fixes add-model response when no controllers are registered#1801
ale8k merged 4 commits intocanonical:v3from
ale8k:juju-9051/fix-add-model-no-controllers

Conversation

@ale8k
Copy link
Contributor

@ale8k ale8k commented Jan 13, 2026

Description

Fixes https://warthogs.atlassian.net/browse/JUJU-9051, a bug that @alesstimec found.

When running add-model against JIMM, and no controllers were registered, the code path for this was running. This is because Juju was attempting to get the cloud here in order to retrieve the credential to add the model.

I've solved this by adding a count controllers DB call, and checking in ForEachUserCloud that controllers are registered. This error is propogated through the facade and now returned from the Clouds() call. Surfaced like so:

➜  jimm git:(juju-9051/fix-add-model-no-controllers) ✗ juju add-model a
ERROR no controllers registered

I did think of putting it in the facade call but any call to ForEachUserCloud is moot without having controllers, hence why I added the check here. We should probably add this to all Cloud retrieval calls, but I didn't want to scope creep this PR.

Engineering checklist

  • Documentation updated
  • Covered by unit tests
  • Covered by integration tests

Test instructions

Spin up jimm without controllers, login, and run add-model.

@ale8k ale8k requested a review from a team as a code owner January 13, 2026 12:37
@ale8k ale8k force-pushed the juju-9051/fix-add-model-no-controllers branch from 33bd6f5 to 9a26a73 Compare January 13, 2026 12:39
Copy link
Contributor

@kian99 kian99 left a comment

Choose a reason for hiding this comment

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

Loosk good, truncating the int64 to int is also fine and I'd make that change.

Copy link
Collaborator

@alesstimec alesstimec left a comment

Choose a reason for hiding this comment

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

LGTM with final two comments

@ale8k ale8k force-pushed the juju-9051/fix-add-model-no-controllers branch from e3a6f90 to 789ca67 Compare January 13, 2026 15:19
@ale8k ale8k merged commit cf61276 into canonical:v3 Jan 13, 2026
7 checks passed
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.

3 participants