mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-19 02:48:39 +02:00
use subresource when patching new status
This commit is contained in:
@@ -323,7 +323,7 @@ var postgresqlList = []struct {
|
|||||||
out PostgresqlList
|
out PostgresqlList
|
||||||
err error
|
err error
|
||||||
}{
|
}{
|
||||||
{[]byte(`{"apiVersion":"v1","items":[{"apiVersion":"acid.zalan.do/v1","kind":"Postgresql","metadata":{"labels":{"team":"acid"},"name":"acid-testcluster42","namespace":"default","resourceVersion":"30446957","selfLink":"/apis/acid.zalan.do/v1/namespaces/default/postgresqls/acid-testcluster42","uid":"857cd208-33dc-11e7-b20a-0699041e4b03"},"spec":{"allowedSourceRanges":["185.85.220.0/22"],"numberOfInstances":1,"postgresql":{"version":"9.6"},"teamId":"acid","volume":{"size":"10Gi"}},"status":"Running"}],"kind":"List","metadata":{},"resourceVersion":"","selfLink":""}`),
|
{[]byte(`{"apiVersion":"v1","items":[{"apiVersion":"acid.zalan.do/v1","kind":"Postgresql","metadata":{"labels":{"team":"acid"},"name":"acid-testcluster42","namespace":"default","resourceVersion":"30446957","selfLink":"/apis/acid.zalan.do/v1/namespaces/default/postgresqls/acid-testcluster42","uid":"857cd208-33dc-11e7-b20a-0699041e4b03"},"spec":{"allowedSourceRanges":["185.85.220.0/22"],"numberOfInstances":1,"postgresql":{"version":"9.6"},"teamId":"acid","volume":{"size":"10Gi"}},"status":{"PostgresClusterStatus":"Running"}}],"kind":"List","metadata":{},"resourceVersion":"","selfLink":""}`),
|
||||||
PostgresqlList{
|
PostgresqlList{
|
||||||
TypeMeta: metav1.TypeMeta{
|
TypeMeta: metav1.TypeMeta{
|
||||||
Kind: "List",
|
Kind: "List",
|
||||||
|
|||||||
@@ -159,11 +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)
|
||||||
}
|
}
|
||||||
|
|
||||||
patch := []byte(fmt.Sprintf(`{"status":{"PostgresClusterStatus": %s}}`, string(b)))
|
subresource := 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, patch)
|
newspec, err := c.KubeClient.AcidV1ClientSet.AcidV1().Postgresqls(c.clusterNamespace()).Patch(c.Name, types.MergePatchType, make([]byte, 0), subresource)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.logger.Errorf("could not update status: %v", err)
|
c.logger.Errorf("could not update status: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user