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 - acid.zalan.do
resources: resources:
- postgresqls - postgresqls
- postgresqls/status
- operatorconfigurations - operatorconfigurations
verbs: verbs:
- "*" - "*"
@ -137,7 +138,7 @@ rules:
- clusterroles - clusterroles
verbs: verbs:
- bind - bind
resourceNames: resourceNames:
- zalando-postgres-operator - 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) 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), // 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) // 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. // 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 { if err != nil {
c.logger.Errorf("could not update status: %v", err) c.logger.Errorf("could not update status: %v", err)
} }