Skip to content

Comments

SREP-3725: support VPC CIDR-based security group rules#360

Merged
openshift-merge-bot[bot] merged 1 commit intoopenshift:mainfrom
dustman9000:SREP-3725/use-vpc-cidr
Feb 24, 2026
Merged

SREP-3725: support VPC CIDR-based security group rules#360
openshift-merge-bot[bot] merged 1 commit intoopenshift:mainfrom
dustman9000:SREP-3725/use-vpc-cidr

Conversation

@dustman9000
Copy link
Member

Jira: https://issues.redhat.com/browse/SREP-3725

Summary

  • Add useVpcCidr option to SecurityGroup spec that uses the VPC CIDR block for security group rules instead of cluster-specific security group IDs
  • This enables multi-cluster VPC environments (e.g. FedRAMP/GovCloud) where multiple clusters need to access shared VPC endpoints
  • Fix copy-paste bugs in egress rule generation where IngressRules[i] was referenced instead of EgressRules[i]

Details

When spec.securityGroup.useVpcCidr is set to true, rules without an explicit cidrIp will resolve the VPC CIDR block and create IpRanges-based rules instead of discovering cluster node security group IDs. The default (false) preserves existing behavior.

Reference: HCMSEC-2832

Test plan

  • New unit tests for VPC CIDR rule generation path
  • New unit test for GetVpcCidrBlock AWS client method
  • Test cases for mixed explicit CidrIp + VPC CIDR rules
  • Test case for error when VPCId is empty
  • All existing tests pass
  • Deploy to test cluster with useVpcCidr: true and verify SG rules use VPC CIDR

Add useVpcCidr option to SecurityGroup spec that uses the VPC CIDR
block for security group rules instead of cluster-specific security
group IDs. This enables multi-cluster VPC environments where multiple
clusters need to access shared VPC endpoints.

Also fixes copy-paste bugs in egress rule generation where
IngressRules[i] was referenced instead of EgressRules[i].
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Feb 24, 2026
@openshift-ci-robot
Copy link

openshift-ci-robot commented Feb 24, 2026

@dustman9000: This pull request references SREP-3725 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

Jira: https://issues.redhat.com/browse/SREP-3725

Summary

  • Add useVpcCidr option to SecurityGroup spec that uses the VPC CIDR block for security group rules instead of cluster-specific security group IDs
  • This enables multi-cluster VPC environments (e.g. FedRAMP/GovCloud) where multiple clusters need to access shared VPC endpoints
  • Fix copy-paste bugs in egress rule generation where IngressRules[i] was referenced instead of EgressRules[i]

Details

When spec.securityGroup.useVpcCidr is set to true, rules without an explicit cidrIp will resolve the VPC CIDR block and create IpRanges-based rules instead of discovering cluster node security group IDs. The default (false) preserves existing behavior.

Reference: HCMSEC-2832

Test plan

  • New unit tests for VPC CIDR rule generation path
  • New unit test for GetVpcCidrBlock AWS client method
  • Test cases for mixed explicit CidrIp + VPC CIDR rules
  • Test case for error when VPCId is empty
  • All existing tests pass
  • Deploy to test cluster with useVpcCidr: true and verify SG rules use VPC CIDR

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 24, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dustman9000

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 24, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 24, 2026

@dustman9000: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 71.01449% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 40.69%. Comparing base (aba38b2) to head (889bd0d).

Files with missing lines Patch % Lines
controllers/vpcendpoint/helpers.go 71.73% 8 Missing and 5 partials ⚠️
pkg/aws_client/vpc_endpoint.go 53.84% 3 Missing and 3 partials ⚠️
pkg/aws_client/mock.go 90.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #360      +/-   ##
==========================================
+ Coverage   39.60%   40.69%   +1.08%     
==========================================
  Files          32       32              
  Lines        2040     2106      +66     
==========================================
+ Hits          808      857      +49     
- Misses       1134     1145      +11     
- Partials       98      104       +6     
Files with missing lines Coverage Δ
api/v1alpha2/vpcendpoint_types.go 100.00% <ø> (ø)
pkg/aws_client/mock.go 84.61% <90.00%> (+0.27%) ⬆️
pkg/aws_client/vpc_endpoint.go 63.06% <53.84%> (-1.23%) ⬇️
controllers/vpcendpoint/helpers.go 41.17% <71.73%> (+2.77%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

create := true
for _, rule := range rulesResp.SecurityGroupRules {
if avoAndAwsSecurityGroupRuleCandidate(true, resource.Spec.SecurityGroup.IngressRules[i], rule) {
if avoAndAwsSecurityGroupRuleCandidate(true, resource.Spec.SecurityGroup.EgressRules[i], rule) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure this was a typo? Looks to have been made over 3 years ago now, I would expect us to have seen issues? d964e88

Copy link
Member Author

@dustman9000 dustman9000 Feb 24, 2026

Choose a reason for hiding this comment

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

Yeah, it is a bug, but it's been harmless in practice because every VpcEndpoint CR we deploy configures identical ingress and egress rules (same ports, same protocol, same CidrIp). So IngressRules[i] and EgressRules[i] always had the same values at matching indices, and the wrong reference produced the correct result by coincidence.

Where it would actually break is if someone configured different rules for ingress vs egress (different ports, different protocols, or CidrIp on one but not the other). In that case the egress rule candidate matching would compare against the wrong port/protocol/CIDR. Since we've never done that, it's never surfaced.

Happy to split the bug fix into a separate commit if that's cleaner.

@joshbranham
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 24, 2026
@openshift-merge-bot openshift-merge-bot bot merged commit 90c64be into openshift:main Feb 24, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants