using status subresource

This commit is contained in:
Felix Kunde 2019-04-09 14:01:27 +02:00
parent 7e356a15c7
commit 407a05086e
2 changed files with 4 additions and 3 deletions

View File

@ -14,6 +14,7 @@ rules:
- acid.zalan.do
resources:
- postgresqls
- postgresqls/status
- operatorconfigurations
verbs:
- "*"
@ -137,7 +138,7 @@ rules:
- clusterroles
verbs:
- bind
resourceNames:
resourceNames:
- zalando-postgres-operator
---

View File

@ -159,12 +159,12 @@ func (c *Cluster) setStatus(status acidv1.PostgresClusterStatus) {
c.logger.Errorf("could not marshal status: %v", err)
}
subresource := fmt.Sprintf(`{"status":{"PostgresClusterStatus": %s}}`, string(b))
patch := []byte(fmt.Sprintf(`{"status":{"PostgresClusterStatus": %s}}`, string(b)))
// we cannot do a full scale update here without fetching the previous manifest (as the resourceVersion may differ),
// however, we could do patch without it. In the future, once /status subresource is there (starting Kubernets 1.11)
// we should take advantage of it.
newspec, err := c.KubeClient.AcidV1ClientSet.AcidV1().Postgresqls(c.clusterNamespace()).Patch(c.Name, types.MergePatchType, make([]byte, 0), subresource)
newspec, err := c.KubeClient.AcidV1ClientSet.AcidV1().Postgresqls(c.clusterNamespace()).Patch(c.Name, types.MergePatchType, patch, "status")
if err != nil {
c.logger.Errorf("could not update status: %v", err)
}