cnrancher / hangar

Multi-platform container image command-line utility.
https://hangar.cnrancher.com
Apache License 2.0
12 stars 6 forks source link

[load命令] -default-project 参数无法执行成功 #1

Closed rootwuj closed 1 year ago

rootwuj commented 1 year ago

版本:v1.2.1

问题描述: load 命令,使用 -default-project 参数指定默认的 project 名称,无法执行成功。(mirror命令使用 -default-project 参数可以成功执行。)

load

root@ip-172-31-21-220:~# ./image-tools load -s ./saved-images.tar.gz -d harbor.wujing.site  -repo-type=harbor -default-project=library  -j 10
02:11:40 [INFO] Set 'docker login' registry to "harbor.wujing.site"
02:11:40 [INFO] Logging in to harbor.wujing.site
02:11:40 [INFO] Get passwd of user "admin" from docker config
02:11:40 [INFO] Login succeed
02:11:40 [INFO] Decompressing ./saved-images.tar.gz...
02:11:40 [INFO] Creating 10 job workers
02:11:40 [WARN] "docker.io/busybox" does not have project
02:11:41 [INFO] Set default project to "library"
02:11:41 [WARN] "docker.io/registry" does not have project
02:11:41 [INFO] Set default project to "library"
02:11:41 [INFO] [M_ID:1] DEST: [harbor.wujing.site/library/busybox] TAG: [latest]
02:11:41 [INFO] [M_ID:5] DEST: [harbor.wujing.site/library/registry] TAG: [2]
02:11:41 [INFO] [M_ID:2] DEST: [harbor.wujing.site/rancher/mirrored-nginx-ingress-controller-defaultbackend] TAG: [1.5-rancher1]
02:11:41 [INFO] [M_ID:3] DEST: [harbor.wujing.site/rancher/mirrored-coredns-coredns] TAG: [1.8.0]
02:11:41 [INFO] [M_ID:4] DEST: [harbor.wujing.site/rancher/mirrored-metrics-server] TAG: [v0.5.0]
02:11:41 [INFO] [M_ID:6] DEST: [harbor.wujing.site/rancher/mirrored-coreos-etcd] TAG: [v3.4.15-rancher1]
02:11:41 [ERRO] [M_ID:1] Failed to load image [harbor.wujing.site/library/busybox]
02:11:41 [ERRO] [M_ID:1] MirrorStartLoad: Load: SkopeoCopy dir://root/saved-image-cache/4585a1c6c65cd10b04f0145ce0bb007ac6b52d04b6a6f0bd137cd1623e3bcab5 => docker://harbor.wujing.site/busybox:latest-amd64:
time="2022-12-26T02:11:41Z" level=fatal msg="trying to reuse blob sha256:2123501b93d459033750d3ea725953060ed9bb83bac7c13e46c675be22b69f4a at destination: failed to read from destination repository busybox: 400 (Bad Request)"
, exit status 1
02:11:41 [ERRO] [M_ID:5] Failed to load image [harbor.wujing.site/library/registry]
02:11:41 [ERRO] [M_ID:5] MirrorStartLoad: Load: SkopeoCopy dir://root/saved-image-cache/61e431148ff7239cd4d214e8b5d74de3c1312b6f68407ef933fb6cf45d0ce686 => docker://harbor.wujing.site/registry:2-amd64:
time="2022-12-26T02:11:41Z" level=fatal msg="trying to reuse blob sha256:ca7dd9ec2225f2385955c43b2379305acd51543c28cf1d4e94522b3d94cce3ce at destination: failed to read from destination repository registry: 400 (Bad Request)"
, exit status 1
02:11:44 [INFO] [M_ID:2] Creating dest manifest list...
02:11:45 [INFO] [M_ID:2] Successfully loaded harbor.wujing.site/rancher/mirrored-nginx-ingress-controller-defaultbackend:1.5-rancher1.
02:11:45 [INFO] [M_ID:3] Creating dest manifest list...
02:11:46 [INFO] [M_ID:3] Successfully loaded harbor.wujing.site/rancher/mirrored-coredns-coredns:1.8.0.
02:11:47 [INFO] [M_ID:4] Creating dest manifest list...
02:11:48 [INFO] [M_ID:4] Successfully loaded harbor.wujing.site/rancher/mirrored-metrics-server:v0.5.0.
02:11:49 [INFO] [M_ID:6] Creating dest manifest list...
02:11:50 [INFO] [M_ID:6] Successfully loaded harbor.wujing.site/rancher/mirrored-coreos-etcd:v3.4.15-rancher1.
root@ip-172-31-21-220:~#

