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 @@ -4,6 +4,7 @@
- Add Labels and Annotations to ServiceMonitor
- Allow to expose Exporter in HTTP with secured Deployments
- Change rotation by annotation order (coordinator before dbserver)
- Fix NodeAffinity propagation

## [1.0.4](https://github.com/arangodb/kube-arangodb/tree/1.0.4) (2020-07-28)
- Add Encryption Key rotation feature for ArangoDB EE 3.7+
Expand Down
13 changes: 7 additions & 6 deletions pkg/deployment/deployment_affinity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -673,14 +673,15 @@ func TestEnsurePod_ArangoDB_NodeAffinity(t *testing.T) {
Subdomain: testDeploymentName + "-int",
Affinity: modifyAffinity(testDeploymentName, api.ServerGroupDBServersString,
false, "", func(a *core.Affinity) {
n := core.NodeSelectorTerm{
MatchFields: []core.NodeSelectorRequirement{
{
Key: "key",
},
f := a.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms[0]

f.MatchFields = []core.NodeSelectorRequirement{
{
Key: "key",
},
}
a.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms = append(a.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms, n)

a.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms[0] = f
}),
},
},
Expand Down
25 changes: 19 additions & 6 deletions pkg/deployment/pod/affinity.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,28 @@ func MergeNodeAffinity(a, b *core.NodeAffinity) {
a.PreferredDuringSchedulingIgnoredDuringExecution = append(a.PreferredDuringSchedulingIgnoredDuringExecution, rule)
}

if b.RequiredDuringSchedulingIgnoredDuringExecution != nil {
if a.RequiredDuringSchedulingIgnoredDuringExecution == nil {
a.RequiredDuringSchedulingIgnoredDuringExecution = b.RequiredDuringSchedulingIgnoredDuringExecution.DeepCopy()
} else {
for _, rule := range b.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms {
a.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms = append(a.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms, rule)
var newSelectorTerms []core.NodeSelectorTerm

if b.RequiredDuringSchedulingIgnoredDuringExecution == nil || len(b.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms) == 0 {
newSelectorTerms = a.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms
} else if a.RequiredDuringSchedulingIgnoredDuringExecution == nil || len(a.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms) == 0 {
newSelectorTerms = b.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms
} else {
for _, aTerms := range a.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms {
for _, bTerms := range b.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms {
term := aTerms.DeepCopy()
if len(bTerms.MatchExpressions) != 0 {
term.MatchExpressions = append(term.MatchExpressions, bTerms.MatchExpressions...)
}
if len(bTerms.MatchFields) != 0 {
term.MatchFields = append(term.MatchFields, bTerms.MatchFields...)
}
newSelectorTerms = append(newSelectorTerms, *term)
}
}
}

a.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms = newSelectorTerms
}

func ReturnPodAffinityOrNil(a core.PodAffinity) *core.PodAffinity {
Expand Down