replicatedhq/pvmigrate

Allow filtering by namespace

Closed this issue · 1 comments

gozer commented

A --namespace option could be useful for testing and targeted migrations

@DavidFluck, sounds fun ?

Makes sense to me!

And pretty easy to do, too - you could probably just drop it in

for _, pv := range matchingPVs {
if pv.Spec.ClaimRef != nil {
pvc, err := clientset.CoreV1().PersistentVolumeClaims(pv.Spec.ClaimRef.Namespace).Get(ctx, pv.Spec.ClaimRef.Name, metav1.GetOptions{})
if err != nil {
return nil, nil, fmt.Errorf("failed to get PVC for PV %s in %s: %w", pv.Spec.ClaimRef.Name, pv.Spec.ClaimRef.Namespace, err)
}
matchingPVCs[pv.Spec.ClaimRef.Namespace] = append(matchingPVCs[pv.Spec.ClaimRef.Namespace], *pvc)
namespaces = append(namespaces, pv.Spec.ClaimRef.Namespace)
} else {
return nil, nil, fmt.Errorf("PV %s does not have an associated PVC - resolve this before rerunning", pv.Name)
}
}