-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
fix(cloudflare): custom hostnames edge-cases causing duplicates #5183
fix(cloudflare): custom hostnames edge-cases causing duplicates #5183
Conversation
Hi @mrozentsvayg. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
/ok-to-test |
provider/cloudflare/cloudflare.go
Outdated
log.WithFields(logFields).Errorf("failed to delete custom hostname %v/%v: %v", chID, change.CustomHostname.Hostname, chErr) | ||
} | ||
} else { | ||
log.WithFields(logFields).Infof("Custom hostname %v not found", change.CustomHostname.Hostname) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.WithFields(logFields).Infof("Custom hostname %v not found", change.CustomHostname.Hostname) | |
log.WithFields(logFields).Warnf("Custom hostname %v not found", change.CustomHostname.Hostname) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%v -> %q in all kind of log message please!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%v -> %q in all kind of log message please!
Updated for Cloudflare provider.
There's still a logging inconsistency with the logrus's log.WithFields()
, looking like:
INFO[0001] Changing record. action=CREATE record=mih-cf-test-2.***.xyz ttl=1 type=A zone=***
INFO[0001] Creating custom hostname "mih-test-ch-1.***" action=CREATE record=mih-cf-test-2.*** ttl=1 type=A zone=***
INFO[0002] Changing record. action=CREATE record=a-mih-cf-test-2.*** ttl=1 type=TXT zone=***
If the consistent quoted output is a style policy goal, we could use log.SetFormatter(&log.TextFormatter{ForceQuote: true})
, eg:
diff --git a/provider/cloudflare/cloudflare.go b/provider/cloudflare/cloudflare.go
index 37847491..e4ce8697 100644
--- a/provider/cloudflare/cloudflare.go
+++ b/provider/cloudflare/cloudflare.go
@@ -249,6 +249,7 @@ func NewCloudFlareProvider(domainFilter endpoint.DomainFilter, zoneIDFilter prov
func (p *CloudFlareProvider) Zones(ctx context.Context) ([]cloudflare.Zone, error) {
result := []cloudflare.Zone{}
+ log.SetFormatter(&log.TextFormatter{ForceQuote: true})
// if there is a zoneIDfilter configured
// && if the filter isn't just a blank string (used in tests)
if len(p.zoneIDFilter.ZoneIDs) > 0 && p.zoneIDFilter.ZoneIDs[0] != "" {
@@ -361,6 +362,8 @@ func (p *CloudFlareProvider) ApplyChanges(ctx context.Context, changes *plan.Cha
// submitChanges takes a zone and a collection of Changes and sends them as a single transaction.
func (p *CloudFlareProvider) submitChanges(ctx context.Context, changes []*cloudFlareChange) error {
+ log.SetFormatter(&log.TextFormatter{ForceQuote: true})
+
// return early if there is nothing to change
if len(changes) == 0 {
log.Info("All records are already up to date")
@@ -385,7 +388,6 @@ func (p *CloudFlareProvider) submitChanges(ctx context.Context, changes []*cloud
"action": change.Action,
"zone": zoneID,
}
-
log.WithFields(logFields).Info("Changing record.")
if p.DryRun {
Should we go for it?
Hi. Could you share manifest to test edge cases? As well woul you be able to execute code coverage against modified lines in this pull request? |
The regular manifest before is as we previously discussed and as implemented in unit-tests:
The newly discovered edge-cases are caused by testing multi-cluster (GCP) configuration with the same Cloudflare zone and using TXT registry as a result. So latest addition to the manifest:
I'm looking closely at the coverage and making sure it's not getting any more relaxed on every change. |
bee85fc
to
12cce6f
Compare
…arate method submitCustomHostnameChanges(); extend truncated logging
/label tide/merge-method-squash |
Pulling this comment up from the thread. |
Consistency is nice. No strong opinion how it should or could be implemented. Most likely should be same for the whole project, and is most likely out of the scope for this PR |
…Hostname() for faster lookups
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
cc: @mloiseleur @szuecs
@mrozentsvayg I just have a last small change to suggest. BTW, we are looking for help to maintain this project. The process is documented here. If you are interested, please reach out (on kubernetes slack). |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ivankatliarchuk, mloiseleur The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Description
Fixes and improvements:
submitChanges()
custom hostnames related code to make contributions around it easier (eg. fix(cloudflare): regional hostnames #5175);There are still similar edge-cases that could cause one-time container crash. Not custom hostnames related.
Eg. manually removing or renaming A/CNAME record, but not TXT registry record would crash:
The one-time crashing could be intentional implementation of letting know that something has happened not quite gracefully, but not so sure about the CREATE->DELETE order on rename.
Checklist