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

Update che.sh #1329

Merged
merged 4 commits into from
May 23, 2016
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 39 additions & 5 deletions assembly/assembly-main/src/assembly/bin/che.sh
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,45 @@ get_docker_ready () {
if [ "${WIN}" == "true" ] || [ "${MAC}" == "true" ]; then
launch_docker_vm
else
# If Linux and docker ps fails, then this likely a file permissions issue.
error_exit "Running 'docker' succeeded, but 'docker ps' failed. `
`This usually means that docker cannot reach its daemon. `
`On Mac and Linux, check the read / write permissions on '/var/run/docker.sock'. `
`Consider running 'sudo chmod 777 /var/run/docker.sock'."

# CHE-1202: Improve error messages in case of docker ps failure
# Verify that /var/run/docker.sock has owner and group read / write permissions
PERMS=$(stat -c %A /var/run/docker.sock)

Choose a reason for hiding this comment

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

  1. Even if docker.sock has owner/group rw permission it doesn't mean that current user is owner or included in needed group.
  2. docker.sock can have rw permission for others.
  3. sudo chmod 660 /var/run/docker.sock will help only when user has needed id or gid

Copy link
Author

Choose a reason for hiding this comment

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

We perform the uid check elsewhere in the script. It is checked before getting to this step.

OWNERREAD=$(cut -c2 <(echo $PERMS))
OWNERWRITE=$(cut -c3 <(echo $PERMS))

Choose a reason for hiding this comment

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

Hard to read, use camelcase or underscore

GROUPREAD=$(cut -c5 <(echo $PERMS))
GROUPWRITE=$(cut -c6 <(echo $PERMS))

if [[ "$OWNERREAD" != "r" || "$OWNERWRITE" != "w" || "$GROUPREAD" != "r" || "$GROUPWRITE" != "w" ]]; then
error_exit "Running 'docker' succeeded, but 'docker ps' failed. \n`
`The file /var/run/docker.sock does not have appropriate permissions. \n`
`OWNER READ: ${OWNERREAD} \n`
`OWNER WRITE: ${OWNERWRITE} \n`
`GROUP READ: ${GROUPREAD} \n`
`GROUP WRITE: ${GROUPWRITE} \n`
`Run 'sudo chmod 660 /var/run/docker.sock' to give the right permissions."
return
fi

# CHE-1202: Improve error messages in case of docker ps failure
# Verify that docker client and server versions match
DOCKERSERVERVERSION=$(docker version --format '{{.Server.Version}}')

Choose a reason for hiding this comment

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

Hard to read, use camelcase or underscore

DOCKERCLIENTVERSION=$(docker version --format '{{.Client.Version}}')

if [[ "$DOCKERSERVERVERSION" != "$DOCKERCLIENTVERSION" ]]; then
error_exit "Running 'docker' succeeded, but 'docker ps' failed. \n`
`The docker client version does not match the docker server version. \n`
`DOCKER SERVER: ${DOCKERSERVERVERSION} \n`
`DOCKER CLIENT: ${DOCKERCLIENTVERSION} \n`
`This can occur if you are running Che as a container itself. \n`
`The Che container has an internal docker client that uses your host's docker server. \n`
`Consider updating docker engine to have the versions match."
return
fi

error_exit "Running 'docker' succeeded, but 'docker ps' failed. \n`
`/var/run/docker.sock is ok and your docker client and server have matching versions. \n`
`Run 'docker ps' and inspect the output for additional clues."
return
fi
fi
Expand Down