Skip to content

Commit

Permalink
Update ZookeeperCluster resource status as needed (#37)
Browse files Browse the repository at this point in the history
* Update the staus size field

Signed-off-by: Olivier Bourgeois <[email protected]>

* Update the current size of cluster based on replica set status

Signed-off-by: Olivier Bourgeois <[email protected]>
  • Loading branch information
bourgeoisor authored and adrianmo committed Nov 8, 2018
1 parent 73660ba commit b4c1f5d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/zk/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,19 @@ func syncClusterSize(zk *v1beta1.ZookeeperCluster) (err error) {
return fmt.Errorf("failed to get stateful-set (%s): %v", sts.Name, err)
}

zk.Status.Size = int(sts.Status.Replicas)
err = sdk.Update(zk)
if err != nil {
return fmt.Errorf("failed to update project: %v", err)
}

if *sts.Spec.Replicas != zk.Spec.Size {
sts.Spec.Replicas = &(zk.Spec.Size)
err = sdk.Update(sts)
if err != nil {
return fmt.Errorf("failed to update size of stateful-set (%s): %v", sts.Name, err)
}
}

return nil
}

0 comments on commit b4c1f5d

Please sign in to comment.