Skip to content

Commit

Permalink
fix disks-images-provider error in ubuntu host
Browse files Browse the repository at this point in the history
In ubuntu host, selinux is not enabled by default.
When starting disks-images-provider, following failure
would appear:
"can't apply partial context to unlabeled file".
Check if file selinux tag exist before use chcon.

Signed-off-by: Howard Zhang <[email protected]>
  • Loading branch information
zhlhahaha committed Jun 18, 2020
1 parent 2b35c0c commit 7cf80c3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion images/disks-images-provider/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ set -euo pipefail

# gracefully handle the TERM signal sent when deleting the daemonset
trap 'exit' TERM
SELINUX_TAG=$(ls -Z)

mkdir -p /images/datavolume1 /images/datavolume2 /images/datavolume3

Expand All @@ -38,7 +39,12 @@ rm /images/fedora-cloud/disk.qcow2
echo "copy all images to host mount directory"
cp -R /images/* /hostImages/
chmod -R 777 /hostImages
chcon -Rt svirt_sandbox_file_t /hostImages

# When the host is ubuntu, by default, selinux is not used, so chcon is not necessary.
# If selinux tag is set, use chcon to change /hostImages privileges.
if [ ${SELINUX_TAG:0:1} != "?" ]; then
chcon -Rt svirt_sandbox_file_t /hostImages
fi

# for some reason without sleep, container sometime fails to create the file
sleep 10
Expand Down

0 comments on commit 7cf80c3

Please sign in to comment.