-
Notifications
You must be signed in to change notification settings - Fork 62
Resource Utilization #1782
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
Merged
Merged
Resource Utilization #1782
Changes from all commits
Commits
Show all changes
97 commits
Select commit
Hold shift + click to select a range
b1f9749
First pass of resource utilization
smklein d14f8fc
less weird formatting
smklein 0430d1a
Tweak CTE to avoid using 'OR'; prefer 'UNION' to avoid full table scans
smklein e8c937f
Merge with snapshots
smklein 55c1e81
Add test
smklein 98467b2
test snapshot usage accounting
smklein f838365
Emit disk usage info to clickhouse
smklein f1e4293
Add external API endpoint for querying metrics endpoints
smklein fda4c3c
fix json spec, minor tweaks
smklein b20fefd
Fix unauth tests
smklein 5ff619e
Boost timeout to not miss utilization
smklein acb91ee
Merge branch 'main' into resource-usage
smklein 5c33dba
Add CPUs provisioned
smklein 4c48467
Add resource usage for non-default silo, add fleet to DB
smklein 356d4fc
Silos know which fleets they belong to, fleet resource accounting
smklein ba874bb
Okay, fleet 'resource_usage' now created / tested, should be working
smklein e0f9919
Actually use CPU accounting saga node
smklein 229480b
Add test for CPU usage
smklein d2c5d9d
RAM provisionining metrics are plumbed
smklein 2d6f145
minor docs / label updates
smklein 36f7f8f
Merge branch 'main' into resource-usage
smklein df4bd2f
physical_disk accounting updated to virtual_disk accounting
smklein 2b30f2b
fix endpoint
smklein e0dd385
Make 'test_disk_metrics' less flaky
smklein 613e820
Add resource_type
smklein 0036869
Safer conversions, less unwrap
smklein f3e9d7b
Use authz::project instead of project_id
smklein 4c237e1
Revert "Use authz::project instead of project_id"
smklein 9e3e6ea
No project_id to volume_delete
smklein c0b7d85
Add test for idempotent fleet initialization
smklein 83d8d9f
More transactions
smklein 95bdaff
updated comment
smklein f05296e
Add 404 handling for resource usage
smklein 9a758c2
comments
smklein 8d153f6
http entrypoints naming
smklein 91a1b9d
More endpoint updates
smklein c693630
rename 'ResourceUsage' to 'VirtualResourceProvisioning'
smklein 88c1b0d
Merge branch 'main' into resource-usage (Compiling)
smklein eaf9fb3
usage -> Provision, update openapi
smklein acd4d77
link to query
smklein ec48ea0
VERY WIP - MOVE ACCOUNTING FOR DISKS/INSTANCES CLOSER TO CREATION/DEL…
smklein a414206
Merge branch 'main' into resource-usage
smklein 2653911
fmt
smklein c8a2031
Distinguish between 'resource' and 'collection'. Add CTE to make upda…
smklein db41a2a
Rename virtual_resource_provisioning to collection vs resource
smklein 1371404
Merge branch 'main' into resource-usage
smklein 70facfb
Merge branch 'main' into resource-usage
smklein 206572d
Remove fleet from DB
smklein 82c6378
Still need to insert collection record for fleet
smklein e398fe1
Comments, distinguish between disk and snapshots
smklein 29edafd
Just starting to make snapshot delete a saga
smklein 081f649
Merge branch 'main' into resource-usage
smklein f382a73
Patch tests, pull in some saga-ification PRs
smklein 5f5f15e
Transactions, deleting collections, validate collection empty on delete
smklein 999585c
Remove fleet from views
smklein abf9923
Merge branch 'main' into resource-usage
smklein 27b2c62
Merge branch 'main' into resource-usage
smklein 109172d
Add resource accounting to saga idempotency/unwind tests
smklein 2cada78
cleanup on project delete
smklein 021744c
Merge branch 'main' into resource-usage
smklein fbc1fe4
cleanup tests
smklein dd326e8
testonly
smklein 2e1c25a
Add more tests, oximeter test API
smklein 84308a7
Merge branch 'main' into resource-usage
smklein 4db6b9f
fix disk_delete test parameters
smklein 14b3580
Merge branch 'main' into resource-usage
smklein 254c2ec
Derive display
smklein 76704e7
to ByteCount
smklein 4e6ea23
silo not found when inserting returns 404
smklein e954c77
system_metric_lookup in app layer
smklein fc81ada
Remove ResourceType::VirtualProvision
smklein 6837d17
Simplify nexus testing logic
smklein ae86c33
tweak some test timings to fight flakes when under load
smklein 91fd7b8
De-duplicate Nexus metrics producer
smklein ee529d7
Merge branch 'main' into resource-usage
smklein 292ee96
Local to txn
smklein 2ab2a3f
fix tests
smklein 5f534d6
Add a Nexus internal API endpoint for disk remove read only parent (#…
leftwo ade45d5
[wicket] add missing serde feature on hex dependency (#2163)
sunshowers eaef871
[wicket] move wizard into its own file (#2164)
sunshowers 516acbc
[wicket] fix call to get_prev_component_id (#2167)
sunshowers 338cbd0
[wicket] add an upload command (#2165)
sunshowers 5935d13
Bump trybuild from 1.0.75 to 1.0.76 (#2172)
dependabot[bot] a02eca7
Bump clap from 4.0.32 to 4.1.1 (#2168)
dependabot[bot] b1f3879
Bump debug-ignore from 1.0.3 to 1.0.5 (#2173)
dependabot[bot] 6476827
Bump dropshot from `ce5deee` to `120e168` (#2170)
dependabot[bot] a10f930
Bump progenitor from `634bf98` to `1ef131a` (#2174)
dependabot[bot] b3d3849
Bump indicatif from 0.17.2 to 0.17.3 (#2171)
dependabot[bot] 653479b
Docs on ALLOW_FULL_TABLE_SCAN_SQL
smklein 3db02c7
fix mis-merge
smklein f96cb95
Collect timestamps for Oximeter in CRDB to act as tie-breaker
smklein 5f49bc3
Merge branch 'main' into resource-usage
smklein 57c7389
Fix bad merge
smklein e18210e
mitigate races in metrics test
smklein a1feec2
Merge branch 'main' into resource-usage
smklein 52af08a
Merge branch 'main' into resource-usage
smklein 9f498f0
metrics test needs a wider time window, especially when under load
smklein File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,3 +5,4 @@ | |
| //! Subqueries used in CTEs. | ||
|
|
||
| pub mod region_allocation; | ||
| pub mod virtual_provisioning_collection_update; | ||
47 changes: 47 additions & 0 deletions
47
nexus/db-model/src/queries/virtual_provisioning_collection_update.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| // This Source Code Form is subject to the terms of the Mozilla Public | ||
| // License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| // file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
|
||
| //! Describes the resource provisioning update CTE | ||
| //! | ||
| //! Refer to <nexus/src/db/queries/virtual_provisioning_collection_update.rs> | ||
| //! for the construction of this query. | ||
|
|
||
| use crate::schema::organization; | ||
| use crate::schema::silo; | ||
| use crate::schema::virtual_provisioning_collection; | ||
|
|
||
| table! { | ||
| parent_org { | ||
| id -> Uuid, | ||
| } | ||
| } | ||
|
|
||
| table! { | ||
| parent_silo { | ||
| id -> Uuid, | ||
| } | ||
| } | ||
|
|
||
| table! { | ||
| all_collections { | ||
| id -> Uuid, | ||
| } | ||
| } | ||
|
|
||
| table! { | ||
| do_update (update) { | ||
| update -> Bool, | ||
| } | ||
| } | ||
|
|
||
| diesel::allow_tables_to_appear_in_same_query!(organization, parent_org,); | ||
| diesel::allow_tables_to_appear_in_same_query!(silo, parent_silo,); | ||
|
|
||
| diesel::allow_tables_to_appear_in_same_query!( | ||
| virtual_provisioning_collection, | ||
| parent_org, | ||
| parent_silo, | ||
| all_collections, | ||
| do_update, | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| // This Source Code Form is subject to the terms of the Mozilla Public | ||
| // License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| // file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
|
||
| use crate::schema::virtual_provisioning_collection; | ||
| use crate::ByteCount; | ||
| use chrono::{DateTime, Utc}; | ||
| use omicron_common::api::external; | ||
| use parse_display::Display; | ||
| use uuid::Uuid; | ||
|
|
||
| #[derive(Debug, Display)] | ||
| pub enum CollectionTypeProvisioned { | ||
| Project, | ||
| Organization, | ||
| Silo, | ||
| Fleet, | ||
| } | ||
|
|
||
| /// Describes virtual_provisioning_collection for a collection | ||
| #[derive(Clone, Selectable, Queryable, Insertable, Debug)] | ||
| #[diesel(table_name = virtual_provisioning_collection)] | ||
| #[diesel(treat_none_as_default_value = true)] | ||
| pub struct VirtualProvisioningCollection { | ||
| pub id: Uuid, | ||
| pub time_modified: Option<DateTime<Utc>>, | ||
| pub collection_type: String, | ||
|
|
||
| pub virtual_disk_bytes_provisioned: ByteCount, | ||
| pub cpus_provisioned: i64, | ||
| pub ram_provisioned: ByteCount, | ||
| } | ||
|
|
||
| impl VirtualProvisioningCollection { | ||
| pub fn new(id: Uuid, collection_type: CollectionTypeProvisioned) -> Self { | ||
| Self { | ||
| id, | ||
| time_modified: None, | ||
| collection_type: collection_type.to_string(), | ||
| virtual_disk_bytes_provisioned: ByteCount( | ||
| external::ByteCount::from(0), | ||
| ), | ||
| cpus_provisioned: 0, | ||
| ram_provisioned: ByteCount(external::ByteCount::from(0)), | ||
| } | ||
| } | ||
|
|
||
| pub fn is_empty(&self) -> bool { | ||
| self.virtual_disk_bytes_provisioned.to_bytes() == 0 | ||
| && self.cpus_provisioned == 0 | ||
| && self.ram_provisioned.to_bytes() == 0 | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| // This Source Code Form is subject to the terms of the Mozilla Public | ||
| // License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| // file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
|
||
| use crate::schema::virtual_provisioning_resource; | ||
| use crate::ByteCount; | ||
| use chrono::{DateTime, Utc}; | ||
| use omicron_common::api::external; | ||
| use uuid::Uuid; | ||
|
|
||
| #[derive(Debug)] | ||
| pub enum ResourceTypeProvisioned { | ||
| Instance, | ||
| Disk, | ||
| Snapshot, | ||
| } | ||
|
|
||
| impl std::fmt::Display for ResourceTypeProvisioned { | ||
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
| match self { | ||
| ResourceTypeProvisioned::Instance => write!(f, "instance"), | ||
| ResourceTypeProvisioned::Disk => write!(f, "disk"), | ||
| ResourceTypeProvisioned::Snapshot => write!(f, "snapshot"), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// Describes virtual_provisioning_resource for a resource. | ||
| #[derive(Clone, Selectable, Queryable, Insertable, Debug)] | ||
| #[diesel(table_name = virtual_provisioning_resource)] | ||
| #[diesel(treat_none_as_default_value = true)] | ||
| pub struct VirtualProvisioningResource { | ||
| pub id: Uuid, | ||
| pub time_modified: Option<DateTime<Utc>>, | ||
| pub resource_type: String, | ||
|
|
||
| pub virtual_disk_bytes_provisioned: ByteCount, | ||
| pub cpus_provisioned: i64, | ||
| pub ram_provisioned: ByteCount, | ||
| } | ||
|
|
||
| impl VirtualProvisioningResource { | ||
| pub fn new(id: Uuid, resource_type: ResourceTypeProvisioned) -> Self { | ||
| Self { | ||
| id, | ||
| time_modified: None, | ||
| resource_type: resource_type.to_string(), | ||
| virtual_disk_bytes_provisioned: ByteCount( | ||
| external::ByteCount::from(0), | ||
| ), | ||
| cpus_provisioned: 0, | ||
| ram_provisioned: ByteCount(external::ByteCount::from(0)), | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.