OSAC-2361: add deletion protection for default networking resources - #999
ori-amizur wants to merge 1 commit into
Conversation
Resources labeled osac.openshift.io/default: "true" (VirtualNetwork, Subnet, SecurityGroup, NATGateway, ExternalIP) are system-managed and cannot be deleted via the API. The Delete handler for each resource type now fetches the object and checks for the default label before proceeding, returning FailedPrecondition if present. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@ori-amizur: This pull request references OSAC-2361 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 task to target the "5.0.0" version, but no target version was set. DetailsIn response to this:
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. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ori-amizur The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
WalkthroughDeletion now rejects default-labeled ExternalIPs, NATGateways, SecurityGroups, Subnets, and VirtualNetworks with a gRPC ChangesDefault resource deletion protection
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 10 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (10 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/servers/security_groups_server_test.go`:
- Around line 469-493: Add this default-labeled deletion case to the
PrivateSecurityGroupsServer test suite, using privatev1 create and delete
requests so it exercises PrivateSecurityGroupsServer.Delete. Preserve the
existing assertions for FailedPrecondition and the “default” and
“system-managed” error details, and avoid relying on the public
SecurityGroupsServer test for coverage.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: osac-project/coderabbit/.coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 549470d9-a36d-4a3a-aaaf-81e321bf47c2
📒 Files selected for processing (11)
internal/servers/default_networking_provisioner.gointernal/servers/private_external_ips_server.gointernal/servers/private_external_ips_server_test.gointernal/servers/private_nat_gateways_server.gointernal/servers/private_nat_gateways_server_test.gointernal/servers/private_security_groups_server.gointernal/servers/private_subnets_server.gointernal/servers/private_subnets_server_test.gointernal/servers/private_virtual_networks_server.gointernal/servers/private_virtual_networks_server_test.gointernal/servers/security_groups_server_test.go
| const ownerReferenceAnnotation = "osac.openshift.io/owner-reference" | ||
|
|
||
| func validateNotDefault(labels map[string]string, resourceType string) error { | ||
| if labels[defaultLabel] == "true" { |
There was a problem hiding this comment.
Per the EP (and jira), default resources should be protected from deletion while resources depend on them. but here it's blocked unconditionally based just on the default label
Resources labeled osac.openshift.io/default: "true" (VirtualNetwork, Subnet, SecurityGroup, NATGateway, ExternalIP) are system-managed and cannot be deleted via the API. The Delete handler for each resource type now fetches the object and checks for the default label before proceeding, returning FailedPrecondition if present.
Summary by CodeRabbit