Skip to content

[MOSIP-44613]Resolved code rabbit comments#192

Merged
bhumi46 merged 3 commits intomosip:developfrom
bhumi46:develop
Mar 30, 2026
Merged

[MOSIP-44613]Resolved code rabbit comments#192
bhumi46 merged 3 commits intomosip:developfrom
bhumi46:develop

Conversation

@bhumi46
Copy link
Copy Markdown
Member

@bhumi46 bhumi46 commented Mar 30, 2026

Summary by CodeRabbit

  • Bug Fixes

    • More robust CI profile detection with safer fallbacks, improved quoting, and explicit first-line selection; dispatched workflows now respect a propagated mode.
    • Shell hooks hardened: stricter namespace rewrites, clearer Redis timeout/failure reporting, safer secret/patch handling, and fixed logging path/newline handling.
  • Chores

    • Replaced literal placeholders with environment-variable substitution in Helm configs; Slack webhook now sourced from an env var; updated a referenced ConfigMap name.
    • Terraform: added ActiveMQ NFS hosts setting with validations, added MinIO subdomain, and tightened NFS export/validation and provisioning guards.

Signed-off-by: bhumi46 <thisisbn46@gmail.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 30, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d9812e15-de45-44bf-a447-765923d783e3

📥 Commits

Reviewing files that changed from the base of the PR and between 5caf0fb and 417374c.

📒 Files selected for processing (1)
  • terraform/modules/aws/activemq-setup/activemq-setup.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • terraform/modules/aws/activemq-setup/activemq-setup.sh

Walkthrough

Updates GitHub Actions profile auto-detection/quoting and dispatch MODE propagation; tightens DSF filename matching; applies Helm/YAML env-variable substitutions and path fixes; hardens hook scripts (sed/jq/patches, timeouts, decoding); and adds Terraform ActiveMQ NFS allowed-hosts variable, validations and wiring across modules.

Changes

