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

first steps towards data-plane-gateway deprecation #1628

Merged
merged 8 commits into from
Sep 20, 2024
6 changes: 4 additions & 2 deletions crates/agent/src/api/create_data_plane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,10 @@ async fn do_create_data_plane(
ops_l2_stats_transform,
broker_address,
reactor_address,
hmac_keys
hmac_keys,
enable_l2
) values (
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12
)
on conflict (data_plane_name) do update set
broker_address = $9,
Expand All @@ -171,6 +172,7 @@ async fn do_create_data_plane(
broker_address,
reactor_address,
hmac_keys.as_slice(),
!hmac_keys.is_empty(), // Enable L2 if HMAC keys are defined at creation.
)
.fetch_one(pg_pool)
.await?;
Expand Down
16 changes: 10 additions & 6 deletions crates/agent/src/api/update_l2_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,9 @@ export class Derivation extends Types.IDerivation {"#
ops_l1_inferred_name as "ops_l1_inferred_name: models::Collection",
ops_l2_inferred_transform,
ops_l1_stats_name as "ops_l1_stats_name: models::Collection",
ops_l2_stats_transform
ops_l2_stats_transform,
enable_l2
from data_planes
-- Data-planes without configured HMAC keys are presumed to not be ready,
-- and we hold back from processing their L1 derivations.
where hmac_keys != '{}'
order by data_plane_name asc;
"#,
)
Expand All @@ -123,6 +121,7 @@ export class Derivation extends Types.IDerivation {"#
l2_inferred_transforms.push(models::TransformDef {
name: models::Transform::new(&data_plane.ops_l2_inferred_transform),
source: models::Source::Collection(data_plane.ops_l1_inferred_name.clone()),
disable: !data_plane.enable_l2,

shuffle: models::Shuffle::Key(models::CompositeKey::new([models::JsonPointer::new(
"/collection_name",
Expand All @@ -132,23 +131,25 @@ export class Derivation extends Types.IDerivation {"#
)),

backfill: 0,
disable: false,
priority: 0,
read_delay: None,
});

l2_stats_transforms.push(models::TransformDef {
name: models::Transform::new(&data_plane.ops_l2_stats_transform),
source: models::Source::Collection(data_plane.ops_l1_stats_name.clone()),
disable: !data_plane.enable_l2,

backfill: 0,
disable: false,
lambda: models::RawValue::default(),
priority: 0,
read_delay: None,
shuffle: models::Shuffle::Any,
});

if !data_plane.enable_l2 {
l2_stats_module.push_str("\n/*");
}
l2_stats_module.push_str(&format!(
r#"
{method_name}(read: {{ doc: Types.{type_name}}}): Types.Document[] {{
Expand All @@ -160,6 +161,9 @@ export class Derivation extends Types.IDerivation {"#
camel_case(&data_plane.ops_l2_stats_transform, true)
)
));
if !data_plane.enable_l2 {
l2_stats_module.push_str("\n*/");
}
}

l2_stats_module.push_str("\n}\n");
Expand Down
6 changes: 4 additions & 2 deletions crates/agent/src/integration_tests/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ impl TestHarness {
ops_l2_stats_transform,
broker_address,
reactor_address,
hmac_keys
hmac_keys,
enable_l2
) values (
'ops/dp/public/test',
'test.dp.estuary-data.com',
Expand All @@ -193,7 +194,8 @@ impl TestHarness {
'from-L1-stats',
'broker:address',
'reactor:address',
'{secret-key}'
'{secret-key}',
false
) on conflict do nothing
)
select 1 as "something: bool";
Expand Down
19 changes: 19 additions & 0 deletions supabase/migrations/63_new_data_plane_columns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
begin;

alter table data_planes add column aws_iam_user_arn text;
alter table data_planes add column cidr_blocks cidr[] not null default '{}';
alter table data_planes add column enable_l2 boolean not null default false;
Copy link
Member

Choose a reason for hiding this comment

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

What's the reason for excluding a data plane from the L2 rollups? Is this for increased data privacy?

Copy link
Member Author

Choose a reason for hiding this comment

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

discussed in VC, but this is to be able to temporarily turn off data planes without it breaking L2 reporting.

alter table data_planes add column gcp_service_account_email text;
alter table data_planes add column ssh_private_key text;
Copy link
Member

Choose a reason for hiding this comment

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

nit: These could use some comment on columns


-- Must be provided explicitly.
alter table data_planes alter column enable_l2 drop default;

-- Users may read out details of applied data-plane configuration.
grant select (
aws_iam_user_arn,
cidr_blocks,
gcp_service_account_email
) on data_planes to authenticated;

commit;