Skip to content

[JENKINS-74912] Fix Docker Windows non-C workspaces #332

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MarkRx
Copy link
Contributor

@MarkRx MarkRx commented Jan 20, 2025

Docker windows running windows does not support mounting non-C drive paths. It does however support mounting the entire drive. This change mounts the entire drive when we detect a non-C drive is being used for the workspace as a workaround.

Change includes a test that runs on Windows when Windows containers are enabled and a D drive exists (or gets skipped otherwise). Additionally tests now ensure docker is running in the corresponding OS mode using Assume.

Merge #326 first.

See JENKINS-74912
See Stack Overflow
See Github #41681

Testing done

  • Unit test exists to test case if underlying os and installed software support it (Windows, windows containers, D drive mounted)
  • Tested on a running instance with the following:
pipeline {
    agent {
        label 'docker_windows1809'
    }

    stages {
        stage('Stage') {
            steps {
                ws("N:/jenkins/multi space space") {
                    script {
                        docker.image('microsoft-images-docker.registry.paychex.com/windows/servercore:ltsc2019').inside {
                            bat "echo %cd%"
                        }
                    }
                }
            }
        }
    }
}

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

@basil basil changed the title JENKINS-74912 Fix Docker Windows non-C drive mounts [JENKINS-74912] Fix Docker Windows non-C drive mounts Jan 20, 2025
Copy link
Member

@basil basil left a comment

Choose a reason for hiding this comment

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

Seems like silently mounting the whole drive would violate the principle of least surprise.

@MarkRx
Copy link
Contributor Author

MarkRx commented Jan 20, 2025

Seems like silently mounting the whole drive would violate the principle of least surprise.

The alternative would be to put the logic in WithContainerStep since that directly controls what is mounted. I'm making that change now.

@MarkRx MarkRx force-pushed the bugfix/JENKINS-74912 branch from 278713b to 9311627 Compare January 20, 2025 20:38
@MarkRx MarkRx requested a review from basil January 20, 2025 22:51
@basil
Copy link
Member

basil commented Jan 21, 2025

Same feedback applies. Seems surprising to mount the whole drive when the user requested only a subdirectory to be mounted. What if the drive contained a secret that the user did not want to expose?

@MarkRx
Copy link
Contributor Author

MarkRx commented Jan 21, 2025

I updated the title to avoid confusion. The latest change only works around if the workspace is on a different drive.

Users wouldn't interface with this logic. The plugin controls when the workspace is bind mounted to the container when launching it. Any manual user arguments (such as volumes) would still be passed in verbatim. I updated the title to reflect this - instead of changing all volumes the workaround only applies if the Jenkins workspace is on a different drive. Users can control the value the pass with -v so can (and will have to) workaround any non-C mounts themselves by mounting the whole drive explicitly.

Permissions would be no different than a job that ran directly on the agent as the entire drive would already be mounted and available. If D:/foo is accessible from the agent, then D:/foo will be accessible by the container. If D:/foo is not accessible by the agent then D:/foo will not be accessible by the container provided the container runs as the same user. In other words mounting a separate volume in the container would look the same as not running inside the container.

@MarkRx MarkRx changed the title [JENKINS-74912] Fix Docker Windows non-C drive mounts [JENKINS-74912] Fix Docker Windows non-C workspaces Jan 21, 2025
@basil
Copy link
Member

basil commented Jan 28, 2025

Sorry, I can't understand the above explanation. That might be because I don't know much about Windows Docker or this plugin. Might be best to wait for another reviewer or to adopt the plugin instead.

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