Open Gops123 opened 2 days ago
Hey, thanks for reporting. What's the curl
equivalent command (with secrets omitted, ofc) that succesfully pulls the image from the artifactory?
Also make sure you're not accidentally encoding \n
in the id/key.
Hello, I'm using the following curl command to download an image:
curl -u "username:password" -O "https://artifact.in/artifactory/windows-images/win2019/windows.iso"
The command works independently, but it’s not working as expected within the above manifest. I’ve verified that there are no \n characters in the username or password.
Interesting.. this is precisely what CDI is doing https://github.com/kubevirt/containerized-data-importer/blob/c15ad1d5c12f572a8208dea35c6b045c52bdf7f1/pkg/importer/http-datasource.go#L345 Do you have access to the artifactory side, to check the logs there?
No I don't have access to artifactory to check logs
Okay, could you try executing this curl command from inside a pod in the cluster, in the same ns? similarly to what the cdi-importer is doing?
curl working from pod
> User-Agent: curl/8.5.0
> Accept: */*
>
{ [5 bytes data]
< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Content-Disposition: attachment; filename="win.iso"; filename*=UTF-8''win.iso
< Content-Type: application/octet-stream
< Date: Wed, 13 Nov 2024 13:00:02 GMT
curl working from pod
> User-Agent: curl/8.5.0 > Accept: */* > { [5 bytes data] < HTTP/1.1 200 OK < Accept-Ranges: bytes < Content-Disposition: attachment; filename="win.iso"; filename*=UTF-8''win.iso < Content-Type: application/octet-stream < Date: Wed, 13 Nov 2024 13:00:02 GMT
curl -vvv
may help spot the differences between curl/importer application, just make sure to leave out the credentials
Hello @akalenyu here is the required output from curl with verbose
* ALPN, offering h2
* ALPN, offering http/1.1
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
* TLSv1.0 (OUT), TLS header, Certificate Status (22):
} [5 bytes data]
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
} [512 bytes data]
* TLSv1.2 (IN), TLS header, Certificate Status (22):
{ [5 bytes data]
* TLSv1.3 (IN), TLS handshake, Server hello (2):
{ [89 bytes data]
* TLSv1.2 (IN), TLS header, Certificate Status (22):
{ [5 bytes data]
* TLSv1.2 (IN), TLS handshake, Certificate (11):
{ [4304 bytes data]
* TLSv1.2 (IN), TLS header, Certificate Status (22):
{ [5 bytes data]
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
{ [333 bytes data]
* TLSv1.2 (IN), TLS header, Certificate Status (22):
{ [5 bytes data]
* TLSv1.2 (IN), TLS handshake, Server finished (14):
{ [4 bytes data]
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
} [5 bytes data]
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
} [70 bytes data]
* TLSv1.2 (OUT), TLS header, Finished (20):
} [5 bytes data]
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
} [1 bytes data]
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
} [5 bytes data]
* TLSv1.2 (OUT), TLS handshake, Finished (20):
} [16 bytes data]
* TLSv1.2 (IN), TLS header, Finished (20):
{ [5 bytes data]
* TLSv1.2 (IN), TLS header, Certificate Status (22):
{ [5 bytes data]
* TLSv1.2 (IN), TLS handshake, Finished (20):
{ [16 bytes data]
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server did not agree to a protocol
* Server certificate:
* subject: C=US; ST=California; L=San Jose; O=aaaaa Inc.; CN=artifactory.com
* start date: Dec 12 00:00:00 2023 GMT
* expire date: Jan 11 23:59:59 2025 GMT
* subjectAltName: host "artifactory.com" matched cert's "artifactory.com"
* issuer: C=US; O=DigiCert Inc; CN=DigiCert TLS RSA SHA256 2020 CA1
* SSL certificate verify ok.
* Server auth using Basic with user 'xxxxx'
* TLSv1.2 (OUT), TLS header, Unknown (23):
} [5 bytes data]
> GET artifactory/windows-images/win2019/windows.iso HTTP/1.1
> Host: artifactory.com
> Authorization: Basic xxxxxx
> User-Agent: curl/7.76.1
> Accept: */*
>
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* TLSv1.2 (IN), TLS header, Unknown (23):
{ [5 bytes data]
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Content-Disposition: attachment; filename="windows.iso"; filename*=UTF-8''windows.iso
< Content-Type: application/octet-stream
< Date: Wed, 13 Nov 2024 13:41:24 GMT
< ETag: 3402039abb970b3cd851
< Last-Modified: Tue, 12 Nov 2024 09:33:19 GMT
< X-Artifactory-Filename: windows.iso
< X-Artifactory-Id: 62879b11ca5dffd7296b1500c27db7
< X-Artifactory-Node-Id: uw2010012
< X-Checksum-Md5: 8f9a70435dc5b0b86cf
< X-Checksum-Sha1: 3402039abb970b3cd851efc
< X-Checksum-Sha256: 55c687a9a242fab7b0ec89ac69f9def
< X-JFrog-Version: Artifactory/7.63.22 76322900
< Content-Length: 65366
< Connection: keep-alive ```
This looks like the exact same thing CDI is doing. You could try to write a simple golang program that tries to pull from the artifactory, with your credentials, I expect that it would fail with the golang http client
yes tried and getting expected status code
yes tried and getting expected status code
Cool, so you can try spotting the bug, I believe it would be somewhere in https://github.com/kubevirt/containerized-data-importer/blob/c15ad1d5c12f572a8208dea35c6b045c52bdf7f1/pkg/importer/http-datasource.go
Encountering an issue where extra newline characters (\n)
are getting appended to accessKey
and secKey
in the createHTTPReader
function.
https://github.com/kubevirt/containerized-data-importer/blob/main/pkg/importer/http-datasource.go#L317
When you created the secret with the accessKeyId and secretKey you had to base64 encode the username and password. Make sure that when you do this the base64 encoded value doesn't include the \n
for instance echo -n "password" | base64
should encode without encoding the \n
check the output with and without the -n
on the echo and compare it to the value in the secret.
What happened: A Kubernetes Secret is used to securely pass credentials for accessing the Artifactory repository. The DataVolume configuration references this Secret for authentication to pull the image. The URL for the image source is specified within the DataVolume configuration, with artifact-repo-credentials providing the necessary accessKeyId and secretKey for access. credentials are correct but still seeing a 401 Unauthorized error
What you expected to happen: A clear and concise description of what you expected to happen.
Additional context: Add any other context about the problem here.
Environment:
kubectl get deployments cdi-deployment -o yaml
): v1.60.2kubectl version
): v1.29.0uname -a
): N/A