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 @@ -29,6 +29,7 @@
- (Improvement) Add ServerGroup details into ServerGroupSpec
- (Improvement) Add Resource kerror Type
- (Bugfix) Do not block reconciliation in case of Resource failure
- (Improvement) Multi-arch support for ID member

## [1.2.20](https://github.com/arangodb/kube-arangodb/tree/1.2.20) (2022-10-25)
- (Feature) Add action progress
Expand Down
28 changes: 27 additions & 1 deletion pkg/apis/deployment/v1/architecture.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,28 @@ func (a ArangoDeploymentArchitecture) IsArchAllowed(arch ArangoDeploymentArchite
return false
}

func (a ArangoDeploymentArchitecture) AsNodeSelectorRequirement() core.NodeSelectorTerm {
var archs []string

if len(a) == 0 {
archs = append(archs, ArangoDeploymentArchitectureDefault.String())
} else {
for _, arch := range a {
archs = append(archs, arch.String())
}
}

return core.NodeSelectorTerm{
MatchExpressions: []core.NodeSelectorRequirement{
{
Key: shared.NodeArchAffinityLabel,
Operator: "In",
Values: archs,
},
},
}
}

type ArangoDeploymentArchitectureType string

const (
Expand All @@ -83,6 +105,10 @@ func (a ArangoDeploymentArchitectureType) Validate() error {
}
}

func (a ArangoDeploymentArchitectureType) String() string {
return string(a)
}

func (a *ArangoDeploymentArchitectureType) Default(def ArangoDeploymentArchitectureType) ArangoDeploymentArchitectureType {
if a == nil {
return def
Expand All @@ -97,7 +123,7 @@ func (a ArangoDeploymentArchitectureType) AsNodeSelectorRequirement() core.NodeS
{
Key: shared.NodeArchAffinityLabel,
Operator: "In",
Values: []string{string(a)},
Values: []string{a.String()},
},
},
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/deployment/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ func (ib *imagesBuilder) fetchArangoDBImageIDAndVersion(ctx context.Context, cac
return true, errors.WithStack(err)
}

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

func (i *ImageUpdatePod) GetNodeAffinity() *core.NodeAffinity {
a := core.NodeAffinity{}
arch := i.spec.Architecture.GetDefault()

pod.AppendArchSelector(&a, arch)
pod.AppendArchSelector(&a, i.spec.Architecture.AsNodeSelectorRequirement())

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

Expand Down
4 changes: 2 additions & 2 deletions pkg/deployment/pod/affinity.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ func AppendPodAntiAffinityDefault(p interfaces.PodCreator, a *core.PodAntiAffini
}
}

func AppendArchSelector(a *core.NodeAffinity, arch api.ArangoDeploymentArchitectureType) {
func AppendArchSelector(a *core.NodeAffinity, nodeSelectorForArch core.NodeSelectorTerm) {
if a.RequiredDuringSchedulingIgnoredDuringExecution == nil {
a.RequiredDuringSchedulingIgnoredDuringExecution = &core.NodeSelector{}
}

a.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms = append(a.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms, arch.AsNodeSelectorRequirement())
a.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms = append(a.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms, nodeSelectorForArch)
}

func GetArchFromAffinity(a *core.Affinity) api.ArangoDeploymentArchitectureType {
Expand Down
2 changes: 1 addition & 1 deletion pkg/deployment/resources/pod_creator_arangod.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ func (m *MemberArangoDPod) GetPodAffinity() *core.PodAffinity {
func (m *MemberArangoDPod) GetNodeAffinity() *core.NodeAffinity {
a := core.NodeAffinity{}

pod.AppendArchSelector(&a, m.status.Architecture.Default(m.spec.Architecture.GetDefault()))
pod.AppendArchSelector(&a, m.status.Architecture.Default(m.spec.Architecture.GetDefault()).AsNodeSelectorRequirement())

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

Expand Down
2 changes: 1 addition & 1 deletion pkg/deployment/resources/pod_creator_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func (m *MemberSyncPod) GetPodAffinity() *core.PodAffinity {
func (m *MemberSyncPod) GetNodeAffinity() *core.NodeAffinity {
a := core.NodeAffinity{}

pod.AppendArchSelector(&a, m.memberStatus.Architecture.Default(m.spec.Architecture.GetDefault()))
pod.AppendArchSelector(&a, m.memberStatus.Architecture.Default(m.spec.Architecture.GetDefault()).AsNodeSelectorRequirement())

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

Expand Down