Bug 1386725 - Hawkular containers fail to start on Atomic due to file permission
Summary: Hawkular containers fail to start on Atomic due to file permission
Keywords:
Status: VERIFIED
Alias: None
Product: Middleware Manager
Classification: JBoss
Component: Other
Version: 7.0.0 TP2
Hardware: Unspecified
OS: Unspecified
high
unspecified
Target Milestone: ---
: ---
Assignee: Matt Wringe
QA Contact:
URL:
Whiteboard:
Depends On: 1387423
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-10-19 14:10 UTC by Viet Nguyen
Modified: 2022-03-31 04:27 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:


Attachments (Terms of Use)
cassandra stdout log (66.77 KB, image/png)
2016-10-19 14:10 UTC, Viet Nguyen
no flags Details
data dir as seen inside cnode container (78.47 KB, image/png)
2016-10-19 14:13 UTC, Viet Nguyen
no flags Details
hawkular stdout log (75.32 KB, image/png)
2016-10-19 14:15 UTC, Viet Nguyen
no flags Details
Getting started page (103.00 KB, image/png)
2016-11-03 15:33 UTC, Viet Nguyen
no flags Details

Description Viet Nguyen 2016-10-19 14:10:08 UTC
Created attachment 1212164 [details]
cassandra stdout log

Description of problem:
File permission errors prevent Cassandar and Hawkular server container from starting up

Version-Release number of selected component (if applicable):

Image: 
brew-pulp-docker01.web.prod.ext.phx2.redhat.com:8888/hawkular/hawkular-services :0.0.16.Final-redhat-1 

brew-pulp-docker01.web.prod.ext.phx2.redhat.com:8888/jboss/cassandra:3.7.0.redhat-2

How reproducible:
100%

Steps to Reproduce:
1. Provision RHEl Atomic 7.1 on OS1
2. Follow instructions to launch cassandra and hawkular container https://docs.engineering.redhat.com/display/JP/CloudForms+Middleware+-+Quickstart+Guide

Actual results:
Cassandra and Hawkular Services containers fail to start

Expected results:
Containers start w/o file permission errors

Additional info:

Comment 2 Viet Nguyen 2016-10-19 14:13:16 UTC
Created attachment 1212165 [details]
data dir as seen inside cnode container

Comment 3 Viet Nguyen 2016-10-19 14:15:44 UTC
Created attachment 1212166 [details]
hawkular stdout log

Comment 5 Paul Gier 2016-10-20 20:48:11 UTC
It looks like the cassandra and hs process are not running as the root user.  I've had it on my todo list for a while to fix the cassandra container to not need root to access the data dir, I created bz1387423 to fix this, and hopefully should be ready in the next DR.

Are you starting the containers via kubernetes, or just with regular command line?

Comment 6 Viet Nguyen 2016-10-21 10:27:58 UTC
I started the 2 containers with `docker run` but the environment is RHEL Atomic 7.  The team has been testing in RHEL7.  You're correct that HS and Cassandra container should be able to run as as non-root (or as arbitrary user per OpenShift image guidelines) unless we have a good reason to run as root.

Comment 7 Paul Gier 2016-10-21 13:46:31 UTC
When starting with 'docker run' did you use the --user option, or does Atomic have some config which automatically uses a different user?  The current Cassandra image should be able to run as non-root, but you have to set the volume (/opt/apache-cassandra/data) permissions outside the container.

Something like this:

chown myuser:myuser /tmp/mydatadir
docker run -d -v /tmp/mydatadir:/opt/apache-cassandra/data:Z --user $(id -u myuser) jboss/casssandra

Comment 8 Viet Nguyen 2016-10-21 15:57:13 UTC
I didn't use --user option.  I can confirm that hawkular-casssandra container runs fine if I specify the -v option

Comment 9 Paul Gier 2016-10-26 19:57:59 UTC
I have changed the cassandra and hawkular containers in bz1387423 so that neither of them runs as root by default.  I'll update the quickstart doc with some info related to the volume configuration.

Comment 10 Viet Nguyen 2016-10-31 12:05:04 UTC
Still failing if -v flag is omitted.

# docker run -d --name hawkular-cassandra --user root -e MAX_HEAPSIZE=1024M -e CASSANDRA_START_RPC=true brew-pulp-docker01.web.prod.ext.phx2.redhat.com:8888/jboss/cassandra:latest

Output:

# docker logs hawkular-cassandra
WARNING: Container started without specifiying user,  this configuration is not supported for production
chown: changing ownership of '/opt/apache-cassandra/data': Permission denied

# cat /etc/redhat-release 
Red Hat Enterprise Linux Atomic Host release 7.1

Comment 11 Paul Gier 2016-11-01 13:50:02 UTC
This is probably due to selinux policy on the host filesystem.
Can you try running the container with the selinux label turned off?
# docker run --security-opt label:disable ...

If this is the cause of the permissions issue, then we'll have to decide whether we want to support running the container as root, and how it should be configured.  Currently when you run the container as root, it tries to create a VOLUME in a default location.  We could remove this VOLUME config from the Dockerfile, but this could hurt disk I/O performance and will cause the data to be lost when the container is destroyed.  Another option is to just require the user to configure a volume and run the container with a specific userid.

Some additional info here:
http://www.projectatomic.io/blog/2016/03/dwalsh_selinux_containers/
http://www.projectatomic.io/blog/2015/06/using-volumes-with-docker-can-cause-problems-with-selinux/

Comment 12 Paul Gier 2016-11-01 13:52:00 UTC
Also, if you run "docker inspect" on the container, what is the location where the volume is being created?  It should be visible under "Mounts:, Source:".

Comment 13 Viet Nguyen 2016-11-01 20:26:09 UTC
Cassandra container can start after disabling SELinux for Docker.

Important discovery: I was on RHEL Atomic 7.1 where Docker is older

# docker version
Client version: 1.4.1-dev
Client API version: 1.17
Go version (client): go1.3.1
Git commit (client): d26b358/1.4.1
OS/Arch (client): linux/amd64
Server version: 1.4.1-dev
Server API version: 1.17
Go version (server): go1.3.1
Git commit (server): d26b358/1.4.1


Switched to 7.2 the startup problem went away without the need to disable SELinux

-bash-4.2# cat /etc/redhat-release 
Red Hat Enterprise Linux Atomic Host release 7.2
-bash-4.2# docker version
Client:
 Version:      1.8.2
 API version:  1.20
 Package Version: docker-1.8.2-8.el7.x86_64
 Go version:   go1.4.2
 Git commit:   a01dc02/1.8.2
 Built:        
 OS/Arch:      linux/amd64

Server:
 Version:      1.8.2
 API version:  1.20
 Package Version: 
 Go version:   go1.4.2
 Git commit:   a01dc02/1.8.2
 Built:        
 OS/Arch:      linux/amd64

Comment 14 Paul Gier 2016-11-02 12:53:46 UTC
Great!  Is there anything left to do on this issue?  Sounds like we just need to document the different options for the user.

Comment 15 Viet Nguyen 2016-11-02 13:33:59 UTC
Perhaps state the minimum Docker version requirement in your Getting Started page?

Comment 16 Paul Gier 2016-11-03 14:40:44 UTC
Ok, I added a note to the quickstart wiki page to use RHEL 7.2 or Atomic Host 7.2 and Docker 1.8 or higher.

Comment 17 Viet Nguyen 2016-11-03 15:33:53 UTC
Created attachment 1217066 [details]
Getting started page


Note You need to log in before you can comment on or make changes to this bug.