return create and sync error, not setStatus error (#2574)
* return create and sync error, not possible status set error * update documentation and improve deletion logs
This commit is contained in:
parent
a63a0758de
commit
8bd9080798
|
|
@ -339,10 +339,11 @@ configuration they are grouped under the `kubernetes` key.
|
||||||
cannot fully sync it, there can be leftovers. By enabling finalizers the
|
cannot fully sync it, there can be leftovers. By enabling finalizers the
|
||||||
operator will ensure all managed resources are deleted prior to the
|
operator will ensure all managed resources are deleted prior to the
|
||||||
Postgresql resource. There is a trade-off though: The deletion is only
|
Postgresql resource. There is a trade-off though: The deletion is only
|
||||||
performed at the next cluster SYNC cycle when finding a `deletionTimestamp`
|
performed after the next two SYNC cycles with the first one updating the
|
||||||
in the metadata and not immediately after issueing a delete command. The
|
internal spec and the latter reacting on the `deletionTimestamp` while
|
||||||
final removal of the custom resource will add a DELETE event to the worker
|
processing the SYNC event. The final removal of the custom resource will
|
||||||
queue but the child resources are already gone at this point.
|
add a DELETE event to the worker queue but the child resources are already
|
||||||
|
gone at this point.
|
||||||
The default is `false`.
|
The default is `false`.
|
||||||
|
|
||||||
* **enable_pod_disruption_budget**
|
* **enable_pod_disruption_budget**
|
||||||
|
|
|
||||||
|
|
@ -254,14 +254,18 @@ func (c *Cluster) Create() (err error) {
|
||||||
)
|
)
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
var pgUpdatedStatus *acidv1.Postgresql
|
var (
|
||||||
|
pgUpdatedStatus *acidv1.Postgresql
|
||||||
|
errStatus error
|
||||||
|
)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
pgUpdatedStatus, err = c.KubeClient.SetPostgresCRDStatus(c.clusterName(), acidv1.ClusterStatusRunning) //TODO: are you sure it's running?
|
pgUpdatedStatus, errStatus = c.KubeClient.SetPostgresCRDStatus(c.clusterName(), acidv1.ClusterStatusRunning) //TODO: are you sure it's running?
|
||||||
} else {
|
} else {
|
||||||
pgUpdatedStatus, err = c.KubeClient.SetPostgresCRDStatus(c.clusterName(), acidv1.ClusterStatusAddFailed)
|
c.logger.Warningf("cluster created failed: %v", err)
|
||||||
|
pgUpdatedStatus, errStatus = c.KubeClient.SetPostgresCRDStatus(c.clusterName(), acidv1.ClusterStatusAddFailed)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if errStatus != nil {
|
||||||
c.logger.Warningf("could not set cluster status: %v", err)
|
c.logger.Warningf("could not set cluster status: %v", errStatus)
|
||||||
}
|
}
|
||||||
if pgUpdatedStatus != nil {
|
if pgUpdatedStatus != nil {
|
||||||
c.setSpec(pgUpdatedStatus)
|
c.setSpec(pgUpdatedStatus)
|
||||||
|
|
|
||||||
|
|
@ -41,15 +41,18 @@ func (c *Cluster) Sync(newSpec *acidv1.Postgresql) error {
|
||||||
c.setSpec(newSpec)
|
c.setSpec(newSpec)
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
var pgUpdatedStatus *acidv1.Postgresql
|
var (
|
||||||
|
pgUpdatedStatus *acidv1.Postgresql
|
||||||
|
errStatus error
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.logger.Warningf("error while syncing cluster state: %v", err)
|
c.logger.Warningf("error while syncing cluster state: %v", err)
|
||||||
pgUpdatedStatus, err = c.KubeClient.SetPostgresCRDStatus(c.clusterName(), acidv1.ClusterStatusSyncFailed)
|
pgUpdatedStatus, errStatus = c.KubeClient.SetPostgresCRDStatus(c.clusterName(), acidv1.ClusterStatusSyncFailed)
|
||||||
} else if !c.Status.Running() {
|
} else if !c.Status.Running() {
|
||||||
pgUpdatedStatus, err = c.KubeClient.SetPostgresCRDStatus(c.clusterName(), acidv1.ClusterStatusRunning)
|
pgUpdatedStatus, errStatus = c.KubeClient.SetPostgresCRDStatus(c.clusterName(), acidv1.ClusterStatusRunning)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if errStatus != nil {
|
||||||
c.logger.Warningf("could not set cluster status: %v", err)
|
c.logger.Warningf("could not set cluster status: %v", errStatus)
|
||||||
}
|
}
|
||||||
if pgUpdatedStatus != nil {
|
if pgUpdatedStatus != nil {
|
||||||
c.setSpec(pgUpdatedStatus)
|
c.setSpec(pgUpdatedStatus)
|
||||||
|
|
|
||||||
|
|
@ -339,7 +339,6 @@ func (c *Controller) processEvent(event ClusterEvent) {
|
||||||
lg.Error(cl.Error)
|
lg.Error(cl.Error)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
lg.Infof("cluster has been deleted")
|
|
||||||
} else {
|
} else {
|
||||||
if err = cl.Sync(event.NewSpec); err != nil {
|
if err = cl.Sync(event.NewSpec); err != nil {
|
||||||
cl.Error = fmt.Sprintf("could not sync cluster: %v", err)
|
cl.Error = fmt.Sprintf("could not sync cluster: %v", err)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue