Skip to content

flux-local is unable to resolve a HelmChart in a HelmRelease, expecting a HelmRepository #1094

Description

@polds

I have a HelmRelease that references a HelmChart (not a HelmRepository), that HelmChart does reference a HelmRepository.

It looks roughly like this:

---
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
  name: my-app
  namespace: default
spec:
  chartRef:
    kind: HelmChart
    name: ingress
    namespace: flux-system 
  releaseName: my-app
  targetNamespace: default
  # other configuration

---
apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmChart
metadata:
  name: ingress
  namespace: flux-system
spec:
  sourceRef:
    kind: HelmRepository
    name: my-chart
  chart: ingress
  version: "0.1.*"

---
apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository
metadata:
  name: my-chart
  namespace: flux-system
spec: {} # configuration

I do this so I can easily update the version for that HelmChart. However, when executing flux-local test I see an error that looks like this:

flux_local.exceptions.HelmException: Unable to find HelmRepository for flux-system-ingress/ingress for HelmRelease my-app

Interestingly it's looking for a HelmRepository named flux-system-ingress/ingress, when it should be flux-system/my-chart. It seems like flux-local is unable to resolve the path to the HelmRepository by way of the HelmChart, but also is appending the HelmChart name to the namespace ie flux-system + ingress.

Flux Local info

Version: allenporter/flux-local/action/test@d4ebcae7ae08c8c8b8b7c1f515cf86759f9ca950 # 8.1.0

Confirmed via both Github Action and direction invocation:

      - uses: allenporter/flux-local/action/test@d4ebcae7ae08c8c8b8b7c1f515cf86759f9ca950 # 8.1.0
        with:
          path: kubernetes/k3s/flux/bases
          enable-helm: true
flux-local test \
   --all-namespaces \
   --enable-helm \
   --path kubernetes/k3s/flux/bases \
   --verbose

Full stack trace:

release = HelmRelease(name='my-app', namespace='default', chart=HelmChart(name='ingress', version=None, repo_name='ingre...flux-system'}, disable_schema_validation=False, disable_openapi_validation=False)
repo = None
    def _chart_name(
        release: HelmRelease,
        repo: HelmRepository | OCIRepository | LocalGitRepository | None,
    ) -> str:
        """Return the helm chart name used for the helm template command."""
        if release.chart.repo_kind == OCI_REPOSITORY:
            if not repo:
                raise HelmException(
                    f"Unable to find OCIRepository for {release.chart.chart_name} for "
                    f"HelmRelease {release.name}"
                )
            if isinstance(repo, OCIRepository):
                return repo.url
            raise HelmException(
                f"HelmRelease {release.name} expected OCIRepository but got HelmRepository {repo.repo_name}"
            )
        if release.chart.repo_kind in (HELM_REPO_KIND, HELM_CHART):
            if not repo:
>               raise HelmException(
                    f"Unable to find HelmRepository for {release.chart.chart_name} for "
                    f"HelmRelease {release.name}"
                )
E               flux_local.exceptions.HelmException: Unable to find HelmRepository for flux-system-ingress/ingress for HelmRelease my-app
../../_actions/allenporter/flux-local/d4ebcae7ae08c8c8b8b7c1f515cf86759f9ca950/flux_local/helm.py:150: HelmException

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions