Skip to content

fix: primary-resouce is created in wrong place.#6872

Merged
acornett21 merged 1 commit intooperator-framework:masterfrom
holyspectral:owner-reference
Jan 16, 2025
Merged

fix: primary-resouce is created in wrong place.#6872
acornett21 merged 1 commit intooperator-framework:masterfrom
holyspectral:owner-reference

Conversation

@holyspectral
Copy link
Contributor

Description of the change:

This PR fixes the issue where the primary custom resource would randomly get assigned "operator-sdk/primary-resource" and "operator-sdk/primary-resource-type" annotations when helm-operator is used.

Motivation for the change:

We use helm operator to deploy our software in OpenShift environment. However, our primary custom resource would get random annotations assigned , e.g.,

apiVersion: apm.neuvector.com/v1alpha1
kind: Neuvector
metadata:
  annotations:
    operator-sdk/primary-resource: /neuvector-binding-nvvulnerabilityprofiles
    operator-sdk/primary-resource-type: ClusterRoleBinding.rbac.authorization.k8s.io

The resource name and resource type would change randomly after each deployment.

After some debugging, it looks like handler.SetOwnerAnnotations()'s arguments are in reverse.

The caller:

err := handler.SetOwnerAnnotations(u, c.owner)

The function:

func SetOwnerAnnotations(owner, object client.Object)

This PR fixes the issue by correcting the order of arguments.

Checklist

If the pull request includes user-facing changes, extra documentation is required:

@holyspectral
Copy link
Contributor Author

Hi @rashmigottipati @oceanc80 , I wonder if any of you have time to check my PR? Thanks a lot.

@holyspectral
Copy link
Contributor Author

Hi @rashmigottipati @oceanc80 , please advise how to proceed in order for this PR to be merged. I will appreciate it.

@acornett21
Copy link
Contributor

@holyspectral Can you rebase your PR since there are failing tests?

When deployed with helm-operator, the primary custom resource would
randomly get assigned "operator-sdk/primary-resource" and
"operator-sdk/primary-resource-type" annotations.

This commit fixes the issue.

Signed-off-by: Sam Wang (holyspectral) <sam.wang@suse.com>
@holyspectral
Copy link
Contributor Author

@acornett21 thanks! I've rebased my PR, but the sanity/sanity still fails due to OPERATOR_SDK_VERSION unmatched. Would you advise how to fix them?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants