Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix/fix immutable reset #301

Merged
merged 2 commits into from
Nov 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions pkg/deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/immutable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

/*
Expand Down
42 changes: 21 additions & 21 deletions tests/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down