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

EIB helm chart logic breaks if "---" is present in the chart's Kubernetes resources #307

Closed
ipetrov117 opened this issue Mar 13, 2024 · 0 comments · Fixed by #310
Closed
Assignees
Labels
bug Something isn't working triaged The team has reviewed the issue
Milestone

Comments

@ipetrov117
Copy link
Contributor

ipetrov117 commented Mar 13, 2024

When you attempt to deploy a helm chart that has a Kubernetes resource that contains ---, the EIB helm chart decode logic breaks.

Below you can find an example of the problem by trying to deploy Rancher in a RKE2 cluster setup by EIB:

(1) Configure EIB to deploy Rancher through EIB's configuration file:

kubernetes:
  version: v1.27.11+rke2r1
  network:
    apiVIP: 192.168.122.117
  manifests:
    urls:
    - https://github.com/cert-manager/cert-manager/releases/download/v1.14.4/cert-manager.crds.yaml
  helm:
    charts:
    - name: cert-manager
      repositoryName: jetstack
      targetNamespace: cert-manager
      createNamespace: true
      version: v1.14.4
    - name: rancher
      repositoryName: rancher-stable
      targetNamespace: cattle-system
      createNamespace: true
      valuesFile: rancher-values.yaml
      version: 2.8.2
    repositories:
    - name: jetstack
      url: https://charts.jetstack.io/
    - name: rancher-stable
      url: https://releases.rancher.com/server-charts/stable

(2) rancher-values.yaml:

hostname: <rancher_host>
bootstrapPassword: <bootstrap_pass>

(3) Execute EIB container:

sudo podman run --rm --privileged -it -v <path_to_eib_dir>:/eib eib:dev build -definition-file <definition_file>.yaml -config-dir /eib -build-dir /eib/_build

Generating image customization components...
Identifier ................... [SUCCESS]
Custom Files ................. [SKIPPED]
Time ......................... [SKIPPED]
Network ...................... [SKIPPED]
Groups ....................... [SKIPPED]
Users ........................ [SUCCESS]
Proxy ........................ [SKIPPED]
Rpm .......................... [SKIPPED]
Systemd ...................... [SKIPPED]
Elemental .................... [SKIPPED]
Suma ......................... [SKIPPED]
Embedded Artifact Registry ... [FAILED ]
Error configuring customization components, check the logs under the build directory for more information.

(4) eib-build.log:

2024-03-13T13:52:27.148Z	WARN	kubernetes/cluster.go:103	Kubernetes config file '/eib/kubernetes/config/server.yaml' was not provided
2024-03-13T13:52:27.148Z	INFO	combustion/network.go:53	Configuring network component...
2024-03-13T13:52:27.148Z	INFO	combustion/network.go:57	Skipping network component, configuration is not provided
2024-03-13T13:52:27.149Z	INFO	combustion/rpm.go:32	Skipping RPM component. Configuration is not provided
2024-03-13T13:52:27.149Z	INFO	combustion/elemental.go:36	Skipping elemental registration component, configuration is not provided
2024-03-13T13:52:28.519Z	FATAL	build/build.go:92	An error occurred building the image: configuring combustion: configuring component "embedded artifact registry": configuring embedded artifact registry: parsing helm charts: handling chart resource: getting chart container images: templating chart: parsing chart contents: decoding resource from source ' Skip the app [${app}] in the namespace [${namespace}]"': yaml: unmarshal errors:
  line 1: cannot unmarshal !!str `continu...` into map[string]interface {}
github.com/suse-edge/edge-image-builder/pkg/cli/build.Run
	/src/pkg/cli/build/build.go:92
github.com/urfave/cli/v2.(*Command).Run
	/go/pkg/mod/github.com/urfave/cli/v2@v2.27.1/command.go:279
github.com/urfave/cli/v2.(*Command).Run
	/go/pkg/mod/github.com/urfave/cli/v2@v2.27.1/command.go:272
github.com/urfave/cli/v2.(*App).RunContext
	/go/pkg/mod/github.com/urfave/cli/v2@v2.27.1/app.go:337
github.com/urfave/cli/v2.(*App).Run
	/go/pkg/mod/github.com/urfave/cli/v2@v2.27.1/app.go:311
main.main
	/src/cmd/eib/main.go:18
runtime.main
	/usr/lib64/go/1.22/src/runtime/proc.go:271

(5) looking at the helm-template.log I can see the following resource that Rancher ships:

# Source: rancher/templates/post-delete-hook-config-map.yaml
apiVersion: v1
kind: ConfigMap
....
data:
  post-delete-hook.sh: |-
    #!/bin/bash
    
 ....
    for namespace in ${namespaces}; do
      for app in $(helm list -n "${namespace}" -q); do
        if [[ ${app} =~ .crd$ ]]; then
          echo "--- Skip the app [${app}] in the namespace [${namespace}]"
          continue
        fi
        echo "--- Deleting the app [${app}] in the namespace [${namespace}]"
        if [[ ! $(helm uninstall "${app}" -n "${namespace}") ]]; then
          failed=("${failed[@]}" "${app}")
          continue
        fi
    ....

It would seem that the post-delete-hook-config-map.yaml config map ships a script that uses the --- characters within its data. This results in the EIB logic breaking at the parseChartContents function, because it splits the chartContents by ---.

We should find a better delimiter for the chartContents than ---.

@ipetrov117 ipetrov117 added the bug Something isn't working label Mar 13, 2024
@atanasdinov atanasdinov added this to the 1.0.0 milestone Mar 13, 2024
@atanasdinov atanasdinov added the triaged The team has reviewed the issue label Mar 13, 2024
@dbw7 dbw7 mentioned this issue Mar 13, 2024
@dbw7 dbw7 closed this as completed in #310 Mar 13, 2024
@dbw7 dbw7 self-assigned this Mar 17, 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 triaged The team has reviewed the issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants