Skip to content

Fixups to dnspolicy for realgcp - #9594

Merged
justinsb merged 5 commits into
GoogleCloudPlatform:masterfrom
codebot-robot:issue_9593
Jun 9, 2026
Merged

Fixups to dnspolicy for realgcp#9594
justinsb merged 5 commits into
GoogleCloudPlatform:masterfrom
codebot-robot:issue_9593

Conversation

@codebot-robot

Copy link
Copy Markdown
Collaborator

Following on from #9569, a few fixups that are needed based on real-gcp testing:

  • Normalizes Id to ${dnsPolicyId} in mockgcp/mockdns/normalize.go when kind is dns#policy (similar logic to managedZoneId).
  • In func (a *DNSPolicyAdapter) Update, set desired.Id = a.actual.Id to work around the undocumented bug in the DNS update API where Id is required in update calls.
  • Add cnrm.cloud.google.com/deletion-policy: abandon on the kind: DNSPolicy test fixture objects to prevent deletion blocks from VPC networks in real GCP.
  • Update "not found" messages in mockgcp/mockdns/policy.go to follow the format "The 'parameters.policy' resource named 'dnspolicy-test-${uniqueId}' does not exist.".

Fixes #9593

- Normalize Id to ${dnsPolicyId} in mockdns/normalize.go when kind is dns#policy.
- In DNSPolicyAdapter Update, set desired.Id = a.actual.Id as a workaround for the DNS update API bug where Id is required.
- Add cnrm.cloud.google.com/deletion-policy: abandon on the DNSPolicy test fixture objects.
- Update NotFound error messages in mockdns/policy.go to match the expected format for dns policies.

Fixes GoogleCloudPlatform#9593
X-Xss-Protection: 0

{
"id": "000000000000000000000",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I was expecting this to be ${dnsPolicyId}. Let's also make sure that we are generating a "random" id in mockgcp also (we tend to just use the unix timestamp, it's random enough for a mock).

@codebot-robot codebot-robot removed their assignment Jun 9, 2026
@codebot-robot codebot-robot removed their assignment Jun 9, 2026

---

PATCH https://dns.googleapis.com/dns/v1beta2/projects/${projectId}/policies/dnspolicy-test-${uniqueId}?alt=json

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Oh I see - the old controller would clear the networks first. I like that approach, let's do that, then we don't need to mark the dns policy objects with abandon-on-delete

@codebot-robot codebot-robot removed their assignment Jun 9, 2026

if a.actual != nil && len(a.actual.Networks) > 0 {
log.V(2).Info("clearing networks for DNSPolicy before deletion", "name", a.id)
cleared := common.DeepCopy(a.actual)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It might be clearer if we wrote this one as a patch

@codebot-robot codebot-robot removed their assignment Jun 9, 2026

@justinsb justinsb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

/approve
/lgtm

@google-oss-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: justinsb

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

@justinsb
justinsb added this pull request to the merge queue Jun 9, 2026
Merged via the queue into GoogleCloudPlatform:master with commit 96670a6 Jun 9, 2026
177 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fixups to dnspolicy for realgcp

2 participants