Skip to content

fix: Do not send patch request if there's no update on FirewallPolicyRule #4199

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

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
revert previous commit
  • Loading branch information
gemmahou committed Mar 31, 2025
commit 254b53c9a6a06354d344427bb29e43a7f78c9617
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"strconv"
"strings"

"github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct/common"

"google.golang.org/api/option"

gcp "cloud.google.com/go/compute/apiv1"
Expand Down Expand Up @@ -196,14 +198,14 @@ func (a *firewallPolicyRuleAdapter) Update(ctx context.Context, updateOp *direct
// See API doc: https://cloud.google.com/compute/docs/reference/rest/v1/firewallPolicies/patchRule#query-parameters
firewallPolicyRule.Priority = nil

//paths, err := common.CompareProtoMessage(firewallPolicyRule, a.actual, common.BasicDiff)
//if err != nil {
// return err
//}
//if len(paths) == 0 {
// log.V(2).Info("no field needs update", "name", a.id.String())
// return nil
//}
paths, err := common.CompareProtoMessage(firewallPolicyRule, a.actual, common.BasicDiff)
if err != nil {
return err
}
if len(paths) == 0 {
log.V(2).Info("no field needs update", "name", a.id.String())
return nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should not just return nil here. Instead, we want to call updateOp.UpdateStatus(ctx, status, nil) to make sure the status is updated. This is especially important for first time acquire.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated in #4369

}

updated := &computepb.FirewallPolicyRule{}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ kind: ComputeFirewallPolicyRule
metadata:
annotations:
cnrm.cloud.google.com/project-id: ${projectId}
test.cnrm.cloud.google.com/reconcile-cookie: (removed)
finalizers:
- cnrm.cloud.google.com/finalizer
- cnrm.cloud.google.com/deletion-defender
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ spec:
- "10.100.0.1/32"
priority: 9000
---
TEST: TOUCH
apiVersion: compute.cnrm.cloud.google.com/v1beta1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Have you confirmed that before your change, a PATCH is triggered in this test?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added this commit to collect log without this change. I added "TOUCH" test flag to trigger a reconcile and confirmed that PATCH is triggered in the log.

kind: ComputeFirewallPolicyRule
metadata:
Expand Down
Loading