Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1887526: only include pvc in volume mounts at stage restore of a pod #97

Merged
merged 1 commit into from Aug 11, 2021

Conversation

JaydipGabani
Copy link
Contributor

@JaydipGabani JaydipGabani commented Aug 3, 2021

This PR trim downs volumes and volume mounts to only PVCs while restoring pods in stage migration. Needed for the PR

Changes include:

  1. swapping container images with stage pod image and adding the command sleep to make the application pod look like stage pod
  2. trimming down the list of PVC to only the volumes that are required to copy over for containers of the pod.

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 3, 2021
exclude = append(exclude, volume.Name)
continue
}
pvcVolumes = append(pvcVolumes, volume)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need to filter this to exclude "move" and "snapshot copy" volumes from the pod, since these are excluded from stage restore, and the pod won't come up if it's missing volumes. What's not obvious is how to do that here.
@dymurray do you have any insight here? When creating stage pods in the controller, we can use the MigPlan selection values. We don't have access to the PVC annotations since those are in the backup, not in the cluster. Do we need to annotate application pods with a list of PVC exclusions? Basically when we add the stage labels to application pods on backup, in GetApplicationPodsWithStageLabels, when we find a PVC that should be excluded from the stage pod because it's a move or snapshot copy, we'll add its name to a PVC exclude list annotation, and the plugin here could make use of that. Is there a cleaner way to do this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically when we add the stage labels to application pods on backup, in GetApplicationPodsWithStageLabels, when we find a PVC that should be excluded from the stage pod because it's a move or snapshot copy, we'll add its name to a PVC exclude list annotation, and the plugin here could make use of that.

I've been trying to thinnk of a better way to do this and I haven't yet. This seems to be the cleanest way to make this work.

@JaydipGabani JaydipGabani marked this pull request as ready for review August 6, 2021 18:27
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 6, 2021
Copy link
Contributor

@sseago sseago left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the only real change needed here is to compare slice elements rather than using strings.Contain to avoid false positives in the results which may result in excluding needed volumes.

continue
}
if len(pod.Labels[common.ExcludePVCPodLabel]) > 0 {
if strings.Contains(pod.Labels[common.ExcludePVCPodLabel], volume.Name) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to split the Exclude label out into a slice and compare slice entries. In the simple case, "foo,bar,baz" does contain "foo" so we'll exclude foo, "foo1,foo2" will contain "foo" so foo would be erroneously skipped.

@@ -113,9 +113,55 @@ func (p *RestorePlugin) Execute(input *velero.RestoreItemActionExecuteInput) (*v
destStagePodImage := input.Restore.Annotations[common.StagePodImageAnnotation]
if len(pod.Labels[common.IncludedInStageBackupLabel]) > 0 && len(destStagePodImage) > 0 {
p.Log.Infof("[pod-restore] swapping stage pod images for pod %s", pod.Name)
pvcVolumes := []corev1API.Volume{}
exclude := []string{}
moveVolumes := []string{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: not a merge blocker, but a minor comment. It's slightly confusing to call this "moveVolumes" since it also includes snapshot copy volumes. "exclude" is already in use, though. Maybe "excludePVC" or "excludeAnnotation" or something like that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, removed excude as it was not being used

@dymurray
Copy link
Member

LGTM

@JaydipGabani JaydipGabani merged commit 5362c0b into openshift:master Aug 11, 2021
@JaydipGabani JaydipGabani changed the title only include pvc in volume mounts at stage restore of a pod Bug 1887526: only include pvc in volume mounts at stage restore of a pod Aug 11, 2021
@openshift-ci
Copy link

openshift-ci bot commented Aug 11, 2021

@JaydipGabani: All pull requests linked via external trackers have merged:

Bugzilla bug 1887526 has been moved to the MODIFIED state.

In response to this:

Bug 1887526: only include pvc in volume mounts at stage restore of a pod

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants