pravega / zookeeper-operator

Kubernetes Operator for Zookeeper
Apache License 2.0
368 stars 206 forks source link

Fix #474: Svc Annotations created but not updated #492

Closed hoyhbx closed 2 years ago

hoyhbx commented 2 years ago

Change log description

Purpose of the change

Fix #474, now service annotations are not only created but also updated.

What the code does

We added one line of code in the function to update annotations.

curr.SetAnnotations(next.GetAnnotations())

How to verify it

  1. Build the image and deploy the operator

  2. Deploy a zookeeper instance with no annotations specified

    apiVersion: zookeeper.pravega.io/v1beta1
    kind: ZookeeperCluster
    metadata:
      name: zookeeper
    spec:
      replicas: 3
  3. Execute kubectl get svc/zookeeper-headless -o yaml and observe that this service does not have any annotations.

    apiVersion: v1
    kind: Service
    metadata:
      creationTimestamp: "2022-08-01T21:56:06Z"
      labels:
        app: zookeeper
        headless: "true"
        owner-rv: "1474"
        release: zookeeper
      name: zookeeper-headless
      namespace: default
      ownerReferences:
      - apiVersion: zookeeper.pravega.io/v1beta1
    ...
  4. Now, update this zookeeper instance by adding domainName: hgvkbmxwtg to our CR.

    apiVersion: zookeeper.pravega.io/v1beta1
    kind: ZookeeperCluster
    metadata:
      name: zookeeper
    spec:
      domainName: hgvkbmxwtg
      replicas: 3
  5. Execute kubectl get sec/zookeeper-headless -o yaml and observe that this service now has the expected annotation.

    $ kubectl get svc/zookeeper-headless -o yaml
    apiVersion: v1
    kind: Service
    metadata:
      annotations:
        external-dns.alpha.kubernetes.io/hostname: zookeeper-headless.hgvkbmxwtg.
      creationTimestamp: "2022-08-01T21:56:06Z"
      labels:
        app: zookeeper
        headless: "true"
        owner-rv: "1474"
        release: zookeeper
      name: zookeeper-headless
      namespace: default
      ownerReferences:
      - apiVersion: zookeeper.pravega.io/v1beta1
    ...
codecov[bot] commented 2 years ago

Codecov Report

Merging #492 (fa3e23b) into master (2403ac5) will increase coverage by 0.00%. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #492   +/-   ##
=======================================
  Coverage   85.04%   85.05%           
=======================================
  Files          12       12           
  Lines        1605     1606    +1     
=======================================
+ Hits         1365     1366    +1     
  Misses        155      155           
  Partials       85       85           
Impacted Files Coverage Δ
pkg/zk/synchronizers.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2403ac5...fa3e23b. Read the comment docs.