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
15 changes: 7 additions & 8 deletions pkg/apis/deployment/v1/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const (
ConditionTypeTerminated ConditionType = "Terminated"
// ConditionTypeAutoUpgrade indicates that the member has to be started with `--database.auto-upgrade` once.
ConditionTypeAutoUpgrade ConditionType = "AutoUpgrade"

// ConditionTypeCleanedOut indicates that the member (dbserver) has been cleaned out.
// Always check in combination with ConditionTypeTerminated.
ConditionTypeCleanedOut ConditionType = "CleanedOut"
Expand All @@ -51,16 +52,9 @@ const (
ConditionTypeAgentRecoveryNeeded ConditionType = "AgentRecoveryNeeded"
// ConditionTypePodSchedulingFailure indicates that one or more pods belonging to the deployment cannot be schedule.
ConditionTypePodSchedulingFailure ConditionType = "PodSchedulingFailure"
// ConditionTypeSecretsChanged indicates that the value of one of more secrets used by
// the deployment have changed. Once that is the case, the operator will no longer
// touch the deployment, until the original secrets have been restored.
ConditionTypeSecretsChanged ConditionType = "SecretsChanged"
// ConditionTypeMemberOfCluster indicates that the member is a known member of the ArangoDB cluster.
ConditionTypeMemberOfCluster ConditionType = "MemberOfCluster"
// ConditionTypeBootstrapCompleted indicates that the initial cluster bootstrap has been completed.
ConditionTypeBootstrapCompleted ConditionType = "BootstrapCompleted"
// ConditionTypeBootstrapSucceded indicates that the initial cluster bootstrap completed successfully.
ConditionTypeBootstrapSucceded ConditionType = "BootstrapSucceded"

// ConditionTypeTerminating indicates that the member is terminating but not yet terminated.
ConditionTypeTerminating ConditionType = "Terminating"
// ConditionTypeTerminating indicates that the deployment is up to date.
Expand All @@ -69,20 +63,25 @@ const (
ConditionTypeMarkedToRemove ConditionType = "MarkedToRemove"
// ConditionTypeUpgradeFailed indicates that upgrade failed
ConditionTypeUpgradeFailed ConditionType = "UpgradeFailed"

// ConditionTypeMaintenanceMode indicates that Maintenance is enabled
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"

// ConditionTypePendingUpdate indicates that runtime update is pending
ConditionTypePendingUpdate ConditionType = "PendingUpdate"
// ConditionTypeUpdating indicates that runtime update is in progress
ConditionTypeUpdating ConditionType = "Updating"
// ConditionTypeUpdateFailed indicates that runtime update failed
ConditionTypeUpdateFailed ConditionType = "UpdateFailed"

// ConditionTypeTopologyAware indicates that the member is deployed with TopologyAwareness.
ConditionTypeTopologyAware ConditionType = "TopologyAware"
)
Expand Down
33 changes: 33 additions & 0 deletions pkg/apis/deployment/v1/conditions_deployment.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// DISCLAIMER
//
// Copyright 2016-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
//

package v1

const (
// ConditionTypeSecretsChanged indicates that the value of one of more secrets used by
// the deployment have changed. Once that is the case, the operator will no longer
// touch the deployment, until the original secrets have been restored.
ConditionTypeSecretsChanged ConditionType = "SecretsChanged"

// ConditionTypeBootstrapCompleted indicates that the initial cluster bootstrap has been completed.
ConditionTypeBootstrapCompleted ConditionType = "BootstrapCompleted"
// ConditionTypeBootstrapSucceded indicates that the initial cluster bootstrap completed successfully.
ConditionTypeBootstrapSucceded ConditionType = "BootstrapSucceded"
)
31 changes: 31 additions & 0 deletions pkg/apis/deployment/v1/deployment_member_status_element.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,39 @@

package v1

import "sort"

type DeploymentStatusMemberElementsSortFunc func(a, b DeploymentStatusMemberElement) bool
type DeploymentStatusMemberElementsCondFunc func(a DeploymentStatusMemberElement) bool

type DeploymentStatusMemberElements []DeploymentStatusMemberElement

func (d DeploymentStatusMemberElements) Filter(f DeploymentStatusMemberElementsCondFunc) DeploymentStatusMemberElements {
var l DeploymentStatusMemberElements

for _, a := range d {
if !f(a) {
continue
}

z := a.DeepCopy()

l = append(l, *z)
}

return l
}

func (d DeploymentStatusMemberElements) Sort(less DeploymentStatusMemberElementsSortFunc) DeploymentStatusMemberElements {
n := d.DeepCopy()

sort.Slice(n, func(i, j int) bool {
return less(n[i], n[j])
})

return n
}

// DeploymentStatusMemberElement holds one specific element with group and member status
type DeploymentStatusMemberElement struct {
Group ServerGroup `json:"group,omitempty"`
Expand Down
28 changes: 26 additions & 2 deletions pkg/apis/deployment/v1/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,24 @@ func (l List) Contains(v string) bool {
return false
}

func (l List) Sort() {
sort.Strings(l)
func (l List) Sort() List {
z := l.DeepCopy()
sort.Strings(z)
return z
}

func (l List) Unique() List {
var m List

for _, k := range l {
if m.Contains(k) {
continue
}

m = m.Add(k)
}

return m
}

func (l List) Remove(values ...string) List {
Expand All @@ -53,3 +69,11 @@ func (l List) Remove(values ...string) List {

return m
}
func (l List) Add(values ...string) List {
var m List

m = append(m, l...)
m = append(m, values...)

return m
}
1 change: 1 addition & 0 deletions pkg/apis/deployment/v1/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ const (
// Topology
ActionTypeTopologyEnable ActionType = "TopologyEnable"
ActionTypeTopologyDisable ActionType = "TopologyDisable"
ActionTypeTopologyZonesUpdate ActionType = "TopologyZonesUpdate"
ActionTypeTopologyMemberAssignment ActionType = "TopologyMemberAssignment"
)

Expand Down
5 changes: 3 additions & 2 deletions pkg/apis/deployment/v1/topology_member_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package v1
import "k8s.io/apimachinery/pkg/types"

type TopologyMemberStatus struct {
ID types.UID `json:"id"`
Zone int `json:"rack"`
ID types.UID `json:"id"`
Zone int `json:"rack"`
Label string `json:"label,omitempty"`
}
7 changes: 2 additions & 5 deletions pkg/apis/deployment/v1/topology_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ func (t *TopologyStatus) RegisterTopologyLabel(zone int, label string) bool {
return false
}

t.Zones[zone].Labels = append(t.Zones[zone].Labels, label)
t.Zones[zone].Labels.Sort()
t.Zones[zone].Labels = t.Zones[zone].Labels.Add(label).Sort()

return true
}
Expand Down Expand Up @@ -125,9 +124,7 @@ func (t *TopologyStatusZone) AddMember(group ServerGroup, id string) {
t.Members = TopologyStatusZoneMembers{}
}

t.Members[group.AsRoleAbbreviated()] = append(t.Members[group.AsRoleAbbreviated()], id)

t.Members[group.AsRoleAbbreviated()].Sort()
t.Members[group.AsRoleAbbreviated()] = t.Members[group.AsRoleAbbreviated()].Add(id).Sort()
}

func (t *TopologyStatusZone) RemoveMember(group ServerGroup, id string) bool {
Expand Down
15 changes: 7 additions & 8 deletions pkg/apis/deployment/v2alpha1/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const (
ConditionTypeTerminated ConditionType = "Terminated"
// ConditionTypeAutoUpgrade indicates that the member has to be started with `--database.auto-upgrade` once.
ConditionTypeAutoUpgrade ConditionType = "AutoUpgrade"

// ConditionTypeCleanedOut indicates that the member (dbserver) has been cleaned out.
// Always check in combination with ConditionTypeTerminated.
ConditionTypeCleanedOut ConditionType = "CleanedOut"
Expand All @@ -51,16 +52,9 @@ const (
ConditionTypeAgentRecoveryNeeded ConditionType = "AgentRecoveryNeeded"
// ConditionTypePodSchedulingFailure indicates that one or more pods belonging to the deployment cannot be schedule.
ConditionTypePodSchedulingFailure ConditionType = "PodSchedulingFailure"
// ConditionTypeSecretsChanged indicates that the value of one of more secrets used by
// the deployment have changed. Once that is the case, the operator will no longer
// touch the deployment, until the original secrets have been restored.
ConditionTypeSecretsChanged ConditionType = "SecretsChanged"
// ConditionTypeMemberOfCluster indicates that the member is a known member of the ArangoDB cluster.
ConditionTypeMemberOfCluster ConditionType = "MemberOfCluster"
// ConditionTypeBootstrapCompleted indicates that the initial cluster bootstrap has been completed.
ConditionTypeBootstrapCompleted ConditionType = "BootstrapCompleted"
// ConditionTypeBootstrapSucceded indicates that the initial cluster bootstrap completed successfully.
ConditionTypeBootstrapSucceded ConditionType = "BootstrapSucceded"

// ConditionTypeTerminating indicates that the member is terminating but not yet terminated.
ConditionTypeTerminating ConditionType = "Terminating"
// ConditionTypeTerminating indicates that the deployment is up to date.
Expand All @@ -69,20 +63,25 @@ const (
ConditionTypeMarkedToRemove ConditionType = "MarkedToRemove"
// ConditionTypeUpgradeFailed indicates that upgrade failed
ConditionTypeUpgradeFailed ConditionType = "UpgradeFailed"

// ConditionTypeMaintenanceMode indicates that Maintenance is enabled
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"

// ConditionTypePendingUpdate indicates that runtime update is pending
ConditionTypePendingUpdate ConditionType = "PendingUpdate"
// ConditionTypeUpdating indicates that runtime update is in progress
ConditionTypeUpdating ConditionType = "Updating"
// ConditionTypeUpdateFailed indicates that runtime update failed
ConditionTypeUpdateFailed ConditionType = "UpdateFailed"

// ConditionTypeTopologyAware indicates that the member is deployed with TopologyAwareness.
ConditionTypeTopologyAware ConditionType = "TopologyAware"
)
Expand Down
33 changes: 33 additions & 0 deletions pkg/apis/deployment/v2alpha1/conditions_deployment.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// DISCLAIMER
//
// Copyright 2016-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
//

package v2alpha1

const (
// ConditionTypeSecretsChanged indicates that the value of one of more secrets used by
// the deployment have changed. Once that is the case, the operator will no longer
// touch the deployment, until the original secrets have been restored.
ConditionTypeSecretsChanged ConditionType = "SecretsChanged"

// ConditionTypeBootstrapCompleted indicates that the initial cluster bootstrap has been completed.
ConditionTypeBootstrapCompleted ConditionType = "BootstrapCompleted"
// ConditionTypeBootstrapSucceded indicates that the initial cluster bootstrap completed successfully.
ConditionTypeBootstrapSucceded ConditionType = "BootstrapSucceded"
)
31 changes: 31 additions & 0 deletions pkg/apis/deployment/v2alpha1/deployment_member_status_element.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,39 @@

package v2alpha1

import "sort"

type DeploymentStatusMemberElementsSortFunc func(a, b DeploymentStatusMemberElement) bool
type DeploymentStatusMemberElementsCondFunc func(a DeploymentStatusMemberElement) bool

type DeploymentStatusMemberElements []DeploymentStatusMemberElement

func (d DeploymentStatusMemberElements) Filter(f DeploymentStatusMemberElementsCondFunc) DeploymentStatusMemberElements {
var l DeploymentStatusMemberElements

for _, a := range d {
if !f(a) {
continue
}

z := a.DeepCopy()

l = append(l, *z)
}

return l
}

func (d DeploymentStatusMemberElements) Sort(less DeploymentStatusMemberElementsSortFunc) DeploymentStatusMemberElements {
n := d.DeepCopy()

sort.Slice(n, func(i, j int) bool {
return less(n[i], n[j])
})

return n
}

// DeploymentStatusMemberElement holds one specific element with group and member status
type DeploymentStatusMemberElement struct {
Group ServerGroup `json:"group,omitempty"`
Expand Down
28 changes: 26 additions & 2 deletions pkg/apis/deployment/v2alpha1/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,24 @@ func (l List) Contains(v string) bool {
return false
}

func (l List) Sort() {
sort.Strings(l)
func (l List) Sort() List {
z := l.DeepCopy()
sort.Strings(z)
return z
}

func (l List) Unique() List {
var m List

for _, k := range l {
if m.Contains(k) {
continue
}

m = m.Add(k)
}

return m
}

func (l List) Remove(values ...string) List {
Expand All @@ -53,3 +69,11 @@ func (l List) Remove(values ...string) List {

return m
}
func (l List) Add(values ...string) List {
var m List

m = append(m, l...)
m = append(m, values...)

return m
}
1 change: 1 addition & 0 deletions pkg/apis/deployment/v2alpha1/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ const (
// Topology
ActionTypeTopologyEnable ActionType = "TopologyEnable"
ActionTypeTopologyDisable ActionType = "TopologyDisable"
ActionTypeTopologyZonesUpdate ActionType = "TopologyZonesUpdate"
ActionTypeTopologyMemberAssignment ActionType = "TopologyMemberAssignment"
)

Expand Down
5 changes: 3 additions & 2 deletions pkg/apis/deployment/v2alpha1/topology_member_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package v2alpha1
import "k8s.io/apimachinery/pkg/types"

type TopologyMemberStatus struct {
ID types.UID `json:"id"`
Zone int `json:"rack"`
ID types.UID `json:"id"`
Zone int `json:"rack"`
Label string `json:"label,omitempty"`
}
Loading