mirror

root@ip-172-31-21-220:~# ./image-tools mirror -f ./aa.txt.converted -d harbor.wujing.site  -repo-type=harbor -default-project=library
02:23:06 [INFO] Found skopeo: skopeo version 1.4.1
02:23:07 [INFO] Set source registry to "docker.io"
02:23:07 [INFO] Set 'docker login' registry to "harbor.wujing.site"
02:23:07 [INFO] Logging in to harbor.wujing.site
02:23:07 [INFO] Get passwd of user "admin" from docker config
02:23:07 [INFO] Login succeed
02:23:07 [INFO] Creating 1 job workers
02:23:07 [INFO] [M_ID:1] SOURCE: [docker.io/rancher/mirrored-coreos-etcd] DEST: [harbor.wujing.site/rancher/mirrored-coreos-etcd] TAG: [v3.4.15-rancher1]
02:23:08 [INFO] [M_ID:1] [docker.io/rancher/mirrored-coreos-etcd:v3.4.15-rancher1] is manifest.list.v2
02:23:08 [INFO] [M_ID:1] [IMG_ID:1] Digest changed: [sha256:724cdecac9dad5289b54ef8fccab073e8112105d2f329984c5da67a86323506d] => [NEW_IMAGE]
02:23:08 [INFO] [M_ID:1] [IMG_ID:1] Copying: [docker.io/rancher/mirrored-coreos-etcd@sha256:724cdecac9dad5289b54ef8fccab073e8112105d2f329984c5da67a86323506d] => [harbor.wujing.site/rancher/mirrored-coreos-etcd:v3.4.15-rancher1-amd64]
Getting image source signatures
Copying blob 21c549d41ff0 skipped: already exists
Copying blob 621b2e0141ca skipped: already exists
Copying blob 39fafc05754f skipped: already exists
Copying blob e1d5804360f1 skipped: already exists
Copying blob 481a903d31c6 skipped: already exists
Copying blob 543c1ea18bb7 [--------------------------------------] 0.0b / 0.0b
Copying config 87c4f81d88 [======================================] 2.8KiB / 2.8KiB
Writing manifest to image destination
Storing signatures
02:23:11 [INFO] [M_ID:1] [IMG_ID:2] Digest changed: [sha256:0725bee729805b5f2ba0c9213db884e22b64fd9a003a5414e254a98c278c3464] => [NEW_IMAGE]
02:23:11 [INFO] [M_ID:1] [IMG_ID:2] Copying: [docker.io/rancher/mirrored-coreos-etcd@sha256:0725bee729805b5f2ba0c9213db884e22b64fd9a003a5414e254a98c278c3464] => [harbor.wujing.site/rancher/mirrored-coreos-etcd:v3.4.15-rancher1-arm64]
Getting image source signatures
Copying blob be512cf3202c skipped: already exists
Copying blob 250181cef7de [--------------------------------------] 0.0b / 0.0b
Copying blob 9f9ba9541db2 [--------------------------------------] 0.0b / 0.0b
Copying blob 3375dc7c185a skipped: already exists
Copying blob 7e281caa7d91 [--------------------------------------] 0.0b / 0.0b
Copying config 955737183a [======================================] 2.7KiB / 2.7KiB
Writing manifest to image destination
Storing signatures
02:23:13 [INFO] [M_ID:1] Creating dest manifest list...
02:23:13 [INFO] [M_ID:1] Successfully copied docker.io/rancher/mirrored-coreos-etcd:v3.4.15-rancher1 => harbor.wujing.site/rancher/mirrored-coreos-etcd:v3.4.15-rancher1.
02:23:13 [INFO] [M_ID:2] SOURCE: [docker.io/rancher/mirrored-metrics-server] DEST: [harbor.wujing.site/rancher/mirrored-metrics-server] TAG: [v0.5.0]
02:23:15 [INFO] [M_ID:2] [docker.io/rancher/mirrored-metrics-server:v0.5.0] is manifest.list.v2
02:23:15 [INFO] [M_ID:2] [IMG_ID:1] Digest changed: [sha256:05bf9f4bf8d9de19da59d3e1543fd5c140a8d42a5e1b92421e36e5c2d74395eb] => [NEW_IMAGE]
02:23:15 [INFO] [M_ID:2] [IMG_ID:1] Copying: [docker.io/rancher/mirrored-metrics-server@sha256:05bf9f4bf8d9de19da59d3e1543fd5c140a8d42a5e1b92421e36e5c2d74395eb] => [harbor.wujing.site/rancher/mirrored-metrics-server:v0.5.0-amd64]
Getting image source signatures
Copying blob 2ca785997557 [--------------------------------------] 0.0b / 0.0b
Copying blob 5dea5ec2316d [--------------------------------------] 0.0b / 0.0b
Copying config 1c655933b9 [======================================] 1.0KiB / 1.0KiB
Writing manifest to image destination
Storing signatures
02:23:17 [INFO] [M_ID:2] [IMG_ID:2] Digest changed: [sha256:8d86e37bd3e5a428aab0f65699fcd8bbe0bc505e95c013cc549869793dbe6bcb] => [NEW_IMAGE]
02:23:17 [INFO] [M_ID:2] [IMG_ID:2] Copying: [docker.io/rancher/mirrored-metrics-server@sha256:8d86e37bd3e5a428aab0f65699fcd8bbe0bc505e95c013cc549869793dbe6bcb] => [harbor.wujing.site/rancher/mirrored-metrics-server:v0.5.0-arm64]
Getting image source signatures
Copying blob 497c59eda27e skipped: already exists
Copying blob 5dea5ec2316d [--------------------------------------] 0.0b / 0.0b
Copying config ee11f1e38a [======================================] 1.0KiB / 1.0KiB
Writing manifest to image destination
Storing signatures
02:23:19 [INFO] [M_ID:2] Creating dest manifest list...
02:23:20 [INFO] [M_ID:2] Successfully copied docker.io/rancher/mirrored-metrics-server:v0.5.0 => harbor.wujing.site/rancher/mirrored-metrics-server:v0.5.0.
02:23:20 [INFO] [M_ID:3] SOURCE: [docker.io/rancher/mirrored-coredns-coredns] DEST: [harbor.wujing.site/rancher/mirrored-coredns-coredns] TAG: [1.8.0]
02:23:21 [INFO] [M_ID:3] [docker.io/rancher/mirrored-coredns-coredns:1.8.0] is manifest.list.v2
02:23:21 [INFO] [M_ID:3] [IMG_ID:1] Digest changed: [sha256:10ecc12177735e5a6fd6fa0127202776128d860ed7ab0341780ddaeb1f6dfe61] => [NEW_IMAGE]
02:23:21 [INFO] [M_ID:3] [IMG_ID:1] Copying: [docker.io/rancher/mirrored-coredns-coredns@sha256:10ecc12177735e5a6fd6fa0127202776128d860ed7ab0341780ddaeb1f6dfe61] => [harbor.wujing.site/rancher/mirrored-coredns-coredns:1.8.0-amd64]
Getting image source signatures
Copying blob 5984b6d55edf skipped: already exists
Copying blob c6568d217a00 [--------------------------------------] 0.0b / 0.0b
Copying config 296a6d5035 [======================================] 1.9KiB / 1.9KiB
Writing manifest to image destination
Storing signatures
02:23:23 [INFO] [M_ID:3] [IMG_ID:2] Digest changed: [sha256:919b800fed6eaf6c9a55c3017c0aa3187bfe5d81abefbe49bb27f968458b94cc] => [NEW_IMAGE]
02:23:23 [INFO] [M_ID:3] [IMG_ID:2] Copying: [docker.io/rancher/mirrored-coredns-coredns@sha256:919b800fed6eaf6c9a55c3017c0aa3187bfe5d81abefbe49bb27f968458b94cc] => [harbor.wujing.site/rancher/mirrored-coredns-coredns:1.8.0-arm64]
Getting image source signatures
Copying blob d4cfe0389280 skipped: already exists
Copying blob c6568d217a00 skipped: already exists
Copying config 1a1f05a2cd [======================================] 1.9KiB / 1.9KiB
Writing manifest to image destination
Storing signatures
02:23:25 [INFO] [M_ID:3] Creating dest manifest list...
02:23:26 [INFO] [M_ID:3] Successfully copied docker.io/rancher/mirrored-coredns-coredns:1.8.0 => harbor.wujing.site/rancher/mirrored-coredns-coredns:1.8.0.
02:23:26 [INFO] [M_ID:4] SOURCE: [docker.io/rancher/mirrored-nginx-ingress-controller-defaultbackend] DEST: [harbor.wujing.site/rancher/mirrored-nginx-ingress-controller-defaultbackend] TAG: [1.5-rancher1]
02:23:26 [WARN] The project of "harbor.wujing.site/busybox" is empty, set to default "library"
02:23:27 [INFO] [M_ID:4] [docker.io/rancher/mirrored-nginx-ingress-controller-defaultbackend:1.5-rancher1] is manifest.list.v2
02:23:27 [INFO] [M_ID:4] [IMG_ID:1] Digest changed: [sha256:4dc5e07c8ca4e23bddb3153737d7b8c556e5fb2f29c4558b7cd6e6df99c512c7] => [NEW_IMAGE]
02:23:27 [INFO] [M_ID:4] [IMG_ID:1] Copying: [docker.io/rancher/mirrored-nginx-ingress-controller-defaultbackend@sha256:4dc5e07c8ca4e23bddb3153737d7b8c556e5fb2f29c4558b7cd6e6df99c512c7] => [harbor.wujing.site/rancher/mirrored-nginx-ingress-controller-defaultbackend:1.5-rancher1-amd64]
Getting image source signatures
Copying blob 65f4220de95d [--------------------------------------] 0.0b / 0.0b
Copying config b5af743e59 [======================================] 1.6KiB / 1.6KiB
Writing manifest to image destination
Storing signatures
02:23:30 [INFO] [M_ID:4] [IMG_ID:2] Digest changed: [sha256:d96c10f06fb8ccc90f6204e6e2f3cd58798e4ac08ca9ac85fbfedad00fcc8917] => [NEW_IMAGE]
02:23:30 [INFO] [M_ID:4] [IMG_ID:2] Copying: [docker.io/rancher/mirrored-nginx-ingress-controller-defaultbackend@sha256:d96c10f06fb8ccc90f6204e6e2f3cd58798e4ac08ca9ac85fbfedad00fcc8917] => [harbor.wujing.site/rancher/mirrored-nginx-ingress-controller-defaultbackend:1.5-rancher1-arm64]
Getting image source signatures
Copying blob fef06acf2a63 [--------------------------------------] 0.0b / 0.0b
Copying config 59f80fd384 [======================================] 1.6KiB / 1.6KiB
Writing manifest to image destination
Storing signatures
02:23:32 [INFO] [M_ID:4] Creating dest manifest list...
02:23:32 [INFO] [M_ID:4] Successfully copied docker.io/rancher/mirrored-nginx-ingress-controller-defaultbackend:1.5-rancher1 => harbor.wujing.site/rancher/mirrored-nginx-ingress-controller-defaultbackend:1.5-rancher1.
02:23:32 [INFO] [M_ID:5] SOURCE: [docker.io/busybox] DEST: [harbor.wujing.site/library/busybox] TAG: [latest]
02:23:32 [WARN] The project of "harbor.wujing.site/registry" is empty, set to default "library"
02:23:34 [INFO] [M_ID:5] [docker.io/busybox:latest] is manifest.list.v2
02:23:34 [INFO] [M_ID:5] [IMG_ID:1] Digest changed: [sha256:51de9138b0cc394c813df84f334d638499333cac22edd05d0300b2c9a2dc80dd] => [NEW_IMAGE]
02:23:34 [INFO] [M_ID:5] [IMG_ID:1] Copying: [docker.io/busybox@sha256:51de9138b0cc394c813df84f334d638499333cac22edd05d0300b2c9a2dc80dd] => [harbor.wujing.site/library/busybox:latest-amd64]
Getting image source signatures
Copying blob 2123501b93d4 done
Copying config 827365c7ba done
Writing manifest to image destination
Storing signatures
02:23:37 [INFO] [M_ID:5] [IMG_ID:2] Digest changed: [sha256:9421d4cc473b282bf48888476604444fa3c74f6e3f5cddfa210e773c534cd33d] => [NEW_IMAGE]
02:23:37 [INFO] [M_ID:5] [IMG_ID:2] Copying: [docker.io/busybox@sha256:9421d4cc473b282bf48888476604444fa3c74f6e3f5cddfa210e773c534cd33d] => [harbor.wujing.site/library/busybox:latest-arm64]
Getting image source signatures
Copying blob ce2f991d7b89 done
Copying config 9bf1b624e5 done
Writing manifest to image destination
Storing signatures
02:23:40 [INFO] [M_ID:5] Creating dest manifest list...
02:23:40 [INFO] [M_ID:5] Successfully copied docker.io/busybox:latest => harbor.wujing.site/library/busybox:latest.
02:23:40 [INFO] [M_ID:6] SOURCE: [docker.io/registry] DEST: [harbor.wujing.site/library/registry] TAG: [2]
02:23:42 [INFO] [M_ID:6] [docker.io/registry:2] is manifest.list.v2
02:23:42 [INFO] [M_ID:6] [IMG_ID:1] Digest changed: [sha256:cc6393207bf9d3e032c4d9277834c1695117532c9f7e8c64e7b7adcda3a85f39] => [NEW_IMAGE]
02:23:42 [INFO] [M_ID:6] [IMG_ID:1] Copying: [docker.io/registry@sha256:cc6393207bf9d3e032c4d9277834c1695117532c9f7e8c64e7b7adcda3a85f39] => [harbor.wujing.site/library/registry:2-amd64]
Getting image source signatures
Copying blob 626897ccab21 done
Copying blob 21df229223d2 done
Copying blob 1ed0fc8a6161 done
Copying blob ca7dd9ec2225 done
Copying blob c41ae7ad2b39 done
Copying config 81c944c228 done
Writing manifest to image destination
Storing signatures
02:23:45 [INFO] [M_ID:6] [IMG_ID:2] Digest changed: [sha256:bd3f236611d9159b461f8e2e1bf7476fb1acdbb2bcdb3d7e3d38bd71f1fad903] => [NEW_IMAGE]
02:23:45 [INFO] [M_ID:6] [IMG_ID:2] Copying: [docker.io/registry@sha256:bd3f236611d9159b461f8e2e1bf7476fb1acdbb2bcdb3d7e3d38bd71f1fad903] => [harbor.wujing.site/library/registry:2-arm64]
Getting image source signatures
Copying blob 6875df1f5354 done
Copying blob 14dda7aa4712 done
Copying blob d89711ab5413 done
Copying blob b0bb999c9df1 done
Copying blob 5273b4c862f6 done
Copying config 9a2b03997a done
Writing manifest to image destination
Storing signatures
02:23:48 [INFO] [M_ID:6] Creating dest manifest list...
02:23:49 [INFO] [M_ID:6] Successfully copied docker.io/registry:2 => harbor.wujing.site/library/registry:2.
root@ip-172-31-21-220:~#
root@ip-172-31-21-220:~#
STARRY-S commented 1 year ago

