diff --git a/pkg/apis/deployment/v1/conditions.go b/pkg/apis/deployment/v1/conditions.go index 1256d7135..505451ac5 100644 --- a/pkg/apis/deployment/v1/conditions.go +++ b/pkg/apis/deployment/v1/conditions.go @@ -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" @@ -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. @@ -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" ) diff --git a/pkg/apis/deployment/v1/conditions_deployment.go b/pkg/apis/deployment/v1/conditions_deployment.go new file mode 100644 index 000000000..01e1a8f87 --- /dev/null +++ b/pkg/apis/deployment/v1/conditions_deployment.go @@ -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" +) diff --git a/pkg/apis/deployment/v1/deployment_member_status_element.go b/pkg/apis/deployment/v1/deployment_member_status_element.go index e98ded9ad..4850eff0f 100644 --- a/pkg/apis/deployment/v1/deployment_member_status_element.go +++ b/pkg/apis/deployment/v1/deployment_member_status_element.go @@ -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"` diff --git a/pkg/apis/deployment/v1/list.go b/pkg/apis/deployment/v1/list.go index eea3476b5..e50a828ba 100644 --- a/pkg/apis/deployment/v1/list.go +++ b/pkg/apis/deployment/v1/list.go @@ -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 { @@ -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 +} diff --git a/pkg/apis/deployment/v1/plan.go b/pkg/apis/deployment/v1/plan.go index 6d8732117..55922cedf 100644 --- a/pkg/apis/deployment/v1/plan.go +++ b/pkg/apis/deployment/v1/plan.go @@ -175,6 +175,7 @@ const ( // Topology ActionTypeTopologyEnable ActionType = "TopologyEnable" ActionTypeTopologyDisable ActionType = "TopologyDisable" + ActionTypeTopologyZonesUpdate ActionType = "TopologyZonesUpdate" ActionTypeTopologyMemberAssignment ActionType = "TopologyMemberAssignment" ) diff --git a/pkg/apis/deployment/v1/topology_member_status.go b/pkg/apis/deployment/v1/topology_member_status.go index 70fd0b8ed..3988f6576 100644 --- a/pkg/apis/deployment/v1/topology_member_status.go +++ b/pkg/apis/deployment/v1/topology_member_status.go @@ -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"` } diff --git a/pkg/apis/deployment/v1/topology_status.go b/pkg/apis/deployment/v1/topology_status.go index ebb888535..4716e27a3 100644 --- a/pkg/apis/deployment/v1/topology_status.go +++ b/pkg/apis/deployment/v1/topology_status.go @@ -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 } @@ -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 { diff --git a/pkg/apis/deployment/v2alpha1/conditions.go b/pkg/apis/deployment/v2alpha1/conditions.go index 9b0faf201..2f2d33b42 100644 --- a/pkg/apis/deployment/v2alpha1/conditions.go +++ b/pkg/apis/deployment/v2alpha1/conditions.go @@ -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" @@ -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. @@ -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" ) diff --git a/pkg/apis/deployment/v2alpha1/conditions_deployment.go b/pkg/apis/deployment/v2alpha1/conditions_deployment.go new file mode 100644 index 000000000..1799b0474 --- /dev/null +++ b/pkg/apis/deployment/v2alpha1/conditions_deployment.go @@ -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" +) diff --git a/pkg/apis/deployment/v2alpha1/deployment_member_status_element.go b/pkg/apis/deployment/v2alpha1/deployment_member_status_element.go index 75aa63cad..9e10dd58a 100644 --- a/pkg/apis/deployment/v2alpha1/deployment_member_status_element.go +++ b/pkg/apis/deployment/v2alpha1/deployment_member_status_element.go @@ -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"` diff --git a/pkg/apis/deployment/v2alpha1/list.go b/pkg/apis/deployment/v2alpha1/list.go index ca041f0e4..e72a26d18 100644 --- a/pkg/apis/deployment/v2alpha1/list.go +++ b/pkg/apis/deployment/v2alpha1/list.go @@ -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 { @@ -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 +} diff --git a/pkg/apis/deployment/v2alpha1/plan.go b/pkg/apis/deployment/v2alpha1/plan.go index 97255d0ac..3d737e9fc 100644 --- a/pkg/apis/deployment/v2alpha1/plan.go +++ b/pkg/apis/deployment/v2alpha1/plan.go @@ -175,6 +175,7 @@ const ( // Topology ActionTypeTopologyEnable ActionType = "TopologyEnable" ActionTypeTopologyDisable ActionType = "TopologyDisable" + ActionTypeTopologyZonesUpdate ActionType = "TopologyZonesUpdate" ActionTypeTopologyMemberAssignment ActionType = "TopologyMemberAssignment" ) diff --git a/pkg/apis/deployment/v2alpha1/topology_member_status.go b/pkg/apis/deployment/v2alpha1/topology_member_status.go index 36bae3bef..724106cdb 100644 --- a/pkg/apis/deployment/v2alpha1/topology_member_status.go +++ b/pkg/apis/deployment/v2alpha1/topology_member_status.go @@ -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"` } diff --git a/pkg/apis/deployment/v2alpha1/topology_status.go b/pkg/apis/deployment/v2alpha1/topology_status.go index f97e76f50..e737b9e9d 100644 --- a/pkg/apis/deployment/v2alpha1/topology_status.go +++ b/pkg/apis/deployment/v2alpha1/topology_status.go @@ -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 } @@ -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 { diff --git a/pkg/deployment/reconcile/action_topology_zones_update.community.go b/pkg/deployment/reconcile/action_topology_zones_update.community.go new file mode 100644 index 000000000..7c4bfd52e --- /dev/null +++ b/pkg/deployment/reconcile/action_topology_zones_update.community.go @@ -0,0 +1,27 @@ +// +// 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 +// + +// +build !enterprise + +package reconcile + +type topologyZonesUpdate struct { + actionEmpty +} diff --git a/pkg/deployment/reconcile/action_topology_zones_update.go b/pkg/deployment/reconcile/action_topology_zones_update.go new file mode 100644 index 000000000..4fa4c99b4 --- /dev/null +++ b/pkg/deployment/reconcile/action_topology_zones_update.go @@ -0,0 +1,38 @@ +// +// 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 reconcile + +import ( + api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" + "github.com/rs/zerolog" +) + +func init() { + registerAction(api.ActionTypeTopologyZonesUpdate, newTopologyZonesUpdate) +} + +func newTopologyZonesUpdate(log zerolog.Logger, action api.Action, actionCtx ActionContext) Action { + a := &topologyZonesUpdate{} + + a.actionImpl = newActionImplDefRef(log, action, actionCtx, defaultTimeout) + + return a +} diff --git a/pkg/deployment/reconcile/plan_builder_normal.go b/pkg/deployment/reconcile/plan_builder_normal.go index 6173ee297..f187176cd 100644 --- a/pkg/deployment/reconcile/plan_builder_normal.go +++ b/pkg/deployment/reconcile/plan_builder_normal.go @@ -85,6 +85,7 @@ func createNormalPlan(ctx context.Context, log zerolog.Logger, apiObject k8sutil ApplyIfEmpty(createTopologyMemberAdjustmentPlan). // Define topology ApplyIfEmpty(createTopologyEnablementPlan). + ApplyIfEmpty(createTopologyUpdatePlan). // Check for scale up ApplyIfEmpty(createScaleUPMemberPlan). // Check for failed members diff --git a/pkg/deployment/reconcile/plan_builder_topology.community.go b/pkg/deployment/reconcile/plan_builder_topology.community.go index e2cbf887b..76193e02f 100644 --- a/pkg/deployment/reconcile/plan_builder_topology.community.go +++ b/pkg/deployment/reconcile/plan_builder_topology.community.go @@ -52,6 +52,13 @@ func createTopologyMemberAdjustmentPlan(ctx context.Context, return nil } +func createTopologyUpdatePlan(ctx context.Context, + log zerolog.Logger, apiObject k8sutil.APIObject, + spec api.DeploymentSpec, status api.DeploymentStatus, + cachedStatus inspectorInterface.Inspector, context PlanBuilderContext) api.Plan { + return nil +} + func topologyMissingMemberToRemoveSelector(s *api.TopologyStatus) api.MemberToRemoveSelector { return nil } diff --git a/pkg/deployment/resources/pod_creator_arangod.go b/pkg/deployment/resources/pod_creator_arangod.go index 89823d1e9..5ba8f4f05 100644 --- a/pkg/deployment/resources/pod_creator_arangod.go +++ b/pkg/deployment/resources/pod_creator_arangod.go @@ -271,7 +271,7 @@ func (m *MemberArangoDPod) GetPodAntiAffinity() *core.PodAntiAffinity { pod.AppendPodAntiAffinityDefault(m, &a) - pod.MergePodAntiAffinity(&a, topology.GetTopologyAffinityRules(m.context.GetName(), m.group, m.deploymentStatus.Topology, m.status.Topology).PodAntiAffinity) + pod.MergePodAntiAffinity(&a, topology.GetTopologyAffinityRules(m.context.GetName(), m.deploymentStatus, m.group, m.status).PodAntiAffinity) pod.MergePodAntiAffinity(&a, m.groupSpec.AntiAffinity) @@ -283,7 +283,7 @@ func (m *MemberArangoDPod) GetPodAffinity() *core.PodAffinity { pod.MergePodAffinity(&a, m.groupSpec.Affinity) - pod.MergePodAffinity(&a, topology.GetTopologyAffinityRules(m.context.GetName(), m.group, m.deploymentStatus.Topology, m.status.Topology).PodAffinity) + pod.MergePodAffinity(&a, topology.GetTopologyAffinityRules(m.context.GetName(), m.deploymentStatus, m.group, m.status).PodAffinity) return pod.ReturnPodAffinityOrNil(a) } @@ -295,7 +295,7 @@ func (m *MemberArangoDPod) GetNodeAffinity() *core.NodeAffinity { pod.MergeNodeAffinity(&a, m.groupSpec.NodeAffinity) - pod.MergeNodeAffinity(&a, topology.GetTopologyAffinityRules(m.context.GetName(), m.group, m.deploymentStatus.Topology, m.status.Topology).NodeAffinity) + pod.MergeNodeAffinity(&a, topology.GetTopologyAffinityRules(m.context.GetName(), m.deploymentStatus, m.group, m.status).NodeAffinity) return pod.ReturnNodeAffinityOrNil(a) } diff --git a/pkg/deployment/resources/pod_inspector.go b/pkg/deployment/resources/pod_inspector.go index 913fee45b..c2555c2a0 100644 --- a/pkg/deployment/resources/pod_inspector.go +++ b/pkg/deployment/resources/pod_inspector.go @@ -187,7 +187,21 @@ func (r *Resources) InspectPods(ctx context.Context, cachedStatus inspectorInter if k8sutil.IsContainerReady(pod, k8sutil.ServerContainerName) { // Pod is now ready if memberStatus.Conditions.Update(api.ConditionTypeReady, true, "Pod Ready", "") { - log.Debug().Str("pod-name", pod.GetName()).Msg("Updating member condition Ready to true") + log.Debug().Str("pod-name", pod.GetName()).Msg("Updating member condition Ready & Initialised to true") + + if status.Topology.IsTopologyOwned(memberStatus.Topology) { + nodes, ok := cachedStatus.GetNodes() + if ok { + node, ok := nodes.Node(pod.Spec.NodeName) + if ok { + label, ok := node.Labels[status.Topology.Label] + if ok { + memberStatus.Topology.Label = label + } + } + } + } + memberStatus.IsInitialized = true // Require future pods for this member to have an existing UUID (in case of dbserver). updateMemberStatusNeeded = true nextInterval = nextInterval.ReduceTo(recheckSoonPodInspectorInterval) diff --git a/pkg/deployment/topology/topology.community.go b/pkg/deployment/topology/topology.community.go index 2eb3fa797..c374726f7 100644 --- a/pkg/deployment/topology/topology.community.go +++ b/pkg/deployment/topology/topology.community.go @@ -27,6 +27,6 @@ import ( core "k8s.io/api/core/v1" ) -func GetTopologyAffinityRules(name string, group api.ServerGroup, status *api.TopologyStatus, member *api.TopologyMemberStatus) core.Affinity { +func GetTopologyAffinityRules(name string, status api.DeploymentStatus, group api.ServerGroup, member api.MemberStatus) core.Affinity { return core.Affinity{} }