use subresource when patching new status
This commit is contained in:
		
							parent
							
								
									48e184d98e
								
							
						
					
					
						commit
						7e356a15c7
					
				|  | @ -323,7 +323,7 @@ var postgresqlList = []struct { | |||
| 	out PostgresqlList | ||||
| 	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{ | ||||
| 			TypeMeta: metav1.TypeMeta{ | ||||
| 				Kind:       "List", | ||||
|  |  | |||
|  | @ -159,11 +159,12 @@ func (c *Cluster) setStatus(status acidv1.PostgresClusterStatus) { | |||
| 		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),
 | ||||
| 	// 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, patch) | ||||
| 	newspec, err := c.KubeClient.AcidV1ClientSet.AcidV1().Postgresqls(c.clusterNamespace()).Patch(c.Name, types.MergePatchType, make([]byte, 0), subresource) | ||||
| 	if err != nil { | ||||
| 		c.logger.Errorf("could not update status: %v", err) | ||||
| 	} | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue