Skip to content

Commit

Permalink
Gate it behind feature flags
Browse files Browse the repository at this point in the history
  • Loading branch information
Sasha Krassovsky committed Jan 18, 2024
1 parent 2426627 commit d2e0d23
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
10 changes: 6 additions & 4 deletions compute_tools/src/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -744,10 +744,12 @@ impl ComputeNode {
// 'Close' connection
drop(client);

thread::spawn(move || {
let mut client = Client::connect(connstr.as_str(), NoTls)?;
handle_migrations(&mut client)
});
if self.has_feature(ComputeFeature::Migrations) {
thread::spawn(move || {
let mut client = Client::connect(connstr.as_str(), NoTls)?;
handle_migrations(&mut client)
});
}
Ok(())
}

Expand Down
11 changes: 9 additions & 2 deletions control_plane/src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ use crate::local_env::LocalEnv;
use crate::postgresql_conf::PostgresConf;

use compute_api::responses::{ComputeState, ComputeStatus};
use compute_api::spec::{Cluster, ComputeMode, ComputeSpec};
use compute_api::spec::{Cluster, ComputeFeature, ComputeMode, ComputeSpec};

// contents of a endpoint.json file
#[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Debug)]
Expand All @@ -70,6 +70,7 @@ pub struct EndpointConf {
http_port: u16,
pg_version: u32,
skip_pg_catalog_updates: bool,
features: Vec<ComputeFeature>,
}

//
Expand Down Expand Up @@ -140,6 +141,7 @@ impl ComputeControlPlane {
// with this we basically test a case of waking up an idle compute, where
// we also skip catalog updates in the cloud.
skip_pg_catalog_updates: true,
features: vec![],
});

ep.create_endpoint_dir()?;
Expand All @@ -154,6 +156,7 @@ impl ComputeControlPlane {
pg_port,
pg_version,
skip_pg_catalog_updates: true,
features: vec![],
})?,
)?;
std::fs::write(
Expand Down Expand Up @@ -215,6 +218,9 @@ pub struct Endpoint {

// Optimizations
skip_pg_catalog_updates: bool,

// Feature flags
features: Vec<ComputeFeature>,
}

impl Endpoint {
Expand Down Expand Up @@ -244,6 +250,7 @@ impl Endpoint {
tenant_id: conf.tenant_id,
pg_version: conf.pg_version,
skip_pg_catalog_updates: conf.skip_pg_catalog_updates,
features: conf.features,
})
}

Expand Down Expand Up @@ -519,7 +526,7 @@ impl Endpoint {
skip_pg_catalog_updates: self.skip_pg_catalog_updates,
format_version: 1.0,
operation_uuid: None,
features: vec![],
features: self.features.clone(),
cluster: Cluster {
cluster_id: None, // project ID: not used
name: None, // project name: not used
Expand Down
3 changes: 3 additions & 0 deletions libs/compute_api/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ pub enum ComputeFeature {
/// track short-lived connections as user activity.
ActivityMonitorExperimental,

/// Enable running migrations
Migrations,

/// This is a special feature flag that is used to represent unknown feature flags.
/// Basically all unknown to enum flags are represented as this one. See unit test
/// `parse_unknown_features()` for more details.
Expand Down
1 change: 1 addition & 0 deletions test_runner/fixtures/neon_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -2914,6 +2914,7 @@ def respec(self, **kwargs):

# Write it back updated
with open(config_path, "w") as file:
log.info(json.dumps(dict(data_dict, **kwargs)))
json.dump(dict(data_dict, **kwargs), file, indent=4)

# Mock the extension part of spec passed from control plane for local testing
Expand Down
2 changes: 1 addition & 1 deletion test_runner/regress/test_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def test_migrations(neon_simple_env: NeonEnv):
endpoint = env.endpoints.create("test_migrations")
log_path = endpoint.endpoint_path() / "compute.log"

endpoint.respec(skip_pg_catalog_updates=False)
endpoint.respec(skip_pg_catalog_updates=False, features=["migrations"])
endpoint.start()

time.sleep(1) # Sleep to let migrations run
Expand Down

0 comments on commit d2e0d23

Please sign in to comment.