Skip to content

Commit 589999d

Browse files
author
lamai93
committed
Added secret force-status-reload status field. ✌️
1 parent eed8ea1 commit 589999d

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

pkg/apis/deployment/v1alpha/deployment_status.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
package v1alpha
2424

25+
import "github.com/arangodb/kube-arangodb/pkg/util"
26+
2527
// DeploymentStatus contains the status part of a Cluster resource.
2628
type DeploymentStatus struct {
2729
// Phase holds the current lifetime phase of the deployment
@@ -56,6 +58,9 @@ type DeploymentStatus struct {
5658
// SecretHashes keeps a sha256 hash of secret values, so we can
5759
// detect changes in secret values.
5860
SecretHashes *SecretHashes `json:"secret-hashes,omitempty"`
61+
62+
// ForceStatusReload if set to true forces a reload of the status from the CR.
63+
ForceStatusReload *bool `json:"force-status-reload,omitempty"`
5964
}
6065

6166
// Equal checks for equality
@@ -72,3 +77,8 @@ func (ds *DeploymentStatus) Equal(other DeploymentStatus) bool {
7277
ds.AcceptedSpec.Equal(other.AcceptedSpec) &&
7378
ds.SecretHashes.Equal(other.SecretHashes)
7479
}
80+
81+
// IsForceReload returns true if ForceStatusReload is set to true
82+
func (ds *DeploymentStatus) IsForceReload() bool {
83+
return util.BoolOrDefault(ds.ForceStatusReload, false)
84+
}

pkg/apis/deployment/v1alpha/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/deployment/deployment.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,15 @@ func (d *Deployment) handleArangoDeploymentUpdatedEvent() error {
287287
specBefore = *status.AcceptedSpec.DeepCopy()
288288
}
289289
newAPIObject := current.DeepCopy()
290+
wasForceReload := false
291+
if newAPIObject.Status.IsForceReload() {
292+
newAPIObject.Status.ForceStatusReload = nil
293+
wasForceReload = true
294+
log.Warn().Msg("Forced status reload!")
295+
}
290296
newAPIObject.Spec.SetDefaultsFrom(specBefore)
291297
newAPIObject.Spec.SetDefaults(d.apiObject.GetName())
292-
newAPIObject.Status = status
298+
293299
resetFields := specBefore.ResetImmutableFields(&newAPIObject.Spec)
294300
if len(resetFields) > 0 {
295301
log.Debug().Strs("fields", resetFields).Msg("Found modified immutable fields")
@@ -318,6 +324,9 @@ func (d *Deployment) handleArangoDeploymentUpdatedEvent() error {
318324
// Save updated accepted spec
319325
{
320326
status, lastVersion := d.GetStatus()
327+
if wasForceReload {
328+
status = newAPIObject.Status
329+
}
321330
status.AcceptedSpec = newAPIObject.Spec.DeepCopy()
322331
if err := d.UpdateStatus(status, lastVersion); err != nil {
323332
return maskAny(fmt.Errorf("failed to update ArangoDeployment status: %v", err))

pkg/deployment/reconcile/action_remove_member.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ func (a *actionRemoveMember) Start(ctx context.Context) (bool, error) {
7070
if err := arangod.RemoveServerFromCluster(ctx, client.Connection(), driver.ServerID(m.ID)); err != nil {
7171
if !driver.IsNotFound(err) && !driver.IsPreconditionFailed(err) {
7272
return false, maskAny(errors.Wrapf(err, "Failed to remove server from cluster: %#v", err))
73+
} else {
74+
a.log.Warn().Msgf("ignoring error: %s", err.Error())
7375
}
7476
}
7577
}

0 commit comments

Comments
 (0)