Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Add Ephemeral Volumes for apps feature
- Check if the DB server is cleaned out.
- Render Pod Template in ArangoMember Spec and Status
- Add Pod PropagationModes

## [1.2.1](https://github.com/arangodb/kube-arangodb/tree/1.2.1) (2021-07-28)
- Fix ArangoMember race with multiple ArangoDeployments within single namespace
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/deployment/v1/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ const (
ConditionTypeMaintenanceMode ConditionType = "MaintenanceMode"
// ConditionTypePendingRestart indicates that restart is required
ConditionTypePendingRestart ConditionType = "PendingRestart"
// ConditionTypeRestart indicates that restart will be started
ConditionTypeRestart ConditionType = "Restart"
// ConditionTypePendingTLSRotation indicates that TLS rotation is pending
ConditionTypePendingTLSRotation ConditionType = "PendingTLSRotation"
)
Expand Down
62 changes: 62 additions & 0 deletions pkg/apis/deployment/v1/deployment_member_propagation_mode.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//
// DISCLAIMER
//
// Copyright 2021 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
// Author Adam Janikowski
//

package v1

type DeploymentMemberPropagationMode string

func (d *DeploymentMemberPropagationMode) Get() DeploymentMemberPropagationMode {
if d == nil {
return DeploymentMemberPropagationModeDefault
}

return *d
}

func (d DeploymentMemberPropagationMode) New() *DeploymentMemberPropagationMode {
return &d
}

func (d DeploymentMemberPropagationMode) String() string {
return string(d)
}

func (d *DeploymentMemberPropagationMode) Equal(b *DeploymentMemberPropagationMode) bool {
if d == nil && b == nil {
return true
}

if d == nil || b == nil {
return false
}

return *d == *b
}

