spike: reduce Monitoring Console restart churn from ConfigMap metadata updates#1731
spike: reduce Monitoring Console restart churn from ConfigMap metadata updates#1731vivekr-splunk wants to merge 2 commits intodevelopfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR optimizes Monitoring Console (MC) pod restart behavior during C3-style bring-up by switching from ConfigMap resourceVersion tracking to deterministic data hashing. This prevents unnecessary MC restarts when only ConfigMap metadata changes (not actual data).
Changes:
- Replaced ConfigMap resourceVersion with SHA256 data hash for the
monitoringConsoleConfigRevannotation - Added deterministic hash function that sorts keys to ensure consistent output regardless of map iteration order
- Added comprehensive unit tests for hash determinism and statefulset annotation behavior
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/splunk/enterprise/monitoringconsole.go | Implemented getMonitoringConsoleConfigDataHash() function and updated getMonitoringConsoleStatefulSet() to use data hash instead of resourceVersion |
| pkg/splunk/enterprise/monitoringconsole_test.go | Added tests for hash determinism (TestGetMonitoringConsoleConfigDataHash) and integration test verifying statefulset uses data hash (TestGetMonitoringConsoleStatefulSetUsesConfigDataHash) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // getMonitoringConsoleConfigDataHash returns a stable hash for MC configMap data. | ||
| // Hashing data (instead of configMap resourceVersion) avoids unnecessary MC restarts | ||
| // when only metadata changes. | ||
| func getMonitoringConsoleConfigDataHash(data map[string]string) string { |
There was a problem hiding this comment.
This looks like pretty general hashing mechanism, maybe we should move it to some util lib (common/util.go) or configmap specific one pkg/splunk/splkcontroller/configmap.go?
Signature would be func GetConfigMapDataHash(data map[string]string) string
Summary
monitoringConsoleConfigRevto a deterministic hash of MC ConfigMap dataWhy
During C3-style bring-up, MC can restart multiple times. One trigger is that annotation currently follows ConfigMap
resourceVersion, so metadata-only updates can force unnecessary restarts. This spike constrains restarts to effective data changes only.Testing