Skip to content

Ansible-operator doesn't inject owner if the namespace is not set in manifest's metadata #5038

@bszeti

Description

@bszeti

Bug Report

What did you do?

Running a Helm chart from an ansible-operator using community.kubernetes.helm module.

What did you expect to see?

Owner reference is injected for the Helm Secret.

What did you see instead? Under which circumstances?

Owner reference is only injected for the resources created by the Helm chart, but not for the Secret containing Helm metadata (type helm.sh/release.v1). The Helm secret (release) is not removed when CR is deleted and the chart is not reinstalled when the CR is recreated.

Environment

Operator type:

/language ansible

Kubernetes cluster type:

On OpenShift 4.7.16

$ operator-sdk version
operator-sdk version: "v1.8.0", commit: "d3bd87c6900f70b7df618340e1d63329c7cd651e", kubernetes version: "v1.20.2", go version: "go1.16.4", GOOS: "darwin", GOARCH: "amd64"

$ go version (if language is Go)
go version go1.16.4 darwin/amd64

$ oc version
Client Version: 4.7.3
Server Version: 4.7.16
Kubernetes Version: v1.20.0+2817867

Possible Solution

The proxy inject injection code assumes that the metadata.namespace is set in the manifest. But in this case Helm does POST /api/v1/namespaces/mynamespace/secrets and doesn't set the namespace in metadata. Kubernetes accepts it, but the owner injection doesn't happen.

Additional context

Also tested and verified with latest operator-sdk.

depNamespace := mDep.GetNamespace()

Metadata

Metadata

Assignees

Labels

kind/bugCategorizes issue or PR as related to a bug.language/ansibleIssue is related to an Ansible operator project

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions