Skip to content

Commit

Permalink
Use local-cluster label in backup policy
Browse files Browse the repository at this point in the history
Self-managed hubs might not always be named local-cluster.

Refs:
 - https://issues.redhat.com/browse/ACM-13274

Signed-off-by: Justin Kulikauskas <[email protected]>
(cherry picked from commit 82fa508)
  • Loading branch information
JustinKuli authored and Magic Mirror committed Aug 26, 2024
1 parent 970dc6d commit a641720
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,12 @@ spec:
{{- $volsync_pvcs := "hub-pvc-backup-pvcs" }}
{{- $volsync_restore_cond := eq ( lookup "v1" "ConfigMap" $ns $volsync_pvcs ).metadata.name $volsync_pvcs }}
{{- $has_local_cluster_ns := eq (lookup "cluster.open-cluster-management.io/v1" "ManagedCluster" "" "local-cluster").metadata.name "local-cluster" }}
{{- $is_hub := "is-hub" }}
{{- $local_cls := "local-cluster" }}
{{- $local_cls_name := index (lookup "cluster.open-cluster-management.io/v1" "ManagedCluster" "" "" "local-cluster=true") "items" 0 "metadata" "name" }}
{{- /* Create the volsync addon - if BackupSchedule exists and there are PVCs with volsync label */ -}}
{{ if or (and $pv_claim_cond $volsync_backup_cond) $volsync_restore_cond }}
{{- range $hub_managed_cls := (lookup "cluster.open-cluster-management.io/v1" "ManagedCluster" "" "" $is_hub).items }}
{{ if not ( eq $hub_managed_cls.metadata.name $local_cls ) }}
{{- range $hub_managed_cls := (lookup "cluster.open-cluster-management.io/v1" "ManagedCluster" "" "" "is-hub").items }}
{{ if not ( eq $hub_managed_cls.metadata.name $local_cls_name ) }}
- complianceType: musthave
objectDefinition:
apiVersion: addon.open-cluster-management.io/v1alpha1
Expand All @@ -147,14 +146,14 @@ spec:
type: Available
{{- end }}
{{- end }}
{{ if $has_local_cluster_ns }}
{{ if $local_cls_name }}
- complianceType: musthave
objectDefinition:
apiVersion: addon.open-cluster-management.io/v1alpha1
kind: ManagedClusterAddOn
metadata:
name: volsync
namespace: {{ $local_cls }}
namespace: {{ $local_cls_name }}
labels:
cluster.open-cluster-management.io/backup: volsync
spec:
Expand Down

0 comments on commit a641720

Please sign in to comment.