fix(monitoring): guard against nil pointer in pooler PodMonitor template#841
Open
philippemnoel wants to merge 2 commits intocloudnative-pg:mainfrom
Open
fix(monitoring): guard against nil pointer in pooler PodMonitor template#841philippemnoel wants to merge 2 commits intocloudnative-pg:mainfrom
philippemnoel wants to merge 2 commits intocloudnative-pg:mainfrom
Conversation
When a pooler defines `monitoring.enabled: true` without a `podMonitor` sub-key, the template panics with a nil pointer error because Go templates evaluate all arguments to `and` before calling the function. Replace the single `and` chain with nested `if` blocks so that `.monitoring.podMonitor.enabled` is only evaluated when `.monitoring.podMonitor` is confirmed to be non-nil. Signed-off-by: Philippe Noël <philippemnoel@gmail.com>
Without asserting on status.readyInstances, the Chainsaw test can pass the Cluster assertion before all instances are ready, causing subsequent steps to fail intermittently. Signed-off-by: Philippe Noël <philippemnoel@gmail.com>
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.
Summary
podmonitor-pooler.yamlwhen a pooler definesmonitoring.enabled: truewithout apodMonitorsub-keyandbefore calling the function, so.monitoring.podMonitor.enabledis evaluated even when.monitoring.podMonitoris nil, causing a nil pointer panicandcheck with nestedifblocks so.monitoring.podMonitor.enabledis only evaluated when.monitoring.podMonitoris confirmed non-nilHow to reproduce
Define a pooler with monitoring enabled but without a
podMonitorkey:This produces: