Skip to content

Commit

Permalink
Backports of Cloning PRs #280 and #297 to 1.1 branch (#301)
Browse files Browse the repository at this point in the history
* Invoke tar from same location in source and target mode (#297)

When cloning we were invoking tar at the container root in the source
mode and within the volume mount in target mode.  The result was the
disk.img file appearing in a tmp/clone/image subdirectory in the target
pvc instead of being copied exactly.

Signed-off-by: Adam Litke <alitke@redhat.com>

* Having the cloning label in the target pod, make the pod affinity fails. (#280)

The target pod looks for a pod with a specific label (specified in the pod affinity) that matches the source pod label.
In my case the target pod included this label as well, so we can see that the target pod found matching pod, but it is the WRONG pod. It's itself!!
The target was running without finding the source pod first.
If we remove this label from the target pod, it will find the source pod and then will be scheduled on the same node.
If it does not find the source pod (because the scheduler tried to schedule it before the source pod), it will be in 'Pending' state until the source pod is scheduled, and then will be running on the same node.
#279
  • Loading branch information
aglitke authored and jeffvance committed Aug 1, 2018
1 parent a860514 commit 2925c85
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion cmd/cdi-cloner/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ if [ "$1" == "source" ] ; then
echo "creating fifo pipe"
mkfifo /tmp/clone/socket/$2/pipe
echo "creating tarball of the image and redirecting it to /tmp/clone/socket/$2/pipe"
tar cv /tmp/clone/image/ > /tmp/clone/socket/$2/pipe
pushd /tmp/clone/image
tar cv . > /tmp/clone/socket/$2/pipe
popd
echo "finished writing image to /tmp/clone/socket/$2/pipe"
elif [ "$1" == "target" ] ; then
echo "Starting clone target"
Expand Down
7 changes: 5 additions & 2 deletions pkg/controller/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,7 @@ func MakeCloneTargetPodSpec(image, verbose, pullPolicy string, pvc *v1.Persisten
AnnCloningCreatedBy: "yes",
},
Labels: map[string]string{
CDI_LABEL_KEY: CDI_LABEL_VALUE, //filtered by the podInformer
CLONING_LABEL_KEY: CLONING_LABEL_VALUE + "-" + generatedLabelStr, //used by PodAffinity
CDI_LABEL_KEY: CDI_LABEL_VALUE, //filtered by the podInformer
},
},
Spec: v1.PodSpec{
Expand Down Expand Up @@ -491,6 +490,10 @@ func MakeCloneTargetPodSpec(image, verbose, pullPolicy string, pvc *v1.Persisten
Name: CLONER_TARGET_PODNAME,
Image: image,
ImagePullPolicy: v1.PullPolicy(pullPolicy),
SecurityContext: &v1.SecurityContext{
Privileged: &[]bool{true}[0],
RunAsUser: &[]int64{0}[0],
},
VolumeMounts: []v1.VolumeMount{
{
Name: ImagePathName,
Expand Down

0 comments on commit 2925c85

Please sign in to comment.