-
Notifications
You must be signed in to change notification settings - Fork 2k
Move proxy values balancing to the beginning of parsing #8133
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
Open
javorszky
wants to merge
32
commits into
main
Choose a base branch
from
feat/fixed-safe-buffer-config
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,434
−37
Open
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
252ee58
add helper function to enable proxy_buffers if proxy_buffer_size is e…
AlexFenlon 4d5a6d3
add a safe way to enable proxy_buffers and proxy_buffer_size
AlexFenlon 36ad41a
add `nginx.org/proxy-busy-buffers-size` annotation to ingress
AlexFenlon 0952f77
add `proxy-busy-buffer-size` to configmap, improve validation
AlexFenlon 5bea282
Merge remote-tracking branch 'refs/remotes/origin/main' into feat/saf…
AlexFenlon de8c064
rename ProxyBusyBufferSize to ProxyBusyBuffersSize to be more accurate
AlexFenlon ca2e16b
Add ProxyBusyBuffersSize to VirtualServer as `busy-buffers-size`
AlexFenlon 4162d5d
make validation better
AlexFenlon 7457a49
Merge branch 'main' into feat/safe-buffer-config
AlexFenlon 1bf7b14
make validation better
AlexFenlon 9cffde2
Merge remote-tracking branch 'origin/feat/safe-buffer-config' into fe…
AlexFenlon 10999ff
Update tests
AlexFenlon b9394c0
Update tests, improve validation
AlexFenlon 58fe7cd
fix validation
AlexFenlon 942f17d
Put back the proxy max temp filesize data
javorszky bd2cd8e
Create a new typed unit to store sizes and offsets
javorszky e2a9072
Move new units to internal configs
javorszky 22187df
Move data types to their own file in internal/validation
javorszky eb0098d
Move proxy units into common package
javorszky 4abb3cf
Adjust templates to make them pass
javorszky 64a401c
Normalise parsing of bad / unknown to mb
javorszky d8998cd
Return emptystring if numbersize is zero
javorszky cd5587b
Create BalanceProxy function and tests
javorszky af0aba1
Reconcile the proxy values after parsing them
javorszky aee9418
Fix logic in clamping behaviour
javorszky ed52d20
Fix tests, make another test parallel
javorszky 2a8287f
Account for proxies not being present if invalid
javorszky 254c261
Simplify tests for data types
javorszky ba838f0
Fix tests
javorszky 128e97a
Fix more tests
javorszky 0186bb5
Merge branch 'main' into feat/fixed-safe-buffer-config
javorszky c55f83d
Merge branch 'main' into feat/fixed-safe-buffer-config
javorszky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -335,12 +335,53 @@ func ParseConfigMap(ctx context.Context, cfgm *v1.ConfigMap, nginxPlus bool, has | |||||||||
} | ||||||||||
|
||||||||||
if proxyBuffers, exists := cfgm.Data["proxy-buffers"]; exists { | ||||||||||
cfgParams.ProxyBuffers = proxyBuffers | ||||||||||
proxyBuffersData, err := validation.NewNumberSizeConfig(proxyBuffers) | ||||||||||
if err != nil { | ||||||||||
wrappedError := fmt.Errorf("ConfigMap %s/%s: invalid value for 'proxy-buffers': %w", cfgm.GetNamespace(), cfgm.GetName(), err) | ||||||||||
|
||||||||||
nl.Errorf(l, "%s", wrappedError.Error()) | ||||||||||
eventLog.Event(cfgm, v1.EventTypeWarning, nl.EventReasonInvalidValue, wrappedError.Error()) | ||||||||||
configOk = false | ||||||||||
} else { | ||||||||||
cfgParams.ProxyBuffers = proxyBuffersData | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
if proxyBufferSize, exists := cfgm.Data["proxy-buffer-size"]; exists { | ||||||||||
cfgParams.ProxyBufferSize = proxyBufferSize | ||||||||||
proxyBufferSizeData, err := validation.NewSizeWithUnit(proxyBufferSize) | ||||||||||
if err != nil { | ||||||||||
nl.Errorf(l, "error parsing nginx.org/proxy-buffer-size: %s", err) | ||||||||||
} else { | ||||||||||
cfgParams.ProxyBufferSize = proxyBufferSizeData | ||||||||||
} | ||||||||||
// normalizedProxyBufferSize := validation.NormalizeBufferSize(proxyBufferSize) | ||||||||||
} | ||||||||||
|
||||||||||
// Proxy Busy Buffers Size uses only size format, like "8k". | ||||||||||
if proxyBusyBuffersSize, exists := cfgm.Data["proxy-busy-buffers-size"]; exists { | ||||||||||
proxyBusyBufferSizeUnit, err := validation.NewSizeWithUnit(proxyBusyBuffersSize) | ||||||||||
if err != nil { | ||||||||||
nl.Errorf(l, "error parsing nginx.org/proxy-busy-buffers-size: %s", err) | ||||||||||
} else { | ||||||||||
cfgParams.ProxyBusyBuffersSize = proxyBusyBufferSizeUnit | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
balancedProxyBuffers, balancedProxyBufferSize, balancedProxyBusyBufferSize, modifications, err := validation.BalanceProxyValues(cfgParams.ProxyBuffers, cfgParams.ProxyBufferSize, cfgParams.ProxyBusyBuffersSize) | ||||||||||
if err != nil { | ||||||||||
nl.Errorf(l, "error reconciling proxy_buffers, proxy_buffer_size, and proxy_busy_buffers_size values: %s", err.Error()) | ||||||||||
} | ||||||||||
cfgParams.ProxyBuffers = balancedProxyBuffers | ||||||||||
cfgParams.ProxyBufferSize = balancedProxyBufferSize | ||||||||||
cfgParams.ProxyBusyBuffersSize = balancedProxyBusyBufferSize | ||||||||||
|
||||||||||
if len(modifications) > 0 { | ||||||||||
for _, modification := range modifications { | ||||||||||
nl.Infof(l, "Changes made to proxy values: %s", modification) | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
// Normalise the three proxy buffer values across each other. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment doesn't add value as it just restates what the code above does. It should be removed or made more descriptive.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||
|
||||||||||
if proxyMaxTempFileSize, exists := cfgm.Data["proxy-max-temp-file-size"]; exists { | ||||||||||
cfgParams.ProxyMaxTempFileSize = proxyMaxTempFileSize | ||||||||||
|
@@ -408,7 +449,7 @@ func ParseConfigMap(ctx context.Context, cfgm *v1.ConfigMap, nginxPlus bool, has | |||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
_, err := parseConfigMapZoneSync(l, cfgm, cfgParams, eventLog, nginxPlus) | ||||||||||
_, err = parseConfigMapZoneSync(l, cfgm, cfgParams, eventLog, nginxPlus) | ||||||||||
if err != nil { | ||||||||||
configOk = false | ||||||||||
} | ||||||||||
|
Oops, something went wrong.
Oops, something went wrong.
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.
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.
This commented out code should be removed as it's not being used and adds clutter to the codebase.
Copilot uses AI. Check for mistakes.