Skip to content
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

Merged
merged 3 commits into from
Aug 25, 2023

Conversation

kian99
Copy link
Contributor

@kian99 kian99 commented Aug 24, 2023

Description

Fix the length check in doCloudAdmin to allow granting access to clouds that have more than 1 region and more than 1 controller for said region.

Addresses the main issue from CSS-5266

Engineering checklist

Check only items that apply

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

// 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)))
Copy link
Member

Choose a reason for hiding this comment

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

The error message is not clear enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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?

Copy link
Member

Choose a reason for hiding this comment

The 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) < 1 || len(c.Regions[0].Controllers) < 1 {
zapctx.Error(ctx, "cloud regions check", zap.Int("regions", len(c.Regions)))
if len(c.Regions) > 0 {
zapctx.Error(ctx, "region controllers check", zap.Int("controllers", len(c.Regions[0].Controllers)))
Copy link
Member

Choose a reason for hiding this comment

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

This, too.

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 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was it != 1?

Copy link
Member

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.

@kian99 kian99 merged commit 6762462 into canonical:main Aug 25, 2023
@kian99 kian99 deleted the fix-modify-cloud-access branch August 25, 2023 12:20
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