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

Try .cmd file extension suffix for credential helpers on Windows #2399

Closed
chanseokoh opened this issue Apr 10, 2020 · 7 comments · Fixed by #2403
Closed

Try .cmd file extension suffix for credential helpers on Windows #2399

chanseokoh opened this issue Apr 10, 2020 · 7 comments · Fixed by #2403
Assignees
Milestone

Comments

@chanseokoh
Copy link
Member

On Windows, gcloud auth configure-docker generates the following section in ~/.docker/config.json to specify that the cred helper is docker-credential-gcloud.

"credHelpers": {
    "gcr.io": "gcloud",
    "us.gcr.io": "gcloud",
    "eu.gcr.io": "gcloud",
    "asia.gcr.io": "gcloud",
    "staging-k8s.gcr.io": "gcloud"
},

The actual binary to run is docker-credential-gcloud.cmd. Without .cmd, Jib doesn't seem able to run the binary.

[WARNING] The system does not have docker-credential-gcloud CLI
[WARNING]   Caused by: Cannot run program "docker-credential-gcloud": CreateProcess error=2, The system cannot find the file specified

docker-compose suffered from the same issue, and the workaround was to manually change gcloud to gcloud.cmd in ~/docker.config.json. OTOH, apparently, Docker CLI has been working without .cmd.

@chanseokoh chanseokoh added this to the v2.2.0 milestone Apr 10, 2020
@chanseokoh chanseokoh self-assigned this Apr 13, 2020
@chanseokoh
Copy link
Member Author

chanseokoh commented Apr 13, 2020

It is speculated that, for a binary to be exectuable on Windows, it should have an executable extension. For example, @matthewmichihara reported that copying docker-credential-gcloud.cmd to docker-credential-gcloud did not resolve the issue.

Therefore, it may be necessary to also try .EXE, .COM, .BAT, etc. However, we had not received a report until now, so I think I'll just try .CMD first and watch. Also, .COM and .BAT are kind of deprecated and probably no longer in use in practice.

PS C:\Users\matth\AppData\Local\google\ct4j-cloud-sdk\LATEST\google-cloud-sdk\bin> cp .\docker-credential-gcloud.cmd docker-credential-gcloud
PS C:\Users\matth\AppData\Local\google\ct4j-cloud-sdk\LATEST\google-cloud-sdk\bin> ls


  Directory: C:\Users\matth\AppData\Local\google\ct4j-cloud-sdk\LATEST\google-cloud-sdk\bin


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----        4/10/2020   3:13 PM                bootstrapping
d-----        4/10/2020   3:13 PM                sdk
-a----        2/27/2020   4:49 PM       65257984 anthoscli.exe
-a----        3/13/2020  11:04 AM           4591 bq-ps.ps1
-a----        3/13/2020  11:04 AM           5277 bq.cmd
-a----        4/10/2020   3:12 PM           2901 dev_appserver.py
-a----        3/23/2020   9:38 PM            200 docker-credential-gcloud
-a----        3/23/2020   9:38 PM            200 docker-credential-gcloud.cmd
-a----        4/10/2020   3:12 PM            945 endpointscfg.py
-a----        4/10/2020   3:12 PM           5904 gcloud
-a----        3/23/2020   9:38 PM           4581 gcloud-ps.ps1
-a----        3/23/2020   9:38 PM           5543 gcloud.cmd
-a----        3/23/2020   9:38 PM            354 git-credential-gcloud.cmd
-a----        3/13/2020  11:04 AM           4714 gsutil-ps.ps1
-a----        3/13/2020  11:04 AM           5324 gsutil.cmd
-a----        3/23/2020   9:38 PM           5293 java_dev_appserver.cmd
-a----        4/10/2020   3:12 PM           5930 java_dev_appserver.sh
-a----        3/16/2020   4:57 PM       54646784 minikube.exe

@chanseokoh
Copy link
Member Author

@matthewmichihara can you test out the matt-test-cred-helper-cmd-windows branch?

$ git clone https:/GoogleContainerTools/jib.git
$ cd jib
$ git checkout matt-test-cred-helper-cmd-windows
$ ./gradlew :jib-maven-plugin:install

Then, use the 2.1.1-SNAPSHOT version. It should work in all cases:

  • both -Djib.to.credHelper=gcloud and -Djib.to.credHelper=gcloud.cmd
  • both gcloud and gcloud.cmd for "credHelpers": in ~/.docker/config.json

@matthewmichihara
Copy link

Thank you @chanseokoh!

I just tried this out and it does seem to fix the issue I was seeing.

Tests I've tried:

Jib 2.1.0 and 2.1.1-SNAPSHOT

Cloud Run deploy through Cloud Code with default ~/.docker/config.json on Windows.

// ~/.docker/config.json
{
  "stackOrchestrator": "swarm",
  "credsStore": "desktop"
}

Deploy failed with:

[WARNING] The credential helper (docker-credential-desktop) has nothing for server URL: gcr.io

Got output:

credentials not found in native keychain

Jib 2.1.0

Cloud Run deploy through Cloud Code with ~/.docker/config.json after running gcloud auth configure-docker on Windows.

// ~/.docker/config.json
{
  "credHelpers": {
    "gcr.io": "gcloud",
    "marketplace.gcr.io": "gcloud",
    "eu.gcr.io": "gcloud",
    "us.gcr.io": "gcloud",
    "staging-k8s.gcr.io": "gcloud",
    "asia.gcr.io": "gcloud"
  },
  "stackOrchestrator": "swarm",
  "credsStore": "desktop"
}

Deploy failed with:

[WARNING] The system does not have docker-credential-gcloud CLI
[WARNING]   Caused by: Cannot run program "docker-credential-gcloud": CreateProcess error=2, The system cannot find the file specified

Jib 2.1.1-SNAPSHOT

Cloud Run deploy through Cloud Code with ~/.docker/config.json after running gcloud auth configure-docker on Windows.

// ~/.docker/config.json
{
  "credHelpers": {
    "gcr.io": "gcloud",
    "marketplace.gcr.io": "gcloud",
    "eu.gcr.io": "gcloud",
    "us.gcr.io": "gcloud",
    "staging-k8s.gcr.io": "gcloud",
    "asia.gcr.io": "gcloud"
  },
  "stackOrchestrator": "swarm",
  "credsStore": "desktop"
}

Deploy succeeds with:

[INFO] Using credentials from Docker config (C:\Users\matth\.docker\config.json) for gcr.io/spokane/untitled

The behavior of this change LGTM. On the Cloud Code side, I think we'll need to make sure we run gcloud auth configure-docker.

@chanseokoh
Copy link
Member Author

Thanks. Could you test -Djib.to.credHelper=gcloud and -Djib.to.credHelper=gcloud.cmd too? It goes to a different path, and both of them should work.

@matthewmichihara
Copy link

Confirmed that both of those flags work as expected:

[INFO] Using credential helper docker-credential-gcloud for gcr.io/spokane/untitled
[INFO] Using credential helper docker-credential-gcloud.cmd for gcr.io/spokane/untitled

@chanseokoh
Copy link
Member Author

@matthewmichihara this is fixed in 2.2.0 we released last Friday.

@matthewmichihara
Copy link

great, thanks!

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 a pull request may close this issue.

2 participants