const (
// DeploymentMemberPropagationModeDefault Define default propagation mode
DeploymentMemberPropagationModeDefault = DeploymentMemberPropagationModeAlways
// DeploymentMemberPropagationModeAlways define mode which restart member whenever change in pod is discovered
DeploymentMemberPropagationModeAlways DeploymentMemberPropagationMode = "always"
// DeploymentMemberPropagationModeOnRestart propagate member spec whenever pod is restarted. Do not restart member by default
DeploymentMemberPropagationModeOnRestart DeploymentMemberPropagationMode = "on-restart"
)
2 changes: 2 additions & 0 deletions pkg/apis/deployment/v1/deployment_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ type DeploymentSpec struct {
SyncMasters ServerGroupSpec `json:"syncmasters"`
SyncWorkers ServerGroupSpec `json:"syncworkers"`

MemberPropagationMode *DeploymentMemberPropagationMode `json:"memberPropagationMode,omitempty"`

Chaos ChaosSpec `json:"chaos"`

Recovery *ArangoDeploymentRecoverySpec `json:"recovery,omitempty"`
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/deployment/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pkg/apis/deployment/v2alpha1/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ const (
ConditionTypeMaintenanceMode ConditionType = "MaintenanceMode"
// ConditionTypePendingRestart indicates that restart is required
ConditionTypePendingRestart ConditionType = "PendingRestart"
// ConditionTypeRestart indicates that restart will be started
ConditionTypeRestart ConditionType = "Restart"
// ConditionTypePendingTLSRotation indicates that TLS rotation is pending
ConditionTypePendingTLSRotation ConditionType = "PendingTLSRotation"
)
Expand Down
62 changes: 62 additions & 0 deletions pkg/apis/deployment/v2alpha1/deployment_member_propagation_mode.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//
// DISCLAIMER
//
// Copyright 2021 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
// Author Adam Janikowski
//

package v2alpha1

type DeploymentMemberPropagationMode string

func (d *DeploymentMemberPropagationMode) Get() DeploymentMemberPropagationMode {
if d == nil {
return DeploymentMemberPropagationModeDefault
}

return *d
}

func (d DeploymentMemberPropagationMode) New() *DeploymentMemberPropagationMode {
return &d
}

func (d DeploymentMemberPropagationMode) String() string {
return string(d)
}

func (d *DeploymentMemberPropagationMode) Equal(b *DeploymentMemberPropagationMode) bool {
if d == nil && b == nil {
return true
}

if d == nil || b == nil {
return false
}

return *d == *b
}

const (
// DeploymentMemberPropagationModeDefault Define default propagation mode
DeploymentMemberPropagationModeDefault = DeploymentMemberPropagationModeAlways
// DeploymentMemberPropagationModeAlways define mode which restart member whenever change in pod is discovered
DeploymentMemberPropagationModeAlways DeploymentMemberPropagationMode = "always"
// DeploymentMemberPropagationModeOnRestart propagate member spec whenever pod is restarted. Do not restart member by default
DeploymentMemberPropagationModeOnRestart DeploymentMemberPropagationMode = "on-restart"
)
2 changes: 2 additions & 0 deletions pkg/apis/deployment/v2alpha1/deployment_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ type DeploymentSpec struct {
SyncMasters ServerGroupSpec `json:"syncmasters"`
SyncWorkers ServerGroupSpec `json:"syncworkers"`

MemberPropagationMode *DeploymentMemberPropagationMode `json:"memberPropagationMode,omitempty"`

Chaos ChaosSpec `json:"chaos"`

Recovery *ArangoDeploymentRecoverySpec `json:"recovery,omitempty"`
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/deployment/v2alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 25 additions & 3 deletions pkg/deployment/deployment_inspector.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,17 @@ func (d *Deployment) inspectDeploymentWithError(ctx context.Context, lastInterva

return minInspectionInterval, nil
} else if status.AppliedVersion == checksum {
if !d.apiObject.Status.IsPlanEmpty() && status.Conditions.IsTrue(api.ConditionTypeUpToDate) {
if err = d.updateCondition(ctx, api.ConditionTypeUpToDate, false, "Plan is not empty", "There are pending operations in plan"); err != nil {
isUpToDate, reason := d.isUpToDateStatus()

if !isUpToDate && status.Conditions.IsTrue(api.ConditionTypeUpToDate) {
if err = d.updateCondition(ctx, api.ConditionTypeUpToDate, false, reason, "There are pending operations in plan or members are in restart process"); err != nil {
return minInspectionInterval, errors.Wrapf(err, "Unable to update UpToDate condition")
}

return minInspectionInterval, nil
}

if d.apiObject.Status.IsPlanEmpty() && !status.Conditions.IsTrue(api.ConditionTypeUpToDate) {
if isUpToDate && !status.Conditions.IsTrue(api.ConditionTypeUpToDate) {
if err = d.updateCondition(ctx, api.ConditionTypeUpToDate, true, "Spec is Up To Date", "Spec is Up To Date"); err != nil {
return minInspectionInterval, errors.Wrapf(err, "Unable to update UpToDate condition")
}
Expand Down Expand Up @@ -349,6 +351,26 @@ func (d *Deployment) inspectDeploymentWithError(ctx context.Context, lastInterva
return
}

func (d *Deployment) isUpToDateStatus() (upToDate bool, reason string) {
if !d.apiObject.Status.IsPlanEmpty() {
return false, "Plan is not empty"
}

upToDate = true

d.apiObject.Status.Members.ForeachServerGroup(func(group api.ServerGroup, list api.MemberStatusList) error {
for _, member := range list {
if member.Conditions.IsTrue(api.ConditionTypeRestart) || member.Conditions.IsTrue(api.ConditionTypePendingRestart) {
upToDate = false
reason = "Pending restarts on members"
}
}
return nil
})

return
}

func (d *Deployment) refreshMaintenanceTTL(ctx context.Context) {
if d.apiObject.Spec.Mode.Get() == api.DeploymentModeSingle {
return
Expand Down
Loading