Skip to content

Use docker ps to detect absence of docker permissions #336

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

Merged
merged 1 commit into from
Feb 18, 2025

Conversation

MarkEWaite
Copy link
Contributor

@MarkEWaite MarkEWaite commented Feb 16, 2025

Use docker ps to detect absence of docker permissions

The plugin BOM agents seem to have the docker command available but the user running the agent is not authorized to use the docker command. Previously that was detected by calling docker ps and detecting the failure.

Restores a change made in

Testing done

Plugin BOM draft pull request to check it on weekly:

Confirmed that I could see the same failure on a local computer as is seen on https://ci.jenkins.io/job/Tools/job/bom/job/master/3968/testReport/org.jenkinsci.plugins.docker.workflow/DockerDSLTest/

The computer had Docker CE installed by the specific user running the test did not have permission to access Docker. Prior to this change, the tests failed with the message:

CANNOT CONNECT TO THE DOCKER DAEMON AT UNIX:///VAR/RUN/DOCKER.SOCK. IS THE DOCKER DAEMON RUNNING?

After making this change, the tests pass on that computer with the specific user that does not have permission to access Docker.

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

The plugin BOM agents seem to have the `docker` command available but the
user running the agent is not authorized to use the `docker` command.
Previously that was detected by calling `docker ps` and detecting the
failure.

Restores a change made in

* jenkinsci#331

Testing done

Confirmed that I could see the same failure on a local computer as is seen on
https://ci.jenkins.io/job/Tools/job/bom/job/master/3968/testReport/org.jenkinsci.plugins.docker.workflow/DockerDSLTest/

The computer had Docker CE installed by the specific user running the
test did not have permission to access Docker.  Prior to this change,
the tests failed with the message:

CANNOT CONNECT TO THE DOCKER DAEMON AT UNIX:///VAR/RUN/DOCKER.SOCK. IS THE DOCKER DAEMON RUNNING?

After making this change, the tests pass on that computer with the
specific user that does not have permission to access Docker.
@MarkEWaite MarkEWaite changed the title Use CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b94fe2361b21 docker.io/library/httpd:2.4.12 cat 5 hours ago Up 5 hours sleepy_dewdney 36b4e8866545 docker.io/library/ubuntu:latest cat 5 hours ago Up 5 hours admiring_zhukovsky to detect absence of docker permissions Use docker ps to detect absence of docker permissions Feb 16, 2025
@MarkEWaite MarkEWaite changed the title Use docker ps to detect absence of docker permissions Use docker ps to detect absence of docker permissions Feb 16, 2025
MarkEWaite added a commit to MarkEWaite/bom that referenced this pull request Feb 16, 2025
The 595.v60cec912059b_ tests fail on the ci.jenkins.io agents that are
used for BOM builds.  The failure message is:

> java.lang.IllegalArgumentException: No enum constant
> org.jenkinsci.plugins.docker.workflow.DockerTestUtil.DockerOsMode.
> CANNOT CONNECT TO THE DOCKER DAEMON AT UNIX:///VAR/RUN/DOCKER.SOCK. IS
> THE DOCKER DAEMON RUNNING?

A pull request has been proposed to resolve the failure by skipping
those tests on machines that have the docker executable available but
the user does not have permission to use docker.  The pull request is:

* jenkinsci/docker-workflow-plugin#336
MarkEWaite added a commit to MarkEWaite/bom that referenced this pull request Feb 16, 2025
The 595.v60cec912059b_ tests fail on the ci.jenkins.io agents that are
used for BOM builds.  The failure message is:

> java.lang.IllegalArgumentException: No enum constant
> org.jenkinsci.plugins.docker.workflow.DockerTestUtil.DockerOsMode.
> CANNOT CONNECT TO THE DOCKER DAEMON AT UNIX:///VAR/RUN/DOCKER.SOCK. IS
> THE DOCKER DAEMON RUNNING?

A pull request has been proposed to resolve the failure by skipping
those tests on machines that have the docker executable available but
the user does not have permission to use docker.  The pull request is:

* jenkinsci/docker-workflow-plugin#336

This commit tests that build in plugin BOM
@MarkEWaite
Copy link
Contributor Author

@basil could you review this and let me know if the approach is reasonable or if another approach should be used?

MarkEWaite added a commit to jenkinsci/bom that referenced this pull request Feb 17, 2025
The 595.v60cec912059b_ tests fail on the ci.jenkins.io agents that are
used for BOM builds.  The failure message is:

> java.lang.IllegalArgumentException: No enum constant
> org.jenkinsci.plugins.docker.workflow.DockerTestUtil.DockerOsMode.
> CANNOT CONNECT TO THE DOCKER DAEMON AT UNIX:///VAR/RUN/DOCKER.SOCK. IS
> THE DOCKER DAEMON RUNNING?

A pull request has been proposed to resolve the failure by skipping
those tests on machines that have the docker executable available but
the user does not have permission to use docker.  The pull request is:

* jenkinsci/docker-workflow-plugin#336
@basil basil merged commit 3e6972b into jenkinsci:master Feb 18, 2025
17 checks passed
@MarkEWaite MarkEWaite deleted the fix-tests-in-bom branch February 18, 2025 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants