Skip to content

Commit 5b720d2

Browse files
authored
Merge pull request #338 from arangodb/bug-fix/force-status-reload
Fix Reload
2 parents 32ac512 + 71ba8b0 commit 5b720d2

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-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 custom resource.
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: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ func (d *Deployment) handleArangoDeploymentUpdatedEvent() error {
289289
newAPIObject := current.DeepCopy()
290290
newAPIObject.Spec.SetDefaultsFrom(specBefore)
291291
newAPIObject.Spec.SetDefaults(d.apiObject.GetName())
292-
newAPIObject.Status = status
292+
293293
resetFields := specBefore.ResetImmutableFields(&newAPIObject.Spec)
294294
if len(resetFields) > 0 {
295295
log.Debug().Strs("fields", resetFields).Msg("Found modified immutable fields")
@@ -318,6 +318,11 @@ func (d *Deployment) handleArangoDeploymentUpdatedEvent() error {
318318
// Save updated accepted spec
319319
{
320320
status, lastVersion := d.GetStatus()
321+
if newAPIObject.Status.IsForceReload() {
322+
log.Warn().Msg("Forced status reload!")
323+
status = newAPIObject.Status
324+
status.ForceStatusReload = nil
325+
}
321326
status.AcceptedSpec = newAPIObject.Spec.DeepCopy()
322327
if err := d.UpdateStatus(status, lastVersion); err != nil {
323328
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)