Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@charlievieth
Copy link
Contributor

This commit changes the CNAME rewrite rule to use a pre-compiled regexp when the match type is RegexMatch instead of compiling it on-the-fly for each request. This will also allow for invalid regexp patterns to be identified during setup instead of causing a panic when the rule is first invoked.

1. Why is this pull request needed and what does it do?

This PR will increase the performance of the CNAME rewrite plugin when using a regex match and will allow for invalid regex patterns to be identified during plugin setup instead of causing a panic the first time the rewrite rule is invoked.

2. Which issues (if any) are related?

N/A

3. Which documentation changes (if any) need to be made?

N/A

4. Does this introduce a backward incompatible change or deprecation?

N/A

@charlievieth charlievieth force-pushed the cev/rewrite-cname-regex branch 2 times, most recently from 2b3c35d to cf3803b Compare November 19, 2025 22:21
This commit changes the CNAME rewrite rule to use a pre-compiled regexp
when the match type is RegexMatch instead of compiling it on-the-fly for
each request. This will also allow for invalid regexp patterns to be
identified during setup instead of causing a panic when the rule is
first invoked.

Signed-off-by: Charlie Vieth <[email protected]>
@charlievieth charlievieth force-pushed the cev/rewrite-cname-regex branch from cf3803b to 6db9f00 Compare November 19, 2025 23:12
@greenpau
Copy link
Collaborator

@charlievieth , pretty straightforward. Please recheck commit message, i.e. CNMAE vs CNAME.

@greenpau
Copy link
Collaborator

@charlievieth , out of curiosity, what prompted this PR?

@greenpau
Copy link
Collaborator

@johnbelamaric , check out @charlievieth on LinkedIn. Perhaps you could help him with an introduction. He is πŸ‘ to πŸ§‘β€πŸ­ and could be a good fit for G.

@charlievieth
Copy link
Contributor Author

charlievieth commented Nov 20, 2025

@charlievieth , out of curiosity, what prompted this PR?

Nothing production related, I was simply doing a code review of some of the plugins and saw that regexp.MustCompile was being called in a hot'ish path and that the pattern being passed was const to the cnameTargetRule.

Additionally, I saw that the other rewrite rules pre-compiled their regex's (when needed), which leads me to assume that pre-compilation is the norm (which I believe it should be).

@charlievieth charlievieth changed the title plugin/rewrite: pre-compile CNMAE rewrite regexp plugin/rewrite: pre-compile CNAME rewrite regexp Nov 20, 2025
@charlievieth
Copy link
Contributor Author

charlievieth commented Nov 20, 2025

@johnbelamaric , check out @charlievieth on LinkedIn. Perhaps you could help him with an introduction. He is πŸ‘ to πŸ§‘β€πŸ­ and could be a good fit for G.

ty and I am open to work and can be contacted at linkedin.com/in/charlievieth/ or my sign off email in the commit.

@greenpau greenpau merged commit 2883b63 into coredns:master Nov 20, 2025
11 checks passed
@greenpau
Copy link
Collaborator

@charlievieth , thank you for contributing!

@charlievieth charlievieth deleted the cev/rewrite-cname-regex branch November 20, 2025 03:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants