operator-framework / operator-sdk

SDK for building Kubernetes applications. Provides high level APIs, useful abstractions, and project scaffolding.
https://sdk.operatorframework.io
Apache License 2.0
7.26k stars 1.75k forks source link

Operator helm not syncing on labels #6836

Open AkhileshK8y opened 2 months ago

AkhileshK8y commented 2 months ago

Bug Report

What did you do?

I created a nginy helm operator based on the docs. My watches yaml:

- group: demo.example.com
  version: v1alpha1
  kind: Nginy
  chart: helm-charts/nginy
  selector:
    matchLabels:
      syncMy: devOperator

I deployed 2 test object:

apiVersion: demo.example.com/v1alpha1
kind: Nginy
metadata:
  name: testa
  namespace:testa
  labels:
    syncMy: devOperator
spec:
  replicaCount: 3

and

apiVersion: demo.example.com/v1alpha1
kind: Nginy
metadata:
  name: testb
  namespace: testb
  labels:
    syncUr: devOperator
spec:
  replicaCount: 3

My Dockerfile

# Build the manager binary
FROM quay.io/operator-framework/helm-operator:v1.37.0

ENV HOME=/opt/helm
COPY watches.yaml ${HOME}/watches.yaml
COPY helm-charts  ${HOME}/helm-charts
WORKDIR ${HOME}

What did you expect to see?

I expected only testa object to get synced as only its label match. testb shouldn't sync.

What did you see instead? Under which circumstances?

However testb object is also getting synced. testb is syncing even if I change the label value. Things work fine if I change to v1.33.0 in my Dockerfile. Doesn't work with v1.35.0

Environment

Operator type: helm operator v1.37.0

Kubernetes cluster type: EKS

operator-sdk version: "v1.37.0", commit: "819984d4c1a51c8ff2ef6c23944554148ace0752", kubernetes version: "v1.29.0", go version: "go1.23.1", GOOS: "darwin", GOARCH: "amd64"

$ go version (if language is Go)

Client Version: v1.29.1 Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3 Server Version: v1.29.7-eks-a18cd3a

Possible Solution

My hunch is, it broke with below change: https://github.com/operator-framework/operator-sdk/commit/1fd7f4dafc954ecc79326d042b42e7d420699f44#diff-d47d8a84d35cfdd54322d503604e6ff0b2f5454d3f1133bfc4faa8faeb9b476d This change went in after v1.33.0 and changes label selector code.

Additional context

https://github.com/AkhileshK8y/nginy-operator My full code in case it helps.

pjestin-sym commented 3 days ago

I have the same issue, and this seems to happen when switching from version 1.16.0 to 1.36.1, so probably a regression, although that leaves a lot of versions to check 😬