#331 docker: Use is-active to determine docker status
Merged 5 years ago by astepano. Opened 5 years ago by till.
till/standard-test-roles use_is_active  into  master

@@ -86,13 +86,18 @@ 

          raise RuntimeError("Could not parse DOCKER_EXTRA_ARGS")

      logger.info("Launching Docker container for {0}".format(image))

      # Make sure the docker service is running

-     cmd = [

-         "/usr/bin/systemctl", "start", "docker"

-     ]

      try:

-         subprocess.check_call(cmd, stdout=sys.stderr.fileno())

+         subprocess.check_call(["/usr/bin/systemctl", "is-active", "--quiet", "docker"],

+                               stdout=sys.stderr.fileno())

      except subprocess.CalledProcessError:

-         raise RuntimeError("Could not start docker service")

+         try:

+             cmd = [

+                 "/usr/bin/systemctl", "start", "docker"

+             ]

+             subprocess.check_call(cmd, stdout=sys.stderr.fileno())

+         except subprocess.CalledProcessError:

+             raise RuntimeError("Could not start docker service")

+ 

      # And launch the actual container

      cmd = [

          "/usr/bin/docker", "run", "--detach", "--cidfile={0}".format(cidfile),

Only run systemctl start docker when systemctl is-active docker
fails. The start command is privileged and therefore requires manual
authentication if it is run by a non-root user even if the service is
already active. The check with is-active is possible without special
privileges. This allows to use the inventory file if the current user is
in the docker group.

Jenkins seems to point to the wrong URL, it mentions a commit by Stef Walter instead of mine:
https://jenkins-fedora-atomic-process.apps.ci.centos.org/job/str_pr_test/346/changes#detail0

Btw. an alternative would be to not start the docker service at all... It seems to be a little bit intrusive IMHO.

rebased onto 5749801

5 years ago

Seems the jenkins log is correct but it is not very clear where to find the actual failure IMHO. Should be fixed now.

I've tested the copr build for this PR [1] and it worked well.

I think it is nice improvement not start the service if it is already started.

Just note the STI [2] says the playbook must be run as root.

[1] https://copr.fedorainfracloud.org/coprs/g/osci/standard-test-roles/build/884105/
[2] https://docs.fedoraproject.org/en-US/ci/standard-test-interface/#_invocation

Commit bafaf13 fixes this pull-request

Pull-Request has been merged by astepano

5 years ago

Pull-Request has been merged by astepano

5 years ago