-
Notifications
You must be signed in to change notification settings - Fork 8
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
CSS-5266 - Tweak length check to require at least 1 region and controller #1034
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -483,11 +483,15 @@ func (j *JIMM) doCloudAdmin(ctx context.Context, u *dbmodel.User, ct names.Cloud | |
// an unauthorized error. | ||
return errors.E(op, errors.CodeUnauthorized, "unauthorized") | ||
} | ||
|
||
if len(c.Regions) != 1 || len(c.Regions[0].Controllers) != 1 { | ||
return errors.E(op, "cloud administration not available for %s", ct.Id()) | ||
// Ensure we always have at least 1 region for the cloud with at least 1 controller | ||
// managing that region. | ||
if len(c.Regions) < 1 || len(c.Regions[0].Controllers) < 1 { | ||
zapctx.Error(ctx, "cloud regions check", zap.Int("regions", len(c.Regions))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The error message is not clear enough. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is more of a debug line actually, if I change it to Debug should I then leave it or make it more explanatory? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Although a clear message is good anyway, but if it's just for future debugging, leave it as is. Also, I'm not sure if changing the level to debug is going to help, because we may lose it due to the applied log-level config. |
||
if len(c.Regions) > 0 { | ||
zapctx.Error(ctx, "region controllers check", zap.Int("controllers", len(c.Regions[0].Controllers))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This, too. |
||
} | ||
return errors.E(op, fmt.Sprintf("cloud administration not available for %s", ct.Id())) | ||
} | ||
|
||
api, err := j.dial(ctx, &c.Regions[0].Controllers[0].Controller, names.ModelTag{}) | ||
if err != nil { | ||
return errors.E(op, err) | ||
|
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.
Why was it != 1?
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.
It was
!= 1
, but that includes cases with> 1
elements which shouldn't result in an error.