containerized-data-importer: expected status code 200, got 401. Status: 401 Unauthorized
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
k logs importer-prime-4c45f9a2-160b-45dd-b91d-d3a7277b1842
I1112 11:26:08.283400 1 importer.go:107] Starting importer
I1112 11:26:08.283455 1 importer.go:182] begin import process
E1112 11:26:08.362389 1 http-datasource.go:429] http: expected status code 200, got 401
E1112 11:26:08.377798 1 http-datasource.go:353] http: expected status code 200, got 401
E1112 11:26:08.377876 1 importer.go:347] expected status code 200, got 401. Status: 401 Unauthorized
kubevirt.io/containerized-data-importer/pkg/importer.createHTTPReader
pkg/importer/http-datasource.go:354
kubevirt.io/containerized-data-importer/pkg/importer.NewHTTPDataSource
pkg/importer/http-datasource.go:102
main.newDataSource
cmd/cdi-importer/importer.go:272
main.handleImport
cmd/cdi-importer/importer.go:184
main.main
cmd/cdi-importer/importer.go:148
runtime.main
GOROOT/src/runtime/proc.go:271
runtime.goexit
src/runtime/asm_amd64.s:1695
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:
- CDI version (use
kubectl get deployments cdi-deployment -o yaml): v1.60.2 - Kubernetes version (use
kubectl version): v1.29.0 - DV specification:
apiVersion: v1
kind: Secret
metadata:
name: credentials
type: Opaque
data:
accessKeyId: <base64>
secretKey: <base64>
---
apiVersion: cdi.kubevirt.io/v1beta1
kind: DataVolume
metadata:
name: artifact-repo-dv
spec:
pvc:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Gi
storageClassName: gp3
source:
http:
url: "https://artifact.in/artifactory/windows-images/win2019/windows.iso"
secretRef: credentials
- Cloud provider or hardware configuration: EKS
- OS (e.g. from /etc/os-release): Flatcar
- Kernel (e.g.
uname -a): N/A - Install tools: N/A
- Others: N/A
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (2 by maintainers)
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