From 037c754b8d1c4d90ddd447c586f9eecc0d333099 Mon Sep 17 00:00:00 2001 From: ajanikow <12255597+ajanikow@users.noreply.github.com> Date: Mon, 18 May 2020 06:35:17 +0000 Subject: [PATCH] Allow unsafe upgrades --- pkg/apis/deployment/v1/deployment_spec.go | 8 ++++++++ pkg/apis/deployment/v1/zz_generated.deepcopy.go | 5 +++++ .../reconcile/plan_builder_rotate_upgrade.go | 11 +++++++++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/pkg/apis/deployment/v1/deployment_spec.go b/pkg/apis/deployment/v1/deployment_spec.go index 4644e7565..bb1200ed8 100644 --- a/pkg/apis/deployment/v1/deployment_spec.go +++ b/pkg/apis/deployment/v1/deployment_spec.go @@ -67,6 +67,9 @@ type DeploymentSpec struct { RestoreFrom *string `json:"restoreFrom,omitempty"` + // AllowUnsafeUpgrade determines if upgrade on missing member or with not in sync shards is allowed + AllowUnsafeUpgrade *bool `json:"allowUnsafeUpgrade,omitempty"` + ExternalAccess ExternalAccessSpec `json:"externalAccess"` RocksDB RocksDBSpec `json:"rocksdb"` Authentication AuthenticationSpec `json:"auth"` @@ -270,6 +273,11 @@ func (s *DeploymentSpec) SetDefaultsFrom(source DeploymentSpec) { if s.DisableIPv6 == nil { s.DisableIPv6 = util.NewBoolOrNil(source.DisableIPv6) } + + if s.AllowUnsafeUpgrade == nil { + s.AllowUnsafeUpgrade = util.NewBoolOrNil(source.AllowUnsafeUpgrade) + } + s.License.SetDefaultsFrom(source.License) s.ExternalAccess.SetDefaultsFrom(source.ExternalAccess) s.RocksDB.SetDefaultsFrom(source.RocksDB) diff --git a/pkg/apis/deployment/v1/zz_generated.deepcopy.go b/pkg/apis/deployment/v1/zz_generated.deepcopy.go index bb64788fb..c4530249d 100644 --- a/pkg/apis/deployment/v1/zz_generated.deepcopy.go +++ b/pkg/apis/deployment/v1/zz_generated.deepcopy.go @@ -317,6 +317,11 @@ func (in *DeploymentSpec) DeepCopyInto(out *DeploymentSpec) { *out = new(string) **out = **in } + if in.AllowUnsafeUpgrade != nil { + in, out := &in.AllowUnsafeUpgrade, &out.AllowUnsafeUpgrade + *out = new(bool) + **out = **in + } in.ExternalAccess.DeepCopyInto(&out.ExternalAccess) in.RocksDB.DeepCopyInto(&out.RocksDB) in.Authentication.DeepCopyInto(&out.Authentication) diff --git a/pkg/deployment/reconcile/plan_builder_rotate_upgrade.go b/pkg/deployment/reconcile/plan_builder_rotate_upgrade.go index e53b0c6a5..2d7e59a99 100644 --- a/pkg/deployment/reconcile/plan_builder_rotate_upgrade.go +++ b/pkg/deployment/reconcile/plan_builder_rotate_upgrade.go @@ -27,6 +27,7 @@ import ( upgraderules "github.com/arangodb/go-upgrade-rules" "github.com/arangodb/kube-arangodb/pkg/apis/deployment" api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" + "github.com/arangodb/kube-arangodb/pkg/util" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" "github.com/rs/zerolog" core "k8s.io/api/core/v1" @@ -105,8 +106,14 @@ func createRotateOrUpgradePlan(log zerolog.Logger, apiObject k8sutil.APIObject, // Use the new plan return newPlan, false } else { - log.Info().Msg("Pod needs upgrade but cluster is not ready. Either some shards are not in sync or some member is not ready.") - return nil, true + if util.BoolOrDefault(spec.AllowUnsafeUpgrade, false) { + log.Info().Msg("Pod needs upgrade but cluster is not ready. Either some shards are not in sync or some member is not ready, but unsafe upgrade is allowed") + // Use the new plan + return newPlan, false + } else { + log.Info().Msg("Pod needs upgrade but cluster is not ready. Either some shards are not in sync or some member is not ready.") + return nil, true + } } } return nil, false