pulsar-resources-operator icon indicating copy to clipboard operation
pulsar-resources-operator copied to clipboard

v0.9.0 modifies custom resource spec

Open piotr-bzdyl-vertexinc opened this issue 8 months ago • 1 comments

After upgrading to v0.9.0 we have noticed that the operator modifies the spec of the custom resource, e.g. PulsarTopic. This causes endless competition between the operator and continuous deployment (e.g. FluxCD:

  • continuous deployment process ensures the resource matches the code from git
  • pulsar-resources-operator applies this change but modifies the spec part of the resource
  • continuous deployment process detects drift in the resource spec, thus it applies it again to match the code from git
  • pulsar-resources-operator detects the change in the resource and modifies the spec part again
  • and so on...

I was able to reproduce it with the following PulsarTopic applied by continuous deployment:

apiVersion: resource.streamnative.io/v1alpha1
kind: PulsarTopic
metadata:
  name: test-topic
spec:
  connectionRef:
    name: test-cluster
  name: persistent://test-tenant/test-ns/test-topic
  persistent: true
  retentionTime: 14d
  retentionSize: -1

The operator modifies it by adding spec.partitions: 0 and changing type of spec.retentionSize from int to string:

apiVersion: resource.streamnative.io/v1alpha1
kind: PulsarTopic
metadata:
  name: test-topic
spec:
  connectionRef:
    name: test-cluster
  name: persistent://test-tenant/test-ns/test-topic
  partitions: 0
  persistent: true
  retentionTime: 14d
  retentionSize: "-1"

We had also modifications made in the following PulsarTopic

apiVersion: resource.streamnative.io/v1alpha1
kind: PulsarTopic
metadata:
  name: test-topic
spec:
  connectionRef:
    name: test-cluster
  name: persistent://test-tenant/test-ns/test-topic
  persistent: true
  retentionTime: 14d
  retentionSize: -1
  schemaInfo:
    type: STRING
    schema: ""

In this case the operator deletes spec.schemaInfo.schema from the kubernetes resource:

apiVersion: resource.streamnative.io/v1alpha1
kind: PulsarTopic
metadata:
  name: test-topic
spec:
  connectionRef:
    name: test-cluster
  name: persistent://test-tenant/test-ns/test-topic
  partitions: 0
  persistent: true
  retentionTime: 14d
  retentionSize: "-1"
  schemaInfo:
    type: STRING

According to https://github.com/streamnative/pulsar-resources-operator/blob/main/docs/pulsar_topic.md#schemainfo spec.schemaInfo.schema is required, which is even more confusing.

piotr-bzdyl-vertexinc avatar Apr 17 '25 06:04 piotr-bzdyl-vertexinc

hi @piotr-bzdyl-vertexinc, the default value of partitions to 0, and the type of retentionSize as *resource.Quantity should have existed since very beginning. And *resource.Quantity as string should be a known issue from the kubernetes community, and the suggested solution is using string to retentionSize to prevent the Quantity type drift.

freeznet avatar Jun 27 '25 04:06 freeznet