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

Hide internal silos in utilization #4943

Merged
merged 9 commits into from
Feb 1, 2024
Merged

Conversation

zephraph
Copy link
Contributor

Fixes #4708.

I've updated the /v1/system/utilization/silos endpoint to only return non-discoverable silos if they have a quota set. I believe the default-silo does get a quota set currently which is non-ideal, but that should be the only one that shows up on the list.

I need specific eyes on the migration b/c I've never written a view migration before.

@@ -9,6 +9,7 @@ use uuid::Uuid;
pub struct SiloUtilization {
pub silo_id: Uuid,
pub silo_name: Name,
pub silo_discoverable: bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

Strictly speaking, while this is fine to add, you don't actually need this line, right? In the query you're using it in SQL directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmm, perhaps. I thought this struct is what generated the type to use for the dsl but that might actually be from the table! call. Yeah, regardless, it shouldn't matter.

@@ -13,7 +13,7 @@ use omicron_common::api::external::SemverVersion;
///
/// This should be updated whenever the schema is changed. For more details,
/// refer to: schema/crdb/README.adoc
pub const SCHEMA_VERSION: SemverVersion = SemverVersion::new(30, 0, 0);
pub const SCHEMA_VERSION: SemverVersion = SemverVersion::new(31, 0, 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to be 32 so #4852 can be 31

@augustuswm
Copy link
Contributor

Logically this makes sense to me. I don't know what specifically cockroachdb supports but if this is similar to postgres you may need to use CREATE OR REPLACE VIEW instead of ALTER VIEW

@zephraph
Copy link
Contributor Author

zephraph commented Jan 31, 2024

@augustuswm pointed out using CREATE OR REPLACE VIEW so I changed it to that instead. Something I'm not sure about is what CRDB's docs say about this:

In order to replace an existing view, the new view must have the same columns as the existing view, or more. If the new view has additional columns, the old columns must be a prefix of the new columns. For example, if the existing view has columns a, b, the new view can have an additional column c, but must have columns a, b as a prefix. In this case, CREATE OR REPLACE VIEW myview (a, b, c) would be allowed, but CREATE OR REPLACE VIEW myview (b, a, c) would not.

I'm not using the parenthesis after that name in the same way they've expressed so I assume what I have is okay? It wasn't clear to me if they're saying the select order matters.

@zephraph
Copy link
Contributor Author

I've updated the PR w/ a comment in the migration about what's being added and bumped the schema version an extra number to avoid clashing with #4852

@augustuswm
Copy link
Contributor

Looks like based on the failure it might need a drop / create instead of a replace.

@zephraph
Copy link
Contributor Author

Looks like based on the failure it might need a drop / create instead of a replace.

I reordered it such that the new column is at the end of the view and that causes it to pass. Seems like view migrations are order sensitive (which is what the docs I quoted above implied, I just didn't know if that meant for the select statement too).

@zephraph zephraph enabled auto-merge (squash) February 1, 2024 01:04
@zephraph zephraph merged commit 6a82336 into main Feb 1, 2024
20 checks passed
@zephraph zephraph deleted the hide-internal-silos-in-utilization branch February 1, 2024 01:51
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.

Non-discoverable silos should have zero quotas and be excluded from utilization query
4 participants