From 72beb35edca6873f4aab5216e49416a746e86aef Mon Sep 17 00:00:00 2001 From: Xun Jiang/Bruce Jiang <59276555+blackpiglet@users.noreply.github.com> Date: Sat, 24 Jan 2026 03:27:50 +0800 Subject: [PATCH] Maintenance Job only uses the first element of the LoadAffinity array from the ConfigMap. (#9494) Signed-off-by: Xun Jiang --- changelogs/unreleased/9494-blackpiglet | 1 + pkg/repository/maintenance/maintenance.go | 3 ++- .../docs/main/repository-maintenance.md | 19 +++---------------- 3 files changed, 6 insertions(+), 17 deletions(-) create mode 100644 changelogs/unreleased/9494-blackpiglet diff --git a/changelogs/unreleased/9494-blackpiglet b/changelogs/unreleased/9494-blackpiglet new file mode 100644 index 000000000..ac062ddaf --- /dev/null +++ b/changelogs/unreleased/9494-blackpiglet @@ -0,0 +1 @@ +Maintenance Job only uses the first element of the LoadAffinity array \ No newline at end of file diff --git a/pkg/repository/maintenance/maintenance.go b/pkg/repository/maintenance/maintenance.go index 52aaa0e03..496d07703 100644 --- a/pkg/repository/maintenance/maintenance.go +++ b/pkg/repository/maintenance/maintenance.go @@ -671,7 +671,8 @@ func buildJob( } if config != nil && len(config.LoadAffinities) > 0 { - affinity := kube.ToSystemAffinity(config.LoadAffinities) + // Maintenance job only takes the first loadAffinity. + affinity := kube.ToSystemAffinity([]*kube.LoadAffinity{config.LoadAffinities[0]}) job.Spec.Template.Spec.Affinity = affinity } diff --git a/site/content/docs/main/repository-maintenance.md b/site/content/docs/main/repository-maintenance.md index c9c76a677..5ca4f3a8a 100644 --- a/site/content/docs/main/repository-maintenance.md +++ b/site/content/docs/main/repository-maintenance.md @@ -77,19 +77,6 @@ data: }, "keepLatestMaintenanceJobs": 1, "loadAffinity": [ - { - "nodeSelector": { - "matchExpressions": [ - { - "key": "cloud.google.com/machine-family", - "operator": "In", - "values": [ - "e2" - ] - } - ] - } - }, { "nodeSelector": { "matchExpressions": [ @@ -119,10 +106,10 @@ data: } EOF ``` -This sample showcases two affinity configurations: -- matchLabels: maintenance job runs on nodes with label key `cloud.google.com/machine-family` and value `e2`. +Notice: although loadAffinity is an array, Velero only takes the first element of the array. + +This sample showcases how to use affinity configuration: - matchLabels: maintenance job runs on nodes located in `us-central1-a`, `us-central1-b` and `us-central1-c`. -The nodes matching one of the two conditions are selected. To create the configMap, users need to save something like the above sample to a json file and then run below command: ```