-
Notifications
You must be signed in to change notification settings - Fork 485
adapter: handle easy objects using catalog implications #34358
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
Open
aljoscha
wants to merge
2
commits into
MaterializeInc:main
Choose a base branch
from
aljoscha:adapter-implications-follow-up
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+53
−44
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,7 @@ use mz_catalog::memory::objects::{ | |
| CatalogItem, Cluster, ClusterReplica, Connection, ContinualTask, DataSourceDesc, Index, | ||
| MaterializedView, Secret, Sink, Source, StateDiff, Table, TableDataSource, View, | ||
| }; | ||
| use mz_cloud_resources::VpcEndpointConfig; | ||
| use mz_compute_client::protocol::response::PeekResponse; | ||
| use mz_controller_types::{ClusterId, ReplicaId}; | ||
| use mz_ore::collections::CollectionExt; | ||
|
|
@@ -181,6 +182,7 @@ impl Coordinator { | |
| let mut source_collections_to_create = BTreeMap::new(); | ||
| let mut storage_policies_to_initialize = BTreeMap::new(); | ||
| let mut execution_timestamps_to_set = BTreeSet::new(); | ||
| let mut vpc_endpoints_to_create: Vec<(CatalogItemId, VpcEndpointConfig)> = vec![]; | ||
|
|
||
| // We're incrementally migrating the code that manipulates the | ||
| // controller from closures in the sequencer. For some types of catalog | ||
|
|
@@ -380,17 +382,29 @@ impl Coordinator { | |
| secrets_to_drop.push(catalog_id); | ||
| } | ||
| CatalogImplication::Connection(CatalogImplicationKind::Added(connection)) => { | ||
| tracing::debug!(?connection, "not handling AddConnection in here yet"); | ||
| match &connection.details { | ||
| // SSH connections: key pair is stored in secrets_controller | ||
| // BEFORE the catalog transaction, so no action needed here. | ||
| ConnectionDetails::Ssh { .. } => {} | ||
| // AWS PrivateLink connections: create the VPC endpoint | ||
| ConnectionDetails::AwsPrivatelink(privatelink) => { | ||
| let spec = VpcEndpointConfig { | ||
| aws_service_name: privatelink.service_name.to_owned(), | ||
| availability_zone_ids: privatelink.availability_zones.to_owned(), | ||
| }; | ||
| vpc_endpoints_to_create.push((catalog_id, spec)); | ||
| } | ||
| // Other connection types don't require post-transaction actions | ||
| _ => {} | ||
| } | ||
| } | ||
| CatalogImplication::Connection(CatalogImplicationKind::Altered { | ||
| prev: prev_connection, | ||
| new: new_connection, | ||
| prev: _prev_connection, | ||
| new: _new_connection, | ||
| }) => { | ||
| tracing::debug!( | ||
| ?prev_connection, | ||
| ?new_connection, | ||
| "not handling AlterConnection in here yet" | ||
| ); | ||
| // Connection alterations (like rotate keys) are handled via | ||
| // secrets_controller without catalog changes to the connection | ||
| // details structure, so no action needed here. | ||
| } | ||
| CatalogImplication::Connection(CatalogImplicationKind::Dropped( | ||
| connection, | ||
|
|
@@ -519,6 +533,24 @@ impl Coordinator { | |
| self.initialize_storage_collections(storage_policies_to_initialize) | ||
| .await?; | ||
|
|
||
| // Create VPC endpoints for AWS PrivateLink connections | ||
| if !vpc_endpoints_to_create.is_empty() { | ||
| if let Some(cloud_resource_controller) = self.cloud_resource_controller.as_ref() { | ||
| for (connection_id, spec) in vpc_endpoints_to_create { | ||
| if let Err(err) = cloud_resource_controller | ||
| .ensure_vpc_endpoint(connection_id, spec) | ||
| .await | ||
| { | ||
| tracing::warn!(?err, "failed to ensure vpc endpoint!"); | ||
| } | ||
| } | ||
| } else { | ||
| tracing::warn!( | ||
|
Comment on lines
+544
to
+548
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know both of these are |
||
| "AWS PrivateLink connections unsupported without cloud_resource_controller" | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| let collections_to_drop: BTreeSet<_> = sources_to_drop | ||
| .iter() | ||
| .map(|(_, gid)| *gid) | ||
|
|
||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with these things, but I see a
ConnectionDetails::AwsPrivatelinkcode block insequence_alter_connection_stage_finish, which does stuff with thecloud_resource_controller. (It seems similar to the migrated code block fromsequence_create_connection_stage_finish.) Should that be also migrated here, similar tovpc_endpoints_to_create?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, the main difference seems to be that the code "transaction side effects" are not included in a
catalog_transact_with_side_effectscall, but are run after the transaction. Which... I think is functionally the same?