jfrog / jfrog-cli

JFrog CLI is a client that provides a simple interface that automates access to the JFrog products.
https://www.jfrog.com/confluence/display/CLI/JFrog+CLI
Apache License 2.0
531 stars 231 forks source link

jf rt docker-pull fails to create build info when pulling image using image:tag@sha256 #2341

Open dsbenghe opened 11 months ago

dsbenghe commented 11 months ago

Describe the bug

When using jf rt docker-pull it always fails to create the build info when used with a docker image with tag and sha256 i.e. jf rt docker-pull image:tag@sha256:sha256 but it works fine without a sha256 i.e jf rt docker-pull image:tag

The reason seems to be an incorrect aql query

Current behavior

jf rt docker-pull hostname/virtual-repository/any-path/container-name@sha256:e75b5b196d3441ded0ed4fb4503da2726d9e54a77dd4138aa0ede9f79664b9af virtual-repository --server-id ethos.buildinfo --build-name deptms-local-build-docker --build-number 999 --skip-login 23:10:43 [Debug] JFrog CLI version: 2.51.1 23:10:43 [Debug] OS/Arch: windows/amd64 23:10:43 [Debug] Sending HTTP GET request to: https://hostname/artifactory/api/system/version 23:10:43 [Debug] Artifactory response: 200 OK 23:10:43 [Debug] Usage Report: Sending info... 23:10:43 [Debug] Sending HTTP GET request to: https://hostname/artifactory/api/system/version 23:10:43 [Debug] Artifactory response: 200 OK 23:10:43 [Debug] JFrog Artifactory version is: 6.23.41 23:10:43 [Debug] Sending HTTP POST request to: https://hostname/artifactory/api/system/usage hostname/virtual-repository/any-path/container-name@sha256:e75b5b196d3441ded0ed4fb4503da2726d9e54a77dd4138aa0ede9f79664b9af: Pulling from virtual-repository/any-path/container-name Digest: sha256:e75b5b196d3441ded0ed4fb4503da2726d9e54a77dd4138aa0ede9f79664b9af Status: Image is up to date for hostname/virtual-repository/any-path/container-name@sha256:e75b5b196d3441ded0ed4fb4503da2726d9e54a77dd4138aa0ede9f79664b9af hostname/virtual-repository/any-path/container-name@sha256:e75b5b196d3441ded0ed4fb4503da2726d9e54a77dd4138aa0ede9f79664b9af

