Skip to content

Commit cf80e85

Browse files
authored
GT-267 Multi-arch support for ID member (#1186)
1 parent c3dccbb commit cf80e85

File tree

6 files changed

+34
-8
lines changed

6 files changed

+34
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
- (Improvement) Add ServerGroup details into ServerGroupSpec
3030
- (Improvement) Add Resource kerror Type
3131
- (Bugfix) Do not block reconciliation in case of Resource failure
32+
- (Improvement) Multi-arch support for ID member
3233

3334
## [1.2.20](https://github.com/arangodb/kube-arangodb/tree/1.2.20) (2022-10-25)
3435
- (Feature) Add action progress

pkg/apis/deployment/v1/architecture.go

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,28 @@ func (a ArangoDeploymentArchitecture) IsArchAllowed(arch ArangoDeploymentArchite
5959
return false
6060
}
6161

62+
func (a ArangoDeploymentArchitecture) AsNodeSelectorRequirement() core.NodeSelectorTerm {
63+
var archs []string
64+
65+
if len(a) == 0 {
66+
archs = append(archs, ArangoDeploymentArchitectureDefault.String())
67+
} else {
68+
for _, arch := range a {
69+
archs = append(archs, arch.String())
70+
}
71+
}
72+
73+
return core.NodeSelectorTerm{
74+
MatchExpressions: []core.NodeSelectorRequirement{
75+
{
76+
Key: shared.NodeArchAffinityLabel,
77+
Operator: "In",
78+
Values: archs,
79+
},
80+
},
81+
}
82+
}
83+
6284
type ArangoDeploymentArchitectureType string
6385

6486
const (
@@ -83,6 +105,10 @@ func (a ArangoDeploymentArchitectureType) Validate() error {
83105
}
84106
}
85107

108+
func (a ArangoDeploymentArchitectureType) String() string {
109+
return string(a)
110+
}
111+
86112
func (a *ArangoDeploymentArchitectureType) Default(def ArangoDeploymentArchitectureType) ArangoDeploymentArchitectureType {
87113
if a == nil {
88114
return def
@@ -97,7 +123,7 @@ func (a ArangoDeploymentArchitectureType) AsNodeSelectorRequirement() core.NodeS
97123
{
98124
Key: shared.NodeArchAffinityLabel,
99125
Operator: "In",
100-
Values: []string{string(a)},
126+
Values: []string{a.String()},
101127
},
102128
},
103129
}

pkg/deployment/images.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ func (ib *imagesBuilder) fetchArangoDBImageIDAndVersion(ctx context.Context, cac
249249
return true, errors.WithStack(err)
250250
}
251251

252+
// here we need a pod with selector
252253
err = globals.GetGlobalTimeouts().Kubernetes().RunWithTimeout(ctx, func(ctxChild context.Context) error {
253254
_, _, err := resources.CreateArangoPod(ctxChild, ib.Context.ACS().CurrentClusterCache().PodsModInterface().V1(), ib.APIObject, ib.Spec, api.ServerGroupImageDiscovery, pod)
254255
return err
@@ -373,9 +374,7 @@ func (i *ImageUpdatePod) GetPodAffinity() *core.PodAffinity {
373374

374375
func (i *ImageUpdatePod) GetNodeAffinity() *core.NodeAffinity {
375376
a := core.NodeAffinity{}
376-
arch := i.spec.Architecture.GetDefault()
377-
378-
pod.AppendArchSelector(&a, arch)
377+
pod.AppendArchSelector(&a, i.spec.Architecture.AsNodeSelectorRequirement())
379378

380379
pod.MergeNodeAffinity(&a, i.spec.ID.Get().NodeAffinity)
381380

pkg/deployment/pod/affinity.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ func AppendPodAntiAffinityDefault(p interfaces.PodCreator, a *core.PodAntiAffini
5252
}
5353
}
5454

55-
func AppendArchSelector(a *core.NodeAffinity, arch api.ArangoDeploymentArchitectureType) {
55+
func AppendArchSelector(a *core.NodeAffinity, nodeSelectorForArch core.NodeSelectorTerm) {
5656
if a.RequiredDuringSchedulingIgnoredDuringExecution == nil {
5757
a.RequiredDuringSchedulingIgnoredDuringExecution = &core.NodeSelector{}
5858
}
5959

60-
a.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms = append(a.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms, arch.AsNodeSelectorRequirement())
60+
a.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms = append(a.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms, nodeSelectorForArch)
6161
}
6262

6363
func GetArchFromAffinity(a *core.Affinity) api.ArangoDeploymentArchitectureType {

pkg/deployment/resources/pod_creator_arangod.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ func (m *MemberArangoDPod) GetPodAffinity() *core.PodAffinity {
362362
func (m *MemberArangoDPod) GetNodeAffinity() *core.NodeAffinity {
363363
a := core.NodeAffinity{}
364364

365-
pod.AppendArchSelector(&a, m.status.Architecture.Default(m.spec.Architecture.GetDefault()))
365+
pod.AppendArchSelector(&a, m.status.Architecture.Default(m.spec.Architecture.GetDefault()).AsNodeSelectorRequirement())
366366

367367
pod.MergeNodeAffinity(&a, m.groupSpec.NodeAffinity)
368368

pkg/deployment/resources/pod_creator_sync.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ func (m *MemberSyncPod) GetPodAffinity() *core.PodAffinity {
231231
func (m *MemberSyncPod) GetNodeAffinity() *core.NodeAffinity {
232232
a := core.NodeAffinity{}
233233

234-
pod.AppendArchSelector(&a, m.memberStatus.Architecture.Default(m.spec.Architecture.GetDefault()))
234+
pod.AppendArchSelector(&a, m.memberStatus.Architecture.Default(m.spec.Architecture.GetDefault()).AsNodeSelectorRequirement())
235235

236236
pod.MergeNodeAffinity(&a, m.groupSpec.NodeAffinity)
237237

0 commit comments

Comments
 (0)