extproc: load default config if file does not exist#376
Merged
mathetake merged 4 commits intoenvoyproxy:mainfrom Feb 19, 2025
Merged
extproc: load default config if file does not exist#376mathetake merged 4 commits intoenvoyproxy:mainfrom
mathetake merged 4 commits intoenvoyproxy:mainfrom
Conversation
nacx
commented
Feb 19, 2025
| return fmt.Errorf("failed to read the config file: %w", err) | ||
| } | ||
|
|
||
| cw.current = string(raw) |
Member
Author
There was a problem hiding this comment.
I changed the unmarshal method to return the raw contents as well so we don't have to read the file again when logging the diff.
nacx
commented
Feb 19, 2025
| type syncBuffer struct { | ||
| mu sync.RWMutex | ||
| b *bytes.Buffer | ||
| } |
Member
Author
There was a problem hiding this comment.
I'm not sure why this didn't fail before, but when running the unit tests I got data races in the buffer, between the message logs and the call to buf.String(). This should fix that.
mathetake
reviewed
Feb 19, 2025
mathetake
reviewed
Feb 19, 2025
Signed-off-by: Ignasi Barrera <ignasi@tetrate.io>
Signed-off-by: Ignasi Barrera <ignasi@tetrate.io>
mathetake
reviewed
Feb 19, 2025
| if err != nil && os.IsNotExist(err) { | ||
| // If the file does not exist, do not fail (which could lead to the extproc process to terminate) | ||
| // Instead, load the default configuration and keep running unconfigured | ||
| cfg, raw = filterapi.MustLoadDefaultConfig() |
Member
There was a problem hiding this comment.
need to clear err = nil now? not exist will end up captured in if err ! = nil below
Member
Author
There was a problem hiding this comment.
yes. when this method returned an error it made sense; not anymore. fixed
mathetake
pushed a commit
that referenced
this pull request
Feb 20, 2025
**Commit Message** extproc: remove noise when reloading config Reduce the noise when configuration is reloaded. Only print logs when the configuration actually changes and do not reload the default config on every tick. **Related Issues/PRs (if applicable)** Related to #376 **Special notes for reviewers (if applicable)** N/A --------- Signed-off-by: Ignasi Barrera <ignasi@tetrate.io>
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.
Commit Message
extproc: load default config if file does not exist
If the configuration file does not exist, let extproc run with the default configuration. This prevents the extproc process from terminating if the config does not exist, which is a valid use case when the extproc filter is used in conjunction with other control planes.
Related Issues/PRs (if applicable)
N/A
Special notes for reviewers (if applicable)
N/A