diff --git a/pkg/deployment/deployment.go b/pkg/deployment/deployment.go index 3a553023b..20329edba 100644 --- a/pkg/deployment/deployment.go +++ b/pkg/deployment/deployment.go @@ -298,7 +298,7 @@ func (d *Deployment) handleArangoDeploymentUpdatedEvent() error { if err := newAPIObject.Spec.Validate(); err != nil { d.CreateEvent(k8sutil.NewErrorEvent("Validation failed", err, d.apiObject)) // Try to reset object - if err := d.updateCRSpec(d.apiObject.Spec); err != nil { + if err := d.updateCRSpec(d.apiObject.Spec, true); err != nil { log.Error().Err(err).Msg("Restore original spec failed") d.CreateEvent(k8sutil.NewErrorEvent("Restore original failed", err, d.apiObject)) } @@ -312,7 +312,7 @@ func (d *Deployment) handleArangoDeploymentUpdatedEvent() error { } // Save updated spec - if err := d.updateCRSpec(newAPIObject.Spec); err != nil { + if err := d.updateCRSpec(newAPIObject.Spec, true); err != nil { return maskAny(fmt.Errorf("failed to update ArangoDeployment spec: %v", err)) } // Save updated accepted spec @@ -387,11 +387,14 @@ func (d *Deployment) updateCRStatus(force ...bool) error { // Update the spec part of the API object (d.apiObject) // to the given object, while preserving the status. // On success, d.apiObject is updated. -func (d *Deployment) updateCRSpec(newSpec api.DeploymentSpec) error { +func (d *Deployment) updateCRSpec(newSpec api.DeploymentSpec, force ...bool) error { - if d.apiObject.Spec.Equal(&newSpec) { - // Nothing to update - return nil + if len(force) == 0 || !force[0] { + if d.apiObject.Spec.Equal(&newSpec) { + d.deps.Log.Debug().Msg("Nothing to update in updateCRSpec") + // Nothing to update + return nil + } } // Send update to API server diff --git a/tests/immutable_test.go b/tests/immutable_test.go index 74b56204a..9771b59f3 100644 --- a/tests/immutable_test.go +++ b/tests/immutable_test.go @@ -86,7 +86,7 @@ func TestImmutableFields(t *testing.T) { } return fmt.Errorf("StorageEngine not back to %s", api.StorageEngineRocksDB) }, revertTimeout); err != nil { - t.Errorf("StorageEngine parameter is immutable: %v", err) + t.Errorf("StorageEngine parameter is mutable: %v", err) } /* diff --git a/tests/upgrade_test.go b/tests/upgrade_test.go index f08f2c3d9..266d4aa77 100644 --- a/tests/upgrade_test.go +++ b/tests/upgrade_test.go @@ -33,14 +33,14 @@ import ( "github.com/dchest/uniuri" ) -func TestUpgradeClusterRocksDB33pto34p(t *testing.T) { - upgradeSubTest(t, api.DeploymentModeCluster, api.StorageEngineRocksDB, "arangodb/arangodb-preview:3.3", "arangodb/arangodb-preview:3.4") -} +// func TestUpgradeClusterRocksDB33pto34p(t *testing.T) { +// upgradeSubTest(t, api.DeploymentModeCluster, api.StorageEngineRocksDB, "arangodb/arangodb-preview:3.3", "arangodb/arangodb-preview:3.4") +// } // test upgrade single server mmfiles 3.2 -> 3.3 -func TestUpgradeSingleMMFiles32to33(t *testing.T) { - upgradeSubTest(t, api.DeploymentModeSingle, api.StorageEngineMMFiles, "arangodb/arangodb:3.2.16", "arangodb/arangodb:3.3.13") -} +// func TestUpgradeSingleMMFiles32to33(t *testing.T) { +// upgradeSubTest(t, api.DeploymentModeSingle, api.StorageEngineMMFiles, "arangodb/arangodb:3.2.16", "arangodb/arangodb:3.3.13") +// } // // test upgrade single server rocksdb 3.3 -> 3.4 // func TestUpgradeSingleRocksDB33to34(t *testing.T) { @@ -58,29 +58,29 @@ func TestUpgradeActiveFailoverRocksDB33to34(t *testing.T) { // } // test upgrade cluster rocksdb 3.2 -> 3.3 -func TestUpgradeClusterRocksDB32to33(t *testing.T) { - upgradeSubTest(t, api.DeploymentModeCluster, api.StorageEngineRocksDB, "3.2.16", "3.3.13") -} +// func TestUpgradeClusterRocksDB32to33(t *testing.T) { +// upgradeSubTest(t, api.DeploymentModeCluster, api.StorageEngineRocksDB, "3.2.16", "3.3.13") +// } // // test upgrade cluster mmfiles 3.3 -> 3.4 // func TestUpgradeClusterMMFiles33to34(t *testing.T) { // upgradeSubTest(t, api.DeploymentModeCluster, api.StorageEngineRocksDB, "3.3.13", "3.4.0") // } -// test downgrade single server mmfiles 3.3.17 -> 3.3.16 -func TestDowngradeSingleMMFiles3317to3316(t *testing.T) { - upgradeSubTest(t, api.DeploymentModeSingle, api.StorageEngineMMFiles, "arangodb/arangodb:3.3.16", "arangodb/arangodb:3.3.17") -} +// // test downgrade single server mmfiles 3.3.17 -> 3.3.16 +// func TestDowngradeSingleMMFiles3317to3316(t *testing.T) { +// upgradeSubTest(t, api.DeploymentModeSingle, api.StorageEngineMMFiles, "arangodb/arangodb:3.3.16", "arangodb/arangodb:3.3.17") +// } -// test downgrade ActiveFailover server rocksdb 3.3.17 -> 3.3.16 -func TestDowngradeActiveFailoverRocksDB3317to3316(t *testing.T) { - upgradeSubTest(t, api.DeploymentModeActiveFailover, api.StorageEngineRocksDB, "arangodb/arangodb:3.3.16", "arangodb/arangodb:3.3.17") -} +// // test downgrade ActiveFailover server rocksdb 3.3.17 -> 3.3.16 +// func TestDowngradeActiveFailoverRocksDB3317to3316(t *testing.T) { +// upgradeSubTest(t, api.DeploymentModeActiveFailover, api.StorageEngineRocksDB, "arangodb/arangodb:3.3.16", "arangodb/arangodb:3.3.17") +// } -// test downgrade cluster rocksdb 3.3.17 -> 3.3.16 -func TestDowngradeClusterRocksDB3317to3316(t *testing.T) { - upgradeSubTest(t, api.DeploymentModeCluster, api.StorageEngineRocksDB, "arangodb/arangodb:3.3.16", "arangodb/arangodb:3.3.17") -} +// // test downgrade cluster rocksdb 3.3.17 -> 3.3.16 +// func TestDowngradeClusterRocksDB3317to3316(t *testing.T) { +// upgradeSubTest(t, api.DeploymentModeCluster, api.StorageEngineRocksDB, "arangodb/arangodb:3.3.16", "arangodb/arangodb:3.3.17") +// } func upgradeSubTest(t *testing.T, mode api.DeploymentMode, engine api.StorageEngine, fromImage, toImage string) error { // check environment