Skip to content

Conversation

Nepoxx
Copy link
Contributor

@Nepoxx Nepoxx commented Aug 7, 2025

Description

The get_service_ip function was called unconditionally during master initialization but only defined when external access is enabled. This caused single-replica Redis deployments to fail during startup when using the default internal-only configuration.

The fix makes the initialization logic consistent with the comparison logic by using get_full_hostname when external access is disabled.

Description of the change

This change fixes a conditional logic mismatch in the Redis chart's startup script template. The get_service_ip() function was being called unconditionally during master initialization (line 158) but was only defined when sentinel.externalAccess.enabled is true. This caused Redis containers to fail during startup in single-replica deployments using the default configuration where external access is disabled.

The fix adds the same conditional logic used in the comparison section to the initialization section, ensuring consistency between initialization and comparison phases.

Benefits

  • Fixes Redis sentinel mode in single-replica deployments with default configuration
  • Maintains compatibility with existing multi-replica deployments
  • Ensures consistent conditional logic throughout the startup script
  • No breaking changes to existing functionality

Possible drawbacks

None identified. The change only affects the problematic code path and maintains all existing behavior for configurations where external access is enabled.

Applicable issues

This addresses startup failures in single-replica Redis deployments where sentinel is unable to promote the replica to master due to undefined function calls.

Additional information

The issue occurs specifically when:

  • replica.replicaCount: 1 (single replica)
  • sentinel.externalAccess.enabled: false (default configuration)

The fix ensures the startup script works correctly in both external access and internal-only configurations.

Checklist

  • Chart version bumped in Chart.yaml according to semver. This is not necessary when the changes only affect README.md files.
  • Variables are documented in the values.yaml and added to the README.md using readme-generator-for-helm
  • Title of the pull request follows this pattern [bitnami/<name_of_the_chart>] Descriptive title
  • All commits signed off and in agreement of Developer Certificate of Origin (DCO)

Technical Details

Root Cause

The bug existed in /bitnami/redis/templates/scripts-configmap.yaml at line 158:

master_in_persisted_conf="$(get_service_ip "$SVC_NAME")"

This line called get_service_ip() unconditionally, but the function was only defined when:

{{- if and .Values.sentinel.externalAccess.enabled .Values.sentinel.externalAccess.service.loadBalancerIP }}

Fix Applied

Changed the unconditional call to use the same conditional logic as the comparison section:

{{- if and .Values.sentinel.externalAccess.enabled .Values.sentinel.externalAccess.service.loadBalancerIP }}
master_in_persisted_conf="$(get_service_ip "$SVC_NAME")"
{{- else }}
master_in_persisted_conf="$(get_full_hostname "$HOSTNAME")"
{{- end }}

Tested Scenarios

  • ✅ Single replica with internal access (default)
  • ✅ Multiple replicas with internal access
  • ✅ Single/multiple replicas with external access

@github-actions github-actions bot added redis triage Triage is needed labels Aug 7, 2025
@github-actions github-actions bot requested a review from carrodher August 7, 2025 19:21
@Nepoxx Nepoxx marked this pull request as ready for review August 7, 2025 19:21
@Nepoxx Nepoxx force-pushed the main branch 2 times, most recently from b0c7612 to cf12a84 Compare August 7, 2025 19:45
@carrodher carrodher added verify Execute verification workflow for these changes in-progress labels Aug 8, 2025
@github-actions github-actions bot removed the triage Triage is needed label Aug 8, 2025
@github-actions github-actions bot removed the request for review from carrodher August 8, 2025 06:38
@github-actions github-actions bot requested a review from gongomgra August 8, 2025 06:38
@gongomgra
Copy link
Contributor

Hi @Nepoxx

Thanks for reporting this issue and for contributing with a solution! Can you please rebase your branch with updated main branch and fix the conflicts so we can merge your changes?

Nepoxx added 2 commits August 25, 2025 09:08
The get_service_ip function was called unconditionally during master
initialization but only defined when external access is enabled.
This caused single-replica Redis deployments to fail during startup
when using the default internal-only configuration.

The fix makes the initialization logic consistent with the comparison
logic by using get_full_hostname when external access is disabled.

Signed-off-by: Pier-Luc Gagnon <gagnon.pierluc@gmail.com>
Signed-off-by: Pier-Luc Gagnon <gagnon.pierluc@gmail.com>
bitnami-bot and others added 4 commits August 25, 2025 13:22
Signed-off-by: Bitnami Bot <bitnami.bot@broadcom.com>
Signed-off-by: Carlos Rodríguez Hernández <carlos.rodriguez-hernandez@broadcom.com>
Signed-off-by: Carlos Rodríguez Hernández <carlos.rodriguez-hernandez@broadcom.com>
Signed-off-by: Bitnami Bot <bitnami.bot@broadcom.com>
Copy link
Contributor

@gongomgra gongomgra left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution!

@gongomgra gongomgra merged commit 07a0857 into bitnami:main Aug 27, 2025
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
redis solved verify Execute verification workflow for these changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants