Skip to content

Commit

Permalink
Update Oximeter-related DataStore methods for incoming reconfigurator…
Browse files Browse the repository at this point in the history
… support (#6518)

This PR adds two new `DataStore` methods:

* `oximeter_delete` (soft deletes an oximeter instance, which also
requires a small migration to add a `time_deleted` column)
* `oximeter_reassign_all_producers` (reassigns all metric producers from
one oximeter instance to random other instances)

and updates existing methods to account for the possibility that an
oximeter instance may have been deleted (e.g., don't return deleted
instances when listing).

There are no callers of these methods in this PR, but there will be in
the upcoming reconfigurator-can-rebalance-oximeter PR.
  • Loading branch information
jgallagher authored Sep 16, 2024
1 parent d6907fc commit 8b59cae
Show file tree
Hide file tree
Showing 11 changed files with 705 additions and 11 deletions.
14 changes: 13 additions & 1 deletion nexus/db-model/src/oximeter_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use nexus_types::internal_api;
use uuid::Uuid;

/// A record representing a registered `oximeter` collector.
#[derive(Queryable, Insertable, Debug, Clone, Copy)]
#[derive(Queryable, Insertable, Debug, Clone, Copy, PartialEq, Eq)]
#[diesel(table_name = oximeter)]
pub struct OximeterInfo {
/// The ID for this oximeter instance.
Expand All @@ -18,6 +18,17 @@ pub struct OximeterInfo {
pub time_created: DateTime<Utc>,
/// When this resource was last modified.
pub time_modified: DateTime<Utc>,
/// When this resource was expunged.
//
// We typically refer to _zones_ as expunged; this isn't quite the same
// thing since this is the record of a running Oximeter instance. Some time
// after an Oximeter zone has been expunged (usually not very long!), the
// blueprint_executor RPW will mark the Oximeter instance that was running
// in that zone as expunged, setting this field to a non-None value, which
// will cause it to no longer be chosen as a potential collector for
// producers (and will result in any producers it had been assigned being
// reassigned to some other collector).
pub time_expunged: Option<DateTime<Utc>>,
/// The address on which this `oximeter` instance listens for requests.
pub ip: ipnetwork::IpNetwork,
/// The port on which this `oximeter` instance listens for requests.
Expand All @@ -31,6 +42,7 @@ impl OximeterInfo {
id: info.collector_id,
time_created: now,
time_modified: now,
time_expunged: None,
ip: info.address.ip().into(),
port: info.address.port().into(),
}
Expand Down
1 change: 1 addition & 0 deletions nexus/db-model/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ table! {
id -> Uuid,
time_created -> Timestamptz,
time_modified -> Timestamptz,
time_expunged -> Nullable<Timestamptz>,
ip -> Inet,
port -> Int4,
}
Expand Down
3 changes: 2 additions & 1 deletion nexus/db-model/src/schema_versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::collections::BTreeMap;
///
/// This must be updated when you change the database schema. Refer to
/// schema/crdb/README.adoc in the root of this repository for details.
pub const SCHEMA_VERSION: SemverVersion = SemverVersion::new(97, 0, 0);
pub const SCHEMA_VERSION: SemverVersion = SemverVersion::new(98, 0, 0);

/// List of all past database schema versions, in *reverse* order
///
Expand All @@ -29,6 +29,7 @@ static KNOWN_VERSIONS: Lazy<Vec<KnownVersion>> = Lazy::new(|| {
// | leaving the first copy as an example for the next person.
// v
// KnownVersion::new(next_int, "unique-dirname-with-the-sql-files"),
KnownVersion::new(98, "oximeter-add-time-expunged"),
KnownVersion::new(97, "lookup-region-snapshot-by-region-id"),
KnownVersion::new(96, "inv-dataset"),
KnownVersion::new(95, "turn-boot-on-fault-into-auto-restart"),
Expand Down
1 change: 1 addition & 0 deletions nexus/db-queries/src/db/datastore/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ pub use dns::DnsVersionUpdateBuilder;
pub use instance::{InstanceAndActiveVmm, InstanceGestalt};
pub use inventory::DataStoreInventoryTest;
use nexus_db_model::AllSchemaVersions;
pub use oximeter::CollectorReassignment;
pub use rack::RackInit;
pub use rack::SledUnderlayAllocationResult;
pub use region::RegionAllocationFor;
Expand Down
Loading

0 comments on commit 8b59cae

Please sign in to comment.