Skip to content

Conversation

@rahulait
Copy link
Contributor

@rahulait rahulait commented Jul 22, 2025

General:

This PR adds two new flags to CCM (--vpc-ids and --subnet-ids). This will allow someone to specify ids instead of names when starting CCM.

Key changes:
Added --vpc-ids and --subnet-ids command-line flags as IntSlice types
Changed existing --vpc-names and --subnet-names flags from string to StringSlice types
Added validation logic to ensure only one approach (names or IDs) is used at a time

  • Have you removed all sensitive information, including but not limited to access keys and passwords?
  • Have you checked to ensure there aren't other open or closed Pull Requests for the same bug/feature/question?

Pull Request Guidelines:

  1. Does your submission pass tests?
  2. Have you added tests?
  3. Are you addressing a single feature in this PR?
  4. Are your commits atomic, addressing one change per commit?
  5. Are you following the conventions of the language?
  6. Have you saved your large formatting changes for a different PR, so we can focus on your work?
  7. Have you explained your rationale for why this feature is needed?
  8. Have you linked your PR to an open issue

@github-actions github-actions bot added the improvement for improvements in existing functionality in the changelog. label Jul 22, 2025
@codecov
Copy link

codecov bot commented Jul 22, 2025

Codecov Report

Attention: Patch coverage is 93.33333% with 6 lines in your changes missing coverage. Please review.

Project coverage is 75.83%. Comparing base (557cb5d) to head (3747f45).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
cloud/linode/vpc.go 96.05% 2 Missing and 1 partial ⚠️
cloud/linode/cloud.go 33.33% 1 Missing and 1 partial ⚠️
cloud/linode/loadbalancers.go 83.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #423      +/-   ##
==========================================
+ Coverage   75.42%   75.83%   +0.40%     
==========================================
  Files          16       16              
  Lines        2987     3054      +67     
==========================================
+ Hits         2253     2316      +63     
- Misses        545      547       +2     
- Partials      189      191       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This comment was marked as outdated.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds new command-line flags (--vpc-ids and --subnet-ids) to the CCM, allowing users to specify IDs instead of names when configuring VPC routing. The changes maintain backward compatibility with existing name-based flags while adding validation to ensure only one approach is used at a time.

Key changes:

  • Added --vpc-ids and --subnet-ids flags as IntSlice types alongside existing name-based flags
  • Converted existing string flags to StringSlice types for consistency
  • Added comprehensive validation logic to prevent conflicting flag combinations
  • Updated Helm chart templates and documentation to reflect the new options

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
main.go Updated flag definitions to support both ID and name-based VPC/subnet specification
cloud/linode/vpc.go Added validation functions and ID-to-name resolution logic
cloud/linode/vpc_test.go Added comprehensive tests for new validation and resolution functions
docs/configuration/environment.md Updated documentation to include new flag options
deploy/chart/values.yaml Added configuration examples for new ID-based flags
deploy/chart/templates/daemonset.yaml Added Helm template validation and flag passing logic
Multiple test files Updated test data to use new StringSlice format

Comment on lines +216 to +226
func resolveSubnetNames(client client.Client, vpcID int) ([]string, error) {
subnetNames := []string{}
for _, subnetID := range Options.SubnetIDs {
subnet, err := client.GetVPCSubnet(context.TODO(), vpcID, subnetID)
if err != nil {
return nil, fmt.Errorf("failed to get subnet %d for VPC %d: %w", subnetID, vpcID, err)
}

subnetIDs[subnet.Label] = subnet.ID
subnetNames = append(subnetNames, subnet.Label)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

won't this still lead to the same problem if the subnet name is changed? Since we are just grabbing the label at one point in time?

Copy link
Contributor Author

@rahulait rahulait Jul 22, 2025

Choose a reason for hiding this comment

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

Nope. We store everything in the cache and then it always looks into the cache.
vpcIDs and subnetIDs are the two caches it builds at startup and then uses going forward.

Copy link
Contributor

Choose a reason for hiding this comment

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

A ccm restart will cause that cache to be purged. Would that be an issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope. If someone updates vpcname/subnetname and CCM is restarted, it will again try to get the label for the passed vpcid/subnetid and store the updated name in its cache and continue working. When logging, it will log the vpc/subnet names instead of ids which are more readable/human friendly than the ids.

Copy link
Contributor

Choose a reason for hiding this comment

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

ahh ok I missed the vpcID logic since that was already there. Makes a lot more sense to me now.

Only other comment would be why can't you use ids and names?

Copy link
Contributor Author

@rahulait rahulait Jul 22, 2025

Choose a reason for hiding this comment

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

You mean flipping the logic and using vpcids/subnetids instead of vpcnames/subnetnames? Or you meant combination of vpcname+subnetid?
I didn't flip the logic as that would mean all existing tests would start failing and that would be a much bigger change and touch most of the functionality of CCM.

Copy link
Contributor

Choose a reason for hiding this comment

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

the combination, but it really isn't that important. One or the other is fine with me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It increases complexity and would be more error prone. I would prefer just using either names or ids but not both.

@rahulait rahulait merged commit f1b64ce into main Jul 23, 2025
10 of 11 checks passed
@AshleyDumaine AshleyDumaine deleted the accept-vpc-subnet-ids branch July 23, 2025 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement for improvements in existing functionality in the changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants