From ec6601ebc434ac967bc9f9f5a85dc3d8e42c44bb Mon Sep 17 00:00:00 2001 From: fredkan Date: Fri, 27 Aug 2021 17:33:05 +0800 Subject: [PATCH] support disk snapshot zone --- velero-plugin-for-alibabacloud/restore_item_action.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/velero-plugin-for-alibabacloud/restore_item_action.go b/velero-plugin-for-alibabacloud/restore_item_action.go index 9225ec3..53cbafd 100644 --- a/velero-plugin-for-alibabacloud/restore_item_action.go +++ b/velero-plugin-for-alibabacloud/restore_item_action.go @@ -93,6 +93,15 @@ func (p *RestoreItemAction) Execute(input *velero.RestoreItemActionExecuteInput) mountOptions := pv.Spec.MountOptions volumeMode := pv.Spec.VolumeMode nodeAffinity := pv.Spec.NodeAffinity + if len(nodeAffinity.Required.NodeSelectorTerms) > 0 && len(nodeAffinity.Required.NodeSelectorTerms[0].MatchExpressions) > 0 { + if nodeAffinity.Required.NodeSelectorTerms[0].MatchExpressions[0].Key == "topology.diskplugin.csi.alibabacloud.com/zone" { + volumeAZ, err := getMetaData(metadataZoneKey) + if err != nil { + return nil, errors.Errorf("Set NodeAffinity failed to get zone-id, got %v", err) + } + nodeAffinity.Required.NodeSelectorTerms[0].MatchExpressions[0].Values = []string{volumeAZ} + } + } pv.Spec = corev1api.PersistentVolumeSpec{ Capacity: getResourceList(minReqVolSizeString),