Skip to content

Commit 01d5342

Browse files
authored
fix: 部署管理:拉取不到镜像时体验优化 (#2244)
1 parent 7cf49cd commit 01d5342

2 files changed

Lines changed: 69 additions & 24 deletions

File tree

apiserver/paasng/locale/en/LC_MESSAGES/django.po

Lines changed: 57 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: PACKAGE VERSION\n"
99
"Report-Msgid-Bugs-To: \n"
10-
"POT-Creation-Date: 2025-06-27 18:06+0800\n"
10+
"POT-Creation-Date: 2025-07-04 14:01+0800\n"
1111
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1212
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1313
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -200,30 +200,44 @@ msgstr "Bound module information"
200200
msgid "显示名称"
201201
msgstr "Display name"
202202

203-
#: paas_wl/bk_app/cnative/specs/views.py:119
203+
#: paas_wl/bk_app/cnative/specs/views.py:120
204204
msgid "权限不足或仓库不可达"
205205
msgstr "Insufficient permissions or repository unreachable"
206206

207-
#: paas_wl/bk_app/cnative/specs/views.py:141
207+
#: paas_wl/bk_app/cnative/specs/views.py:142
208208
msgid "镜像凭证不存在"
209209
msgstr "Image credentials not found"
210210

211-
#: paas_wl/bk_app/cnative/specs/views.py:158
211+
#: paas_wl/bk_app/cnative/specs/views.py:153
212+
msgid "镜像仓库不存在,请检查仓库地址是否正确"
213+
msgstr "Image repository not exist, please check whether the repository address is correct."
214+
215+
#: paas_wl/bk_app/cnative/specs/views.py:155
216+
msgid "镜像仓库权限不足, 请检查是否配置镜像凭证"
217+
msgstr ""
218+
"Image repository has no permission, please check whether the image "
219+
"credentials are configured."
220+
221+
#: paas_wl/bk_app/cnative/specs/views.py:157
222+
msgid "镜像仓库凭证错误, 请检查镜像凭证配置是否正确"
223+
msgstr ""
224+
"Image repository credential verification failed, please check the credential is "
225+
"correctly."
226+
227+
#: paas_wl/bk_app/cnative/specs/views.py:165
212228
msgid "查看镜像 Tag"
213229
msgstr "View image Tag"
214230

215-
#: paas_wl/bk_app/cnative/specs/views.py:166
216-
#: paasng/platform/sourcectl/views.py:418
217-
#, python-format
218-
msgid "%s的仓库信息查询异常"
219-
msgstr "The warehouse information query of %s is abnormal"
231+
#: paas_wl/bk_app/cnative/specs/views.py:173
232+
msgid "拉取镜像 Tag 失败"
233+
msgstr "Failed to list tag from image repository"
220234

221-
#: paas_wl/bk_app/cnative/specs/views.py:223
222-
#: paas_wl/bk_app/cnative/specs/views.py:282
235+
#: paas_wl/bk_app/cnative/specs/views.py:230
236+
#: paas_wl/bk_app/cnative/specs/views.py:289
223237
msgid "同环境和路径挂载卷已存在"
224238
msgstr "Mount volume already exists in the same environment and path."
225239

226-
#: paas_wl/bk_app/cnative/specs/views.py:373
240+
#: paas_wl/bk_app/cnative/specs/views.py:380
227241
msgid "当前应用暂不支持持久存储功能,请联系管理员"
228242
msgstr ""
229243
"The current application does not support persistent storage functionality. "
@@ -768,9 +782,9 @@ msgstr "Other"
768782
#: paasng/platform/engine/constants.py:127
769783
#: paasng/platform/engine/workflow/protections.py:68
770784
#, fuzzy
771-
#| msgid "未完善应用市场信息"
785+
#| msgid "未完善应用基本信息"
772786
msgid "未完善应用市场信息"
773-
msgstr "Incomplete app market information"
787+
msgstr "Incomplete app basic information"
774788

775789
#: paasng/accessories/publish/market/protections.py:66
776790
msgid "应用未在生产环境成功部署"
@@ -2310,26 +2324,30 @@ msgstr "Testing in progress"
23102324
msgid "无法获取到有效的配置信息."
23112325
msgstr "No valid configuration information is available."
23122326

2313-
#: paasng/plat_mgt/applications/serializers/application.py:188
2327+
#: paasng/plat_mgt/applications/serializers/application.py:209
23142328
#, python-brace-format
23152329
msgid "于{time}{operation}{status}"
23162330
msgstr " {operation} {status} at {time}"
23172331

2318-
#: paasng/plat_mgt/applications/serializers/application.py:239
2332+
#: paasng/plat_mgt/applications/serializers/application.py:252
2333+
msgid "应用分类不存在"
2334+
msgstr ""
2335+
2336+
#: paasng/plat_mgt/applications/serializers/application.py:274
23192337
#, python-brace-format
23202338
msgid "现有的分配策略下未找到匹配的集群(集群名: {name})"
23212339
msgstr ""
23222340
"No matching cluster was found under the existing allocation strategy "
23232341
"(cluster name: {name})"
23242342

2325-
#: paasng/plat_mgt/applications/views/application.py:305
2343+
#: paasng/plat_mgt/applications/views/application.py:330
23262344
#, fuzzy
23272345
#| msgid "应用不存在"
23282346
msgid "应用不存在或未被软删除"
23292347
msgstr "application does not exist"
23302348

2331-
#: paasng/plat_mgt/applications/views/application.py:313
2332-
msgid "PaaS 2.0 中信息删除失败,无法硬删除应用"
2349+
#: paasng/plat_mgt/applications/views/application.py:338
2350+
msgid "PaaS 2.0 中信息删除失败"
23332351
msgstr ""
23342352

23352353
#: paasng/plat_mgt/applications/views/services.py:153
@@ -3483,7 +3501,7 @@ msgstr ""
34833501
#: paasng/platform/mgrlegacy/app_migrations/service_rabbitmq.py:59
34843502
#, python-brace-format
34853503
msgid "正在为 {environment} 环境创建 RabbitMQ 服务实例..."
3486-
msgstr ""
3504+
msgstr "Creating RabbitMQ service instance for {environment} environment..."
34873505

34883506
#: paasng/platform/mgrlegacy/legacy_proxy.py:79
34893507
msgid "暂不支持轻应用迁移"
@@ -3902,6 +3920,11 @@ msgstr ""
39023920
"Unable to get SVN branch information, please check the warehouse address and "
39033921
"authentication information"
39043922

3923+
#: paasng/platform/sourcectl/views.py:418
3924+
#, python-format
3925+
msgid "%s的仓库信息查询异常"
3926+
msgstr "The warehouse information query of %s is abnormal"
3927+
39053928
#: paasng/platform/sourcectl/views.py:488
39063929
#, python-brace-format
39073930
msgid "仓库信息查询异常: {e}"
@@ -4107,8 +4130,10 @@ msgid "访问受保护资源失败"
41074130
msgstr "Failed to access protected resources"
41084131

41094132
#: paasng/utils/error_codes.py:53
4110-
msgid "无法彻底删除软删除的应用"
4111-
msgstr ""
4133+
#, fuzzy
4134+
#| msgid "无法删除应用集群"
4135+
msgid "无法彻底删除应用"
4136+
msgstr "cannot delete cluster"
41124137

41134138
#: paasng/utils/error_codes.py:55
41144139
msgid "模块创建失败"
@@ -4550,6 +4575,16 @@ msgstr "\"{input}\" is not a valid format, please startswith \"base64,\""
45504575
msgid "\"{input}\" is not a valid base64, please check it."
45514576
msgstr "\"{input}\" is not a valid base64, please check it."
45524577

4578+
#: paasng/utils/serializers.py:296
4579+
#, python-brace-format
4580+
msgid "至多包含 {max_items} 个对象."
4581+
msgstr ""
4582+
4583+
#: paasng/utils/serializers.py:297
4584+
#, python-brace-format
4585+
msgid "至少包含 {min_items} 个对象."
4586+
msgstr ""
4587+
45534588
#: paasng/utils/views.py:43
45544589
msgid "参数格式错误"
45554590
msgstr "Parameter format error"

apiserver/paasng/paas_wl/bk_app/cnative/specs/views.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
from contextlib import suppress
2020
from urllib.parse import quote
2121

22+
import requests
2223
from django.conf import settings
2324
from django.db import IntegrityError, transaction
2425
from django.shortcuts import get_object_or_404
2526
from django.utils.translation import gettext_lazy as _
2627
from drf_yasg.utils import swagger_auto_schema
28+
from moby_distribution.registry.exceptions import AuthFailed, PermissionDeny, ResourceNotFound
2729
from moby_distribution.registry.utils import parse_image
2830
from rest_framework import status
2931
from rest_framework.pagination import LimitOffsetPagination
@@ -116,7 +118,7 @@ def _validate_registry_permission(self, registry_service: DockerRegistryControll
116118
# bkrepo 的 docker 仓库,镜像凭证没有填写正确时,.touch() 时会抛出异常
117119
if registry_service.touch():
118120
return
119-
raise error_codes.INVALID_CREDENTIALS.f(_("权限不足或仓库不可达"))
121+
raise error_codes.LIST_TAGS_FAILED.f(_("权限不足或仓库不可达"))
120122

121123
@swagger_auto_schema(response_serializer=AlternativeVersionSLZ(many=True))
122124
def list_tags(self, request, code, module_name):
@@ -148,6 +150,14 @@ def list_tags(self, request, code, module_name):
148150

149151
try:
150152
alternative_versions = AlternativeVersionSLZ(registry_service.list_alternative_versions(), many=True).data
153+
except ResourceNotFound:
154+
raise error_codes.LIST_TAGS_FAILED.f(_("镜像仓库不存在,请检查仓库地址是否正确"), replace=True)
155+
except PermissionDeny:
156+
raise error_codes.INVALID_CREDENTIALS.f(_("镜像仓库权限不足, 请检查是否配置镜像凭证"), replace=True)
157+
except AuthFailed:
158+
raise error_codes.INVALID_CREDENTIALS.f(_("镜像仓库凭证错误, 请检查镜像凭证配置是否正确"), replace=True)
159+
except requests.exceptions.Timeout:
160+
raise error_codes.LIST_TAGS_FAILED.f(_("镜像仓库请求超时, 请检查网络连接"), replace=True)
151161
except Exception:
152162
if endpoint == "mirrors.tencent.com":
153163
# 镜像源迁移期间不能保证 registry 所有接口可用, 迁移期间增量镜像仓库无法查询 tag
@@ -163,7 +173,7 @@ def list_tags(self, request, code, module_name):
163173
}
164174
)
165175
logger.exception("unable to fetch repo info, may be the credential error or a network exception.")
166-
raise error_codes.LIST_TAGS_FAILED.f(_("%s的仓库信息查询异常") % code)
176+
raise error_codes.LIST_TAGS_FAILED.f(_("拉取镜像 Tag 失败"), replace=True)
167177
return Response(data=alternative_versions)
168178

169179

0 commit comments

Comments
 (0)