FIX: Preventing segfault when Cloudflare API limit is reached#1530
Merged
tlimoncelli merged 2 commits intoStackExchange:masterfrom Jun 9, 2022
Merged
FIX: Preventing segfault when Cloudflare API limit is reached#1530tlimoncelli merged 2 commits intoStackExchange:masterfrom
tlimoncelli merged 2 commits intoStackExchange:masterfrom
Conversation
Signed-off-by: Jan-Philipp Benecke <[email protected]>
Contributor
tlimoncelli
reviewed
Jun 8, 2022
| if resp, err := c.cfClient.CreateDNSRecord(context.Background(), domainID, cf); err != nil { | ||
| return err | ||
| } else { | ||
| id = resp.Result.ID |
Contributor
There was a problem hiding this comment.
I'm probably missing something obvious but why set a variable just before a "return nil" statement? I suspect either the id = or return nil isn't needed.
Collaborator
Author
There was a problem hiding this comment.
As far as i see, id = is required at L164 to enable the proxy mode. And return nil is required as the function for F requires a return type:
arr := []*models.Correction{{
Msg: fmt.Sprintf("CREATE record: %s %s %d%s %s", rec.GetLabel(), rec.Type, rec.TTL, prio, content),
F: func() error {}
})
Contributor
There was a problem hiding this comment.
OH! The "id" variable is stored outside of the function! I get it. It's being updated by side-effect.
Could you add a comment like, "Updating id (from the outer scope) by side-effect" for future me ("future me" has terrible memory).
Thanks!
Signed-off-by: Jan-Philipp Benecke <[email protected]>
tlimoncelli
approved these changes
Jun 9, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR prevents segfaults when the Cloudflare API limit (1.2k req per 5mins) is reached and should be handled correctly.
This PR partially fix #1440, DNSControl will no longer panic and provide a meaningful error message to the user.