-
Notifications
You must be signed in to change notification settings - Fork 0
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
[diagnose] test service connectivity when no VPC endpoint exists #12
Conversation
This helps for when central VPC endpoints are used, which exist in a separate VPC (not the one you are testing from)
A positive test when the Execute API service is accessible (because the VPC endpoint exists in the same account and VPC as Gitpod):
|
A negative test for when the VPC endpoint has been deleted:
|
.devcontainer/devcontainer.json
Outdated
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.
Added because...Flex 💪
.gitpod/automations.yaml
Outdated
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.
For the Flex!
@@ -65,6 +66,10 @@ var checkCommand = &cobra.Command{ // nolint:gochecknoglobals | |||
log.Infof("ℹ️ Found duplicate subnets. We'll test each subnet '%v' only once.", distinctSubnets) | |||
} | |||
|
|||
if networkConfig.ApiEndpoint == "" { |
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.
Previously this parameter was unnecessary, because we were testing if the VPC endpoint for execute-api existed in the context of "this" AWS credential.
As we've learned, this is not always the case, like when a central account is used for VPC endpoints.
So, it became necessary to add this parameter.
networkCheckCmd.PersistentFlags().StringVar(&networkConfig.InstanceAMI, "instance-ami", "", "Custom ec2 instance AMI id, if not set will use latest ubuntu") | ||
log.Infof("ℹ️ Running with region `%s`, main subnet `%v`, pod subnet `%v`, and hosts `%v`", networkConfig.AwsRegion, networkConfig.MainSubnets, networkConfig.PodSubnets, networkConfig.HttpsHosts) | ||
networkCheckCmd.PersistentFlags().StringVar(&networkConfig.ApiEndpoint, "api-endpoint", "", "The Gitpod Enterprise control plane's regional API endpoint subdomain") | ||
bindFlags(networkCheckCmd, v) |
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.
We were binding too soon, causing us to not capture the values for instance-ami or api-endpoint.
continue | ||
} | ||
log.Infof("ℹ️ VPC endpoint %s is not configured, testing service connectivity...", endpoint.Endpoint) | ||
_, err := TestServiceConnectivity(ctx, endpoint.PrivateDnsName, 5*time.Second) |
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.
This new method will help us assert whether or not we have connectivity to VPC endpoints which are necessary to send SSM commands to EC2 instances (which later asserts connectivity, by subnet, to AWS services).
@@ -198,13 +209,22 @@ func checkSMPrerequisites(ctx context.Context, ec2Client *ec2.Client) error { | |||
} | |||
|
|||
if len(response.VpcEndpoints) == 0 { | |||
if endpoint.Required { | |||
return fmt.Errorf("❌ VPC endpoint %s not configured: %w", endpoint.Endpoint, err) | |||
if strings.Contains(endpoint.Endpoint, "execute-api") { |
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.
🫧 Instead of doing a substring match on the name, would it make sense to mark the endpoint with a flag named e.g. "testInMainSubnet" or similar...? 🤔
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.
would it make sense to mark the endpoint with a flag named e.g. "testInMainSubnet" or similar...? 🤔
At the moment, I think no. This is for a couple reasons:
- I don't expect the service name to change, and we're not checking for the service name in other places. If we were, then I'd consider adding a flag.
- This section of tests is for asserting we can interact with EC2 and SSM services, execute-api service has no impact on CLI functionality. It does help us assert private DNS is enabled, but, only when the VPC endpoint exists in the same account as Gitpod.
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.
✔️ to unblock, but I'm not in a position to test today
Left a comment with a potential code improvement, leaving it up to you to decide how to proceed. 👍
Description
Provide a means to test connectivity for AWS services when the current VPC lacks VPC endpoints. For example, perhaps VPC endpoints are centralized in another VPC.
Background:
There are two sets of checks in the network check CLI
Related Issue(s)
Fixes CLC-1118
How to test
Documentation
/hold