Harbor复制仓库产生的一系列问题
- 环境:阿里龙蜥8.6
- 环境默认开启firewalld,导致docker网桥重建失败,docker-compose不能重启harbor,需关闭防火墙
- 重启后由于初次启动时更改harbor.yml中的passwd改错,改了pgsql的密码,导致core与registry和jobsrevice不断重启,观察/var/log/harbor/下的各个组件日志,发现./prepare脚本删除数据,并不能删除已挂载的数据,删除服务器/data 目录下所有数据后,重新install.sh,harbor启动成功
- 复制仓库需要新建目标,新建目标时测试连接失败,观察core的日志发现如下报错:
Nov 20 13:53:26 172.25.0.1 core[2128117]: 2024-11-20T05:53:26Z [ERROR][/pkg/reg/adapter/native/adapter.go:126]: failed to ping registry http://172.16.30.203: Get "http://harbor.rubikstack.com/service/token?service=harbor-registry": dial tcp: lookup harbor.rubikstack.com on 127.0.0.11:53: read udp 127.0.0.1:47271->127.0.0.11:53: i/o timeout
-
分析怀疑是harbor使用了代理,代理的no_proxy未添加老客户端的IP,添加IP后重启harbor后报错依旧
-
怀疑新客户端配置了和老客户端同样的域名,多次试验:修改harbor.yml的hostname,修改common/config/core/env的域名,由于老客户端生产环境正在使用,暂时不敢修改为IP;新客户端均已修改为IP模式;
-
依旧怀疑是老客户端域名问题,但是生产环境无法修改操作,于是在harbor的组件之中添加host解析实验:
docker exec -it -u root `docker ps |awk '/core/{print $1}'` /bin/bash
# 一定要用root账户,不然没权限
root [ /harbor ]# echo "172.16.30.203 harbor.rubikstack.com" >> /etc/hosts
root [ /harbor ]# exit
- 修改core组件的host后,连接测试成功,但是复制管理依旧失败
# 报错内容
Nov 20 11:31:50 172.21.0.1 core[2128117]: 2024-11-20T03:31:50Z [INFO] [/pkg/notifier/notifier.go:206]: Handle notification with Handler 'ReplicationWebhook' on topic 'REPLICATION': ReplicationTaskID-156 Status-Error OccurAt-2024-11-20 03:31:50
- 观察harborUI界面发现如下报错
# core.log
2024-11-20T03:55:56Z [ERROR] [/controller/replication/transfer/image/transfer.go:135]: failed to create client for source registry: Get "http://harbor.rubikstack.com/api/version": dial tcp: lookup harbor.rubikstack.com on 127.0.0.11:53: read udp 127.0.0.1:60379->127.0.0.11:53: i/o timeout
# ui界面
{
"errors": [
{
"code": "NOT_FOUND",
"message": "{\"code\":10010,\"message\":\"object is not found\",\"details\":\"fc2eb40441d25b048db810f3\"}"
}
]
}
- 搜索网上资料,复制管理通过registry组件进行管理,修改registry组件的host,服务依旧报错
- 参考github资料:failed to create client for destination registry: http error: code 401, message · Issue #15259 · goharbor/harbor · GitHub 似乎请求被发送到jobservice而不是core。修改jobservice的hosts
- 再次测试,复制成功
Nov 20 14:13:35 172.25.0.1 core[2128117]: 2024-11-20T06:13:35Z [INFO] [/pkg/notifier/notifier.go:206]: Handle notification with Handler 'ReplicationWebhook' on topic 'REPLICATION': ReplicationTaskID-605 Status-Success OccurAt-2024-11-20 06:13:35
Nov 20 14:13:35 172.25.0.1 core[2128117]: 2024-11-20T06:13:35Z [INFO] [/pkg/notifier/notifier.go:206]: Handle notification with Handler 'ReplicationWebhook' on topic 'REPLICATION': ReplicationTaskID-617 Status-Running OccurAt-2024-11-20 06:13:35