Skip to content
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

Helm upgrade with existingCommunicationsSecretName fails #1376

Closed
pkosiec opened this issue Feb 9, 2024 · 4 comments · Fixed by #1378
Closed

Helm upgrade with existingCommunicationsSecretName fails #1376

pkosiec opened this issue Feb 9, 2024 · 4 comments · Fixed by #1378
Assignees
Labels
bug Something isn't working
Milestone

Comments

@pkosiec
Copy link
Member

pkosiec commented Feb 9, 2024

Originally posted by @voriol in #1274 (comment)


When updating my helm chart to the latest version, 1.8.0 I got the following error:

Error: template: sre-botkube/charts/botkube/templates/persistent-config.yaml:6:23: executing "sre-botkube/charts/botkube/templates/persistent-config.yaml" at <index $secret.data "comm_config.yaml">: error calling index: index of untyped nil

Reviewing the latest changes I see that the line it refers to was changed in this commit

fdb389c#diff-e694b58be4de3f2b3d147e65317458bbbc0f5319bd07c703d80dc3b05bb5d1b7

Specifically, on line 6:

{{- $data := b64dec (index $secret.data "comm_config.yaml") -}}

This is the secret content:

apiVersion: v1
kind: Secret
metadata:
  name: botkube-communications
stringData:
  comm_config.yaml: |
    communications:
      default-group:
        ## Settings for Slack with Socket Mode.
        ...etc

I am doing something wrong?

Thanks

@pkosiec pkosiec self-assigned this Feb 9, 2024
@pkosiec pkosiec added bug Something isn't working needs-more-info Further information is needed labels Feb 9, 2024
@pkosiec
Copy link
Member Author

pkosiec commented Feb 9, 2024

Hey @voriol,

There might be a bug in the Helm chart when using existing secret. Unfortunately we're focused on different priorities and I think we won't be able to fix this issue in next few weeks. Here are the possible solutions/workarounds I can see:

  1. You might try migrating your instance to Botkube Cloud, which doesn't have this issue as it doesn't use the complex ConfigMap merging logic. It's free for a single cluster!
  2. Alternatively, you could switch to use built-in secret with platform details
  3. Or, if you have a bit of time and energy, you could contribute and investigate/fix the bug. That would be much appreciated 🙏 Here are a few tips:

You can clone the repo and try to modify the Helm chart in this place:
https://github.com/kubeshop/botkube/blob/main/helm/botkube/templates/persistent-config.yaml#L6

I didn't try it yet, but this could work:

 {{- if .Values.existingCommunicationsSecretName }}
   {{- $secret := lookup "v1" "Secret" .Release.Namespace .Values.existingCommunicationsSecretName | default dict  }}
-  {{- $data := b64dec (index $secret.data "comm_config.yaml") -}}
+  {{- $secretData := $secret.data | default dict -}}
+  {{- $data := b64dec (index $secretData "comm_config.yaml" | default "") -}}
   {{- $dataYaml := $data | fromYaml -}}
   {{- $communications =  $dataYaml.communications }}
 {{- end }}

Hope that helps. Cheers!

@voriol
Copy link
Contributor

voriol commented Feb 9, 2024

I'll try to take a look at it next week.

thanks @pkosiec

@pkosiec
Copy link
Member Author

pkosiec commented Feb 9, 2024

Perfect, thank you!

@voriol
Copy link
Contributor

voriol commented Feb 12, 2024

Hi @pkosiec, your solutions works fine!

 {{- if .Values.existingCommunicationsSecretName }}
   {{- $secret := lookup "v1" "Secret" .Release.Namespace .Values.existingCommunicationsSecretName | default dict  }}
-  {{- $data := b64dec (index $secret.data "comm_config.yaml") -}}
+  {{- $secretData := $secret.data | default dict -}}
+  {{- $data := b64dec (index $secretData "comm_config.yaml" | default "") -}}
   {{- $dataYaml := $data | fromYaml -}}
   {{- $communications =  $dataYaml.communications }}
 {{- end }}

I open the PR #1378

Thanks

@pkosiec pkosiec added this to the v1.9.0 milestone Feb 13, 2024
@pkosiec pkosiec removed the needs-more-info Further information is needed label Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants