-
Notifications
You must be signed in to change notification settings - Fork 23
[MOSIP-43841] Changes related to alerting setup via rapid deployment. #117
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
base: develop
Are you sure you want to change the base?
Conversation
Signed-off-by: Mohan E <mohanraj1715@gmail.com>
Signed-off-by: Mohan E <mohanraj1715@gmail.com>
Signed-off-by: Mohan E <mohanraj1715@gmail.com>
Signed-off-by: Mohan E <mohanraj1715@gmail.com>
WalkthroughThis PR refactors hardcoded configuration values in Helmsman deployment files and hook scripts, replacing concrete values (cluster IDs, Slack credentials, channel names, environment identifiers) with template placeholders, enabling environment-specific configuration during deployment. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
Helmsman/hooks/alerting-setup.sh (1)
17-19: Non-idempotent in-place file modifications may cause issues on credential rotation or redeploy.The
sed -icommands modify alertmanager.yaml and patch-cluster-name.yaml in-place. This works correctly for the first invocation, but subsequent runs with different credentials will not find the original placeholders to replace, potentially leaving stale values in place.Recommended mitigation: Consider one of the following:
- Regenerate template files before each sed run — ensure alertmanager.yaml and patch-cluster-name.yaml are restored to their template state (with placeholders) before this hook executes.
- Use intermediate copies — apply sed to temporary copies and patch from those, or use kubectl create/replace with stdin instead of modifying source files.
- Document the expectation — clarify that the rapid deployment pattern assumes fresh file state per invocation.
For a true multi-environment or credential-rotation scenario, approach #1 is preferable.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
Helmsman/dsf/prereq-dsf.yaml(1 hunks)Helmsman/hooks/alerting-setup.sh(1 hunks)Helmsman/utils/alerting/alertmanager.yaml(2 hunks)Helmsman/utils/alerting/patch-cluster-name.yaml(1 hunks)
🔇 Additional comments (11)
Helmsman/utils/alerting/patch-cluster-name.yaml (1)
3-3: Placeholder introduction aligns with templating strategy.The hardcoded cluster name is properly replaced with a placeholder that will be substituted at runtime by the alerting-setup.sh hook (line 19 of that script).
Helmsman/utils/alerting/alertmanager.yaml (2)
4-4: Slack API URL placeholder introduced correctly.The hardcoded URL is replaced with
<YOUR-SLACK-API-URL>, which will be substituted by alerting-setup.sh line 18.
107-107: Slack channel placeholder introduced correctly.The hardcoded channel is replaced with
<YOUR-CHANNEL-HERE>, which will be substituted by alerting-setup.sh line 17.Helmsman/dsf/prereq-dsf.yaml (3)
45-46: Cluster ID placeholders align with templating approach.Both
grafana.global.cattle.clusterIdandglobal.cattle.clusterIdare correctly updated to use the<cluster-id>placeholder, which users should replace with their actual cluster identifier before deployment.
48-48: Trailing whitespace cleanup.Benign formatting improvement.
52-52: Verify: placeholders in postInstall hook require user substitution.The hook invocation passes
<slack-channel-name> <slack-api-url> <env-name>as placeholders that users must replace with actual values in their deployment configuration before running Helmsman. These three values directly map to positional parameters $1, $2, $3 expected by alerting-setup.sh (which uses them for sed substitutions in lines 17-19).Consider adding inline documentation to make this substitution requirement explicit, or verify whether these placeholders should be processed by a Helmsman template engine instead.
Helmsman/hooks/alerting-setup.sh (5)
9-11: Parameter-driven substitution enables flexible templating.The function now correctly receives Slack channel, API URL, and environment name as positional parameters ($1, $2, $3) instead of hardcoded defaults. This aligns with the Helmsman hook invocation pattern in prereq-dsf.yaml line 52.
17-19: Sed substitution patterns correctly match placeholder names.The sed patterns precisely target the placeholder strings in the template files:
- Line 17:
<YOUR-CHANNEL-HERE>→ alertmanager.yaml line 107 ✓- Line 18:
<YOUR-SLACK-API-URL>→ alertmanager.yaml line 4 ✓- Line 19:
<YOUR-CLUSTER-NAME-HERE>→ patch-cluster-name.yaml line 3 ✓All placeholders are properly accounted for.
24-24: kubectl patch operations use sed-modified files correctly.Both kubectl patch commands (lines 24 and 28) operate on files that have been substituted with actual values by the preceding sed operations (lines 17-19). The patch flow is correct.
Also applies to: 28-28
35-39: Comprehensive error handling configuration.The error handling is well-configured with
set -e,set -o nounset,set -o errtrace, andset -o pipefail. This ensures the script fails loudly on undefined variables or command failures rather than silently proceeding with invalid state.
9-11: Validate sed handling of special characters in credentials.If Slack URLs or channel names contain sed metacharacters (e.g.,
|,&,\,/), the substitution may fail or produce incorrect results. The current sed delimiter (|) is a reasonable choice to avoid conflicts with URLs (which contain/), but verify that:
- Slack webhook URLs do not contain literal
|characters- Channel names do not contain literal
|charactersAlternatively, consider escaping the variables or using a different delimiter if special characters are expected.
Also applies to: 17-19
ckm007
left a comment
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.
Need documentation aroind clusterid and slack url in README.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.