Skip to content

Commit

Permalink
Fix Restore PVC using Task Function method (#897)
Browse files Browse the repository at this point in the history
  • Loading branch information
suaas21 authored and tamalsaha committed Oct 4, 2019
1 parent 404840e commit 6692605
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
3 changes: 3 additions & 0 deletions pkg/controller/inputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ func (c *StashController) inputsForRestoreTarget(target *api.RestoreTarget) map[
} else {
inputs[apis.TargetMountPath] = apis.StashDefaultMountPath
}
if len(target.VolumeClaimTemplates) > 0 && target.Ref.Name == "" {
inputs[apis.TargetName] = target.VolumeClaimTemplates[0].ObjectMeta.Name
}
}
return inputs
}
Expand Down
14 changes: 8 additions & 6 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,14 @@ func AttachLocalBackend(podSpec core.PodSpec, localSpec store.LocalSpec) core.Po
}

func AttachPVC(podSpec core.PodSpec, volumes []core.Volume, volumeMounts []core.VolumeMount) core.PodSpec {
podSpec.Volumes = core_util.UpsertVolume(podSpec.Volumes, volumes...)
for i := range podSpec.InitContainers {
podSpec.InitContainers[i].VolumeMounts = core_util.UpsertVolumeMount(podSpec.InitContainers[i].VolumeMounts, volumeMounts...)
}
for i := range podSpec.Containers {
podSpec.Containers[i].VolumeMounts = core_util.UpsertVolumeMount(podSpec.Containers[i].VolumeMounts, volumeMounts...)
if len(volumeMounts) > 0 {
podSpec.Volumes = core_util.UpsertVolume(podSpec.Volumes, volumes...)
for i := range podSpec.InitContainers {
podSpec.InitContainers[i].VolumeMounts = core_util.UpsertVolumeMount(podSpec.InitContainers[i].VolumeMounts, volumeMounts...)
}
for i := range podSpec.Containers {
podSpec.Containers[i].VolumeMounts = core_util.UpsertVolumeMount(podSpec.Containers[i].VolumeMounts, volumeMounts...)
}
}
return podSpec
}
Expand Down

0 comments on commit 6692605

Please sign in to comment.