已于 https://github.com/cnrancher/image-tools/commit/f0f244f95f8188bd0dd642564990f9d8ec185bd0 修复,可在下一个 release 版本中测试验证。

rootwuj commented 1 year ago

版本:v1.2.2-rc1

验证通过。此版本执行 load 命令,使用 -default-project 参数指定默认的 project 名称,可以执行成功。

[root@ip-172-31-31-52 ~]# ./image-tools load -s ./saved-images.tar.gz -d harbor.wujing.site -repo-type=harbor  -default-project=library -j 10
07:34:04 [INFO] Set 'docker login' registry to "harbor.wujing.site"
07:34:04 [WARN] Cache folder: 'saved-image-cache' is not empty!
Delete it before start save image? [Yes/No] yes
07:34:06 [INFO] Logging in to harbor.wujing.site
07:34:06 [INFO] Get passwd of user "admin" from docker config
07:34:06 [INFO] Login succeed
07:34:06 [INFO] Decompressing ./saved-images.tar.gz...
07:34:08 [INFO] Creating 10 job workers
07:34:08 [WARN] "docker.io/busybox" does not have project name, set to "library"
07:34:08 [INFO] [M_ID:2] DEST: [harbor.wujing.site/cnrancher/ack-operator] TAG: [v2.5-ent]
07:34:08 [INFO] [M_ID:3] DEST: [harbor.wujing.site/cnrancher/cn-rke-tools] TAG: [v0.1.80-ent2]
07:34:08 [INFO] [M_ID:1] DEST: [harbor.wujing.site/library/busybox] TAG: [latest]
07:34:10 [INFO] [M_ID:1] Creating dest manifest list...
07:34:10 [INFO] [M_ID:2] Creating dest manifest list...
07:34:11 [INFO] [M_ID:1] Successfully loaded harbor.wujing.site/library/busybox:latest.
07:34:11 [INFO] [M_ID:2] Successfully loaded harbor.wujing.site/cnrancher/ack-operator:v2.5-ent.
07:34:11 [INFO] [M_ID:3] Creating dest manifest list...
07:34:11 [INFO] [M_ID:3] Successfully loaded harbor.wujing.site/cnrancher/cn-rke-tools:v0.1.80-ent2.
[root@ip-172-31-31-52 ~]#