Skip to content

Commit 7e9b97d

Browse files
GT-196 Update DeploymentReplicationStatus if configuring synchronisation errored (#1150)
1 parent 459fa3e commit 7e9b97d

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- (Feature) Remove stuck Pods
1414
- (Bugfix) Fix Go routine leak
1515
- (Feature) Extend Pod Security context
16+
- (Improvement) Update DeploymentReplicationStatus on configuration error
1617

1718
## [1.2.19](https://github.com/arangodb/kube-arangodb/tree/1.2.19) (2022-10-05)
1819
- (Bugfix) Prevent changes when UID is wrong

pkg/replication/deployment_replication.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,20 @@ func (dr *DeploymentReplication) failOnError(err error, msg string) {
342342
dr.reportFailedStatus()
343343
}
344344

345+
func (dr *DeploymentReplication) reportInvalidConfigError(isRecoverable bool, err error, msg string) {
346+
if !isRecoverable {
347+
dr.status.Phase = api.DeploymentReplicationPhaseFailed
348+
dr.status.Reason = fmt.Sprintf("%s: %s", msg, err.Error())
349+
}
350+
dr.status.Conditions.Update(api.ConditionTypeConfigured, false, api.ConditionConfiguredReasonInvalid, msg)
351+
if err = dr.updateCRStatus(); err != nil {
352+
dr.log.Err(err).Warn("Failed to update status")
353+
}
354+
}
355+
345356
// reportFailedStatus sets the status of the deployment replication to Failed and keeps trying to forward
346357
// that to the API server.
347358
func (dr *DeploymentReplication) reportFailedStatus() {
348-
dr.log.Info("local storage failed. Reporting failed reason...")
349359
repls := dr.deps.Client.Arango().ReplicationV1().ArangoDeploymentReplications(dr.apiObject.GetNamespace())
350360

351361
op := func() error {

pkg/replication/sync_inspector.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,9 @@ func (dr *DeploymentReplication) inspectDeploymentReplication(lastInterval time.
189189
} else {
190190
auth, err := dr.createArangoSyncTLSAuthentication(spec)
191191
if err != nil {
192-
dr.log.Err(err).Warn("Failed to configure synchronization authentication")
192+
msg := "Failed to configure synchronization authentication"
193+
dr.log.Err(err).Warn(msg)
194+
dr.reportInvalidConfigError(false, err, msg)
193195
hasError = true
194196
} else {
195197
req := client.SynchronizationRequest{
@@ -198,7 +200,9 @@ func (dr *DeploymentReplication) inspectDeploymentReplication(lastInterval time.
198200
}
199201
dr.log.Info("Configuring synchronization")
200202
if err := destClient.Master().Synchronize(ctx, req); err != nil {
201-
dr.log.Err(err).Warn("Failed to configure synchronization")
203+
msg := "Failed to configure synchronization"
204+
dr.log.Err(err).Warn(msg)
205+
dr.reportInvalidConfigError(true, err, msg)
202206
hasError = true
203207
} else {
204208
dr.log.Info("Configured synchronization")

0 commit comments

Comments
 (0)