What's Next? View summary of image vulnerabilities and recommendations → docker scout quickview hostname/virtual-repository/any-path/container-name@sha256:e75b5b196d3441ded0ed4fb4503da2726d9e54a77dd4138aa0ede9f79664b9af 23:10:45 [Debug] Getting repository 'virtual-repository' details ... 23:10:45 [Debug] Sending HTTP GET request to: https://hostname/artifactory/api/repositories/virtual-repository 23:11:06 [🟠Warn] (Attempt 1) - Failure occurred while sending GET request to https://hostname/artifactory/api/repositories/virtual-repository: Get "https://hostname/artifactory/api/repositories/virtual-repository": dial tcp 100.64.1.2:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. 23:11:06 [Debug] Sending HTTP GET request to: https://hostname/artifactory/api/repositories/virtual-repository 23:11:06 [Debug] Artifactory response: 200 OK 23:11:06 [Debug] Done getting repository details. 23:11:06 [Debug] Saving build general details at: C:\path_jfrog\jfrog\builds\5680fd6d033564a1e8b8fd4de1ad3748f663a290303b63089171370a8de590a8\partials 23:11:06 [Debug] Start searching for image manifest.json 23:11:06 [Debug] Searching in:"virtual-repository/virtual-repository/any-path/container-name@sha256/e75b5b196d3441ded0ed4fb4503da2726d9e54a77dd4138aa0ede9f79664b9af/" 23:11:06 [Debug] Sending HTTP GET request to: https://hostname/artifactory/api/system/version 23:11:27 [🟠Warn] (Attempt 1) - Failure occurred while sending GET request to https://hostname/artifactory/api/system/version: Get "https://hostname/artifactory/api/system/version": dial tcp 100.64.1.2:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. 23:11:27 [Debug] Sending HTTP GET request to: https://hostname/artifactory/api/system/version 23:11:27 [Debug] Artifactory response: 200 OK 23:11:27 [Debug] JFrog Artifactory version is: 6.23.41 23:11:27 [Debug] Searching Artifactory using AQL query: items.find({"path":{"$ne":"."},"$or":[{"$and":[{"repo":"virtual-repository","path":"virtual-repository/any-path/container-name@sha256/e75b5b196d3441ded0ed4fb4503da2726d9e54a77dd4138aa0ede9f79664b9af","name":{"$match":""}}]}]}).include("name","repo","path","actual_md5","actual_sha1","sha256","size","type","modified","created","property") 23:11:27 [Debug] Sending HTTP POST request to: https://hostname/artifactory/api/search/aql 23:11:27 [Debug] Artifactory response: 200 OK 23:11:28 [Debug] Streaming data to file... 23:11:28 [Debug] Finished streaming data successfully. 23:11:28 [Debug] Searching in:"virtual-repository/any-path/container-name@sha256/e75b5b196d3441ded0ed4fb4503da2726d9e54a77dd4138aa0ede9f79664b9af/" 23:11:28 [Debug] Searching Artifactory using AQL query: items.find({"path":{"$ne":"."},"$or":[{"$and":[{"repo":"virtual-repository","path":"any-path/container-name@sha256/e75b5b196d3441ded0ed4fb4503da2726d9e54a77dd4138aa0ede9f79664b9af","name":{"$match":""}}]}]}).include("name","repo","path","actual_md5","actual_sha1","sha256","size","type","modified","created","property") 23:11:28 [Debug] Sending HTTP POST request to: https://hostname/artifactory/api/search/aql 23:11:28 [Debug] Artifactory response: 200 OK 23:11:28 [Debug] Streaming data to file... 23:11:28 [Debug] Finished streaming data successfully. 23:11:28 [Debug] Searching in:"virtual-repository/library/virtual-repository/any-path/container-name@sha256/e75b5b196d3441ded0ed4fb4503da2726d9e54a77dd4138aa0ede9f79664b9af/" 23:11:28 [Debug] Searching Artifactory using AQL query: items.find({"path":{"$ne":"."},"$or":[{"$and":[{"repo":"virtual-repository","path":"library/virtual-repository/any-path/container-name@sha256/e75b5b196d3441ded0ed4fb4503da2726d9e54a77dd4138aa0ede9f79664b9af","name":{"$match":""}}]}]}).include("name","repo","path","actual_md5","actual_sha1","sha256","size","type","modified","created","property") 23:11:28 [Debug] Sending HTTP POST request to: https://hostname/artifactory/api/search/aql 23:11:28 [Debug] Artifactory response: 200 OK 23:11:28 [Debug] Streaming data to file... 23:11:28 [Debug] Finished streaming data successfully. 23:11:28 [Debug] Searching in:"virtual-repository/library/any-path/container-name@sha256/e75b5b196d3441ded0ed4fb4503da2726d9e54a77dd4138aa0ede9f79664b9af/" 23:11:28 [Debug] Searching Artifactory using AQL query: items.find({"path":{"$ne":"."},"$or":[{"$and":[{"repo":"virtual-repository","path":"library/any-path/container-name@sha256/e75b5b196d3441ded0ed4fb4503da2726d9e54a77dd4138aa0ede9f79664b9af","name":{"$match":""}}]}]}).include("name","repo","path","actual_md5","actual_sha1","sha256","size","type","modified","created","property") 23:11:28 [Debug] Sending HTTP POST request to: https://hostname/artifactory/api/search/aql 23:11:28 [Debug] Artifactory response: 200 OK 23:11:28 [Debug] Streaming data to file... 23:11:28 [Debug] Finished streaming data successfully. 23:11:28 [🟠Warn] Failed to collect build-info. No layer(s) was found for image:'hostname/virtual-repository/any-path/container-name@sha256:e75b5b196d3441ded0ed4fb4503da2726d9e54a77dd4138aa0ede9f79664b9af'. Hint, try to delete the image from the local cache and rerun the command 23:11:28 [Debug] Could not find docker image in Artifactory, expecting image tag: hostname/virtual-repository/any-path/container-name@sha256:e75b5b196d3441ded0ed4fb4503da2726d9e54a77dd4138aa0ede9f79664b9af

Reproduction steps

No response

Expected behavior

with or without sh256 should work the same way; even more important considering that using a sha256 for pull is considered the preferred way.

JFrog CLI version

2.51.1

Operating system type and version

Windows 11

JFrog Artifactory version

6.23.41 rev 62341900

JFrog Xray version

No response

jghal commented 3 days ago

I'm seeing same error with v2.71.0, but I'm not pulling with the @sha syntax. I am running on Windows Server 2019, though

PS C:\> $psversiontable

Name                           Value
----                           -----
PSVersion                      5.1.17763.5820
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17763.5820
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
PS C:\> docker --version
Docker version 27.3.0, build e85edf8
PS C:\> jf --version
jf version 2.71.0

Our Artifactory instance is SaaS. I'm pulling the mcr.microsoft.com/docker:24-windowsservercore-1809 through a virtual repo that includes a remote repo for mcr.microsoft.com.