Cohort / File(s) Summary
GitHub Actions Workflows
\.github/workflows/helmsman_esignet.yml, \.github/workflows/helmsman_external.yml, \.github/workflows/helmsman_mosip.yml, \.github/workflows/helmsman_testrigs.yml
Capture github.event.before/github.sha into BEFORE/SHA, fallback BEFOREHEAD~1 when empty/all-zero, quote git-diff args, use head -n 1, write PROFILE to GITHUB_ENV with quoting, and propagate MODE into downstream workflow dispatch inputs.
Helm DSF & release configs
Helmsman/dsf/.../prereq-dsf.yaml, Helmsman/dsf/.../esignet-dsf.yaml, Helmsman/dsf/.../testrigs-dsf.yaml
Replaced literal placeholders with env-var substitutions (${ISTIO_VERSION}, $CLUSTER_ID), fixed logging values path typo, tightened grep to \.-escaped DSF filenames, switched a ConfigMap name, and moved a Slack webhook to $SLACK_WEBHOOK_URL.
eSignet Hook Scripts
Helmsman/hooks/esignet-1.7.1/captcha-postinstall.sh, .../esignet-init-db.sh, .../esignet-preinstall.sh, .../keycloak-postinstall.sh, .../redis-setup.sh, .../softhsm-mock-identity-system-postinstall.sh
Added check/initialization for missing container env arrays, replaced global sed replacements with anchored/whitespace-tolerant regexes, made Helm secret-arg expansion conditional, switched jq to --arg form, increased Redis wait timeout and added explicit error path, and used echo -n to avoid trailing-newline in base64 decoding.
Terraform: variables, validations & wiring
terraform/implementations/aws/infra/profiles/*/aws.tfvars, terraform/implementations/aws/infra/variables.tf, terraform/implementations/aws/infra/main.tf, terraform/infra/*, terraform/infra/aws/*
Added activemq_nfs_allowed_hosts variable (default "*"), added validations for activemq_storage_device and activemq_mount_point, threaded new variable through module inputs and calls, and added minio to public subdomains in tfvars.
Terraform ActiveMQ module & automation
terraform/modules/aws/activemq-setup/main.tf, .../activemq-setup.sh, .../activemq-setup.yml
Exported/passed ACTIVEMQ_NFS_ALLOWED_HOSTS to setup script and Ansible, changed /etc/exports generation to use allowed-hosts token, removed no_root_squash, added pre-clean of stale /tmp/activemq-storageclass.yaml, and added post-Ansible existence/size guard and improved kubeconfig echo quoting.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • ckm007

Poem

"🐰 I hopped through hooks and TF trees,
Quoted vars and sed with ease,
Profiles found when git was shy,
NFS gates set to watch the sky,
I patch, I test, then nibble cheese."

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title references resolving code review comments but lacks specificity about what was actually changed across 26+ files in this PR. Provide a more descriptive title that summarizes the main changes, such as 'Add ActiveMQ NFS host validation and improve workflow robustness' or similar that captures the core updates.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 11

🧹 Nitpick comments (2)
Helmsman/hooks/esignet-1.7.1/esignet-preinstall.sh (1)

52-54: Consistent pattern applied across all copy operations.

All five namespace substitutions in this file now use the anchored regex pattern.

Note: Per the relevant code snippets, other scripts in this directory (softhsm-esignet-postinstall.sh, redis-setup.sh) and the shared utility copy_cm_func.sh still use the older unanchored pattern. Consider updating those for consistency in a follow-up PR.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Helmsman/hooks/esignet-1.7.1/esignet-preinstall.sh` around lines 52 - 54,
Update all five namespace copy operations in esignet-preinstall.sh to use the
anchored sed regex pattern; specifically, in each kubectl ... get configmap ...
| sed ... | kubectl ... pipeline replace the older unanchored substitution with
the anchored form used in the diff (use s|^\(\s*namespace:\) $POSTGRES_NS$|\1
$ESIGNET_NS| style), making sure to reference the variables POSTGRES_NS and
ESIGNET_NS and preserve quoting and escaping in the sed expression so the
namespace key is matched only at the start of the line.
terraform/modules/aws/activemq-setup/activemq-setup.sh (1)

120-126: Consider moving this manifest check to a per-run path.

/tmp/activemq-storageclass.yaml is shared runner state, while the rest of this script already uses a unique $WORK_DIR. Writing and checking the manifest under $WORK_DIR would avoid stale-file/concurrent-apply collisions and make this guard prove that the current run produced the artifact. That would need the same path wired through activemq-setup.yml and main.tf.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@terraform/modules/aws/activemq-setup/activemq-setup.sh` around lines 120 -
126, The storageClass manifest check currently reads
/tmp/activemq-storageclass.yaml which can collide across concurrent runs; update
the check to use the run-specific path under $WORK_DIR (the same path used
elsewhere in this script) so the guard validates the artifact produced by this
run. Modify the script location that writes/reads the manifest and update the
callers/configs that reference it (activemq-setup.yml and the Terraform module
invocation in main.tf) to pass the new $WORK_DIR-based path instead of the
hardcoded /tmp path, ensuring all places consistently use the unique per-run
filename.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/helmsman_external.yml:
- Around line 69-70: The PROFILE variable is being set to a newline-separated
list (PROFILE="$changed_profiles"), which breaks downstream use in the helmsman
invocation that expects a single profile; change the assignment so PROFILE
contains only a single profile (e.g., extract the first entry from
changed_profiles) or instead iterate over changed_profiles and invoke/dispatch
the downstream workflow once per profile; update the code that calls helmsman
(the command using $WORKDIR/dsf/${PROFILE}/mosip-dsf.yaml) to run for each
profile when iterating or to use the single extracted PROFILE value.

In `@Helmsman/dsf/mosip-platform-java11/prereq-dsf.yaml`:
- Around line 45-46: The two helm values grafana.global.cattle.clusterId and
global.cattle.clusterId reference an unset $CLUSTER_ID; define CLUSTER_ID in the
environment or provide a safe default before enabling rancher-monitoring. Fix by
either exporting CLUSTER_ID in your pipeline/CI env (or the chart values
provider) or replace the literal references with a fallback expression (e.g., a
default cluster id) so grafana.global.cattle.clusterId and
global.cattle.clusterId never resolve to an empty/undefined value when
rancher-monitoring is enabled.
- Around line 36-37: The Helmsman prereq uses ${ISTIO_VERSION}
(postInstall/postUpgrade in prereq-dsf.yaml) but ISTIO_VERSION isn't exported in
the workflow so it expands empty and the hook install-istio-and-httpbin.sh falls
back to "develop"; export ISTIO_VERSION (e.g., ISTIO_VERSION=1.22.0) to
$GITHUB_ENV in the "Setup kubectl, istioctl and kubeconfig" step of
helmsman_external.yml so Helmsman gets the value, and also export CLUSTER_ID to
$GITHUB_ENV in the "Initiate helmsman to apply the DSF configurations" step so
${CLUSTER_ID} is populated at runtime. Ensure the exported names match exactly
(ISTIO_VERSION, CLUSTER_ID) so prereq-dsf.yaml postInstall/postUpgrade and any
references to CLUSTER_ID receive the intended values.

In `@Helmsman/dsf/mosip-platform-java21/prereq-dsf.yaml`:
- Around line 45-46: The two entries grafana.global.cattle.clusterId and
global.cattle.clusterId are using an undefined literal "$CLUSTER_ID"; replace
those literal references with a proper templated value and ensure it's declared
in your chart values (for example change "$CLUSTER_ID" to a Helm template like
"{{ .Values.clusterId }}" or to the same variable used in the java11 fix), and
add clusterId to values.yaml (or export the environment variable where you do
string substitution) so the value is defined at deploy time.
- Around line 36-37: The postInstall/postUpgrade commands in prereq-dsf.yaml
reference an undefined ${ISTIO_VERSION} variable (see the
postInstall/postUpgrade entries), so update the GitHub Actions workflow that
runs this prereq to export ISTIO_VERSION into the environment by writing
ISTIO_VERSION=<value> to $GITHUB_ENV before the job/step that applies this YAML;
ensure the workflow sets the same variable name (ISTIO_VERSION) so the
manifest's ${ISTIO_VERSION} resolves at runtime.

In `@Helmsman/hooks/esignet-1.7.1/esignet-init-db.sh`:
- Around line 28-30: Update esignet-1.7.1/redis-setup.sh to use the same
anchored, POSIX-compatible sed pattern as esignet-init-db.sh: replace the older
global replacement sed invocation with one that anchors to the "namespace:" line
and uses [[:space:]]* (e.g., match "^\([[:space:]]*namespace:\) <old_ns>$" and
substitute the new namespace), preserving the variable usage for current and
target namespaces and piping/kubectl logic exactly as in esignet-init-db.sh so
the change is consistent and safe across shell environments.

In `@Helmsman/hooks/esignet-1.7.1/redis-setup.sh`:
- Around line 23-24: The current kubectl wait command for Redis pods (kubectl -n
"$REDIS_NS" wait --for=condition=ready pod -l app.kubernetes.io/name=redis
--timeout=300s || echo "WARNING: Redis pods not ready after timeout,
continuing") silently continues on timeout which can hide deployment failures
for services in $ESIGNET_NS; change this to fail-fast or at least surface to
stderr and match Helmsman timing: either remove the "|| echo ..." and let the
script exit non‑zero on failure, or replace the echo with a stderr log (echo
"... " >&2) and an explicit exit 1; alternatively align the timeout with
Helmsman (480s) or implement a simple retry/backoff loop around kubectl wait to
give Redis more time before exiting.

In `@terraform/implementations/aws/infra/profiles/esignet/aws.tfvars`:
- Line 80: subdomain_public currently includes "minio" which exposes MinIO
publicly while the consumer esignet-resident-oidc-partner-onboarder is disabled;
either remove "minio" from subdomain_public to keep MinIO internal-only, or
enable partner-onboarder in esignet-dsf.yaml and ensure secure S3 creds (replace
s3-user-key: "admin" with proper secret management); also update the profile
description to mention MinIO is deployed via external-dsf.yaml so documentation
reflects reality.

In `@terraform/implementations/aws/infra/variables.tf`:
- Around line 257-260: The current terraform validation for
var.activemq_mount_point only ensures it's non-empty and starts with "/", but it
must also forbid the root path "/" to prevent mounting/exporting the host root;
update the validation block (the condition for var.activemq_mount_point) to
require more than one character or explicitly check that
var.activemq_mount_point != "/" (while keeping the startswith check) so
activemq-setup.yml never receives "/" as the mount target/export path.
- Around line 247-250: The validation for var.activemq_storage_device currently
allows the bare string "/dev/"; update the validation condition in the
validation block for var.activemq_storage_device so it requires at least one
path segment after the "/dev/" prefix (e.g., require
length(var.activemq_storage_device) > length("/dev/") or use a regex that
matches "^/dev/[^/].+"). Ensure the error_message remains descriptive and that
the check references var.activemq_storage_device so malformed tfvars fail at
plan time.

In `@terraform/modules/aws/activemq-setup/activemq-setup.yml`:
- Around line 99-105: The playbook uses activemq_nfs_allowed_hosts but that
variable isn't exposed or passed through the module; add a module input variable
named activemq_nfs_allowed_hosts (with a sensible default like '*' or empty to
force explicit set) to the Terraform module interface, add the corresponding
variable in terraform/implementations/aws/infra/variables.tf, pass it through
wherever activemq-setup.sh is invoked (so the script can inject it into the
Ansible extra-vars), and ensure activemq-setup.sh forwards the value into the
Ansible run so activemq-setup.yml can consume activemq_nfs_allowed_hosts; update
any docs or defaults so the export allowlist is actually configurable.

---

Nitpick comments:
In `@Helmsman/hooks/esignet-1.7.1/esignet-preinstall.sh`:
- Around line 52-54: Update all five namespace copy operations in
esignet-preinstall.sh to use the anchored sed regex pattern; specifically, in
each kubectl ... get configmap ... | sed ... | kubectl ... pipeline replace the
older unanchored substitution with the anchored form used in the diff (use
s|^\(\s*namespace:\) $POSTGRES_NS$|\1 $ESIGNET_NS| style), making sure to
reference the variables POSTGRES_NS and ESIGNET_NS and preserve quoting and
escaping in the sed expression so the namespace key is matched only at the start
of the line.

In `@terraform/modules/aws/activemq-setup/activemq-setup.sh`:
- Around line 120-126: The storageClass manifest check currently reads
/tmp/activemq-storageclass.yaml which can collide across concurrent runs; update
the check to use the run-specific path under $WORK_DIR (the same path used
elsewhere in this script) so the guard validates the artifact produced by this
run. Modify the script location that writes/reads the manifest and update the
callers/configs that reference it (activemq-setup.yml and the Terraform module
invocation in main.tf) to pass the new $WORK_DIR-based path instead of the
hardcoded /tmp path, ensuring all places consistently use the unique per-run
filename.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0f74cac6-5ecc-4997-9d7c-9f2f59aa554b

📥 Commits

Reviewing files that changed from the base of the PR and between 1acf543 and 031fb74.

📒 Files selected for processing (19)
  • .github/workflows/helmsman_esignet.yml
  • .github/workflows/helmsman_external.yml
  • .github/workflows/helmsman_mosip.yml
  • .github/workflows/helmsman_testrigs.yml
  • Helmsman/dsf/mosip-platform-java11/prereq-dsf.yaml
  • Helmsman/dsf/mosip-platform-java21/esignet-dsf.yaml
  • Helmsman/dsf/mosip-platform-java21/prereq-dsf.yaml
  • Helmsman/dsf/mosip-platform-java21/testrigs-dsf.yaml
  • Helmsman/hooks/esignet-1.7.1/captcha-postinstall.sh
  • Helmsman/hooks/esignet-1.7.1/esignet-init-db.sh
  • Helmsman/hooks/esignet-1.7.1/esignet-preinstall.sh
  • Helmsman/hooks/esignet-1.7.1/keycloak-postinstall.sh
  • Helmsman/hooks/esignet-1.7.1/redis-setup.sh
  • Helmsman/hooks/esignet-1.7.1/softhsm-mock-identity-system-postinstall.sh
  • terraform/implementations/aws/infra/profiles/esignet/aws.tfvars
  • terraform/implementations/aws/infra/variables.tf
  • terraform/modules/aws/activemq-setup/activemq-setup.sh
  • terraform/modules/aws/activemq-setup/activemq-setup.yml
  • terraform/modules/aws/activemq-setup/main.tf

Signed-off-by: bhumi46 <thisisbn46@gmail.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
.github/workflows/helmsman_external.yml (1)

276-282: Payload construction is correct; consider quoting $GITHUB_REPO in URL.

The MODE propagation with ${MODE:-apply} default is properly implemented. Static analysis (SC2086) flags unquoted $GITHUB_REPO on line 281. While repository names don't contain spaces in practice, quoting it improves robustness.

🔧 Optional fix for shellcheck SC2086
         curl -X POST \
           -H "Accept: application/vnd.github+json" \
           -H "Authorization: Bearer $GITHUB_TOKEN" \
           -H "X-GitHub-Api-Version: 2022-11-28" \
-          https://api.github.com/repos/$GITHUB_REPO/actions/workflows/helmsman_mosip.yml/dispatches \
+          "https://api.github.com/repos/$GITHUB_REPO/actions/workflows/helmsman_mosip.yml/dispatches" \
           -d '{"ref":"'"$BRANCH"'","inputs":{"mode":"'"${MODE:-apply}"'","profile":"'"${{ needs.set-matrix.outputs.profile }}"'"}}'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/helmsman_external.yml around lines 276 - 282, The curl
invocation is using an unquoted $GITHUB_REPO in the dispatch URL which triggers
shellcheck SC2086; update the run block so the URL uses a quoted repository
variable (replace $GITHUB_REPO with "${GITHUB_REPO}") in the
https://api.github.com/repos/.../actions/workflows/helmsman_mosip.yml/dispatches
call to prevent word-splitting and globbing while leaving the rest (including
"${BRANCH}" and the JSON payload) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@terraform/implementations/aws/infra/profiles/mosip/aws.tfvars`:
- Line 111: The activemq_nfs_allowed_hosts variable is set to "*" which is
overly permissive; replace the wildcard with a restricted CIDR or host list
(e.g., the cluster CIDR such as "10.0.0.0/8" or the specific application subnet)
and remove the "*" default; update the activemq_nfs_allowed_hosts assignment to
a concrete CIDR or variable reference (e.g., use a cluster_cidr variable) so
only trusted IP ranges can mount the NFS export and adjust the inline comment to
reflect the new restricted value.

In `@terraform/implementations/aws/infra/variables.tf`:
- Around line 265-269: The variable activemq_nfs_allowed_hosts currently accepts
any string; add a Terraform validation block on variable
"activemq_nfs_allowed_hosts" that enforces allowed formats (accept "*" or a
single IP, CIDR, hostname, or a comma-separated list of those) using a regex
condition and a clear error message; implement this by adding a validation {
condition =
can(regex("^(\\*|([0-9]{1,3}(\\.[0-9]{1,3}){3}(\\/\\d{1,2})?|[A-Za-z0-9.-]+)(,([0-9]{1,3}(\\.[0-9]{1,3}){3}(\\/\\d{1,2})?|[A-Za-z0-9.-]+))*)$",
var.activemq_nfs_allowed_hosts)) error = "activemq_nfs_allowed_hosts must be '*'
or an IP/CIDR/hostname or a comma-separated list of those." } inside the
variable block so malformed values cannot be applied.

---

Nitpick comments:
In @.github/workflows/helmsman_external.yml:
- Around line 276-282: The curl invocation is using an unquoted $GITHUB_REPO in
the dispatch URL which triggers shellcheck SC2086; update the run block so the
URL uses a quoted repository variable (replace $GITHUB_REPO with
"${GITHUB_REPO}") in the
https://api.github.com/repos/.../actions/workflows/helmsman_mosip.yml/dispatches
call to prevent word-splitting and globbing while leaving the rest (including
"${BRANCH}" and the JSON payload) unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 5df0f94a-670b-41e7-b98d-20038ef3e1bb

📥 Commits

Reviewing files that changed from the base of the PR and between 031fb74 and 5caf0fb.

📒 Files selected for processing (12)
  • .github/workflows/helmsman_external.yml
  • Helmsman/hooks/esignet-1.7.1/redis-setup.sh
  • terraform/implementations/aws/infra/main.tf
  • terraform/implementations/aws/infra/profiles/esignet/aws.tfvars
  • terraform/implementations/aws/infra/profiles/mosip/aws.tfvars
  • terraform/implementations/aws/infra/variables.tf
  • terraform/infra/aws/main.tf
  • terraform/infra/aws/variables.tf
  • terraform/infra/main.tf
  • terraform/infra/variables.tf
  • terraform/modules/aws/activemq-setup/activemq-setup.sh
  • terraform/modules/aws/activemq-setup/main.tf
🚧 Files skipped from review as they are similar to previous changes (3)
  • Helmsman/hooks/esignet-1.7.1/redis-setup.sh
  • terraform/modules/aws/activemq-setup/main.tf
  • terraform/implementations/aws/infra/profiles/esignet/aws.tfvars

Signed-off-by: bhumi46 <thisisbn46@gmail.com>
@bhumi46 bhumi46 merged commit 65e320b into mosip:develop Mar 30, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant