Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: 文件分发 & 存储 支持制品库 #93

Merged
merged 4 commits into from
Sep 22, 2021

Conversation

ZhuoZhuoCrayon
Copy link
Member

No description provided.

@ZhuoZhuoCrayon ZhuoZhuoCrayon self-assigned this Sep 9, 2021
@codecov-commenter
Copy link

codecov-commenter commented Sep 9, 2021

Codecov Report

Merging #93 (8fa56f5) into V2.1.348rc (5def023) will increase coverage by 0.49%.
The diff coverage is 81.31%.

Impacted file tree graph

@@              Coverage Diff               @@
##           V2.1.348rc      #93      +/-   ##
==============================================
+ Coverage       58.89%   59.38%   +0.49%     
==============================================
  Files             396      410      +14     
  Lines           25970    26510     +540     
==============================================
+ Hits            15295    15743     +448     
- Misses          10675    10767      +92     
Impacted Files Coverage Δ
apps/backend/agent/manager.py 17.13% <0.00%> (ø)
apps/backend/components/collections/bulk_job.py 65.67% <0.00%> (ø)
...s/backend/components/collections/bulk_job_redis.py 75.82% <0.00%> (+0.71%) ⬆️
apps/backend/subscription/steps/base.py 42.16% <0.00%> (ø)
apps/backend/subscription/steps/plugin.py 35.30% <0.00%> (ø)
apps/node_man/tools/plugin_v2.py 82.89% <ø> (+0.33%) ⬆️
apps/node_man/views/plugin_v2.py 48.61% <0.00%> (ø)
apps/node_man/handlers/plugin_v2.py 58.00% <29.41%> (-7.52%) ⬇️
apps/core/files/file_source.py 40.54% <40.54%> (ø)
apps/node_man/periodic_tasks/update_proxy_file.py 25.39% <50.00%> (ø)
... and 52 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5def023...8fa56f5. Read the comment docs.

apps/backend/api/job.py Show resolved Hide resolved
apps/backend/components/collections/agent.py Show resolved Hide resolved
@@ -29,7 +29,7 @@ def handle(self, *args, **options):
# 接入点配置的nginx路径
nginx_paths = [ap.nginx_path for ap in AccessPoint.objects.all() if ap.nginx_path]
# 默认nginx路径
nginx_paths.append(settings.NGINX_DOWNLOAD_PATH)
nginx_paths.append(settings.DOWNLOAD_PATH)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

43行 这里没改造,还是用的本地文件copy,应该调整为storage.save

@@ -287,6 +310,15 @@ def validate(self, data):
creator = serializers.CharField()
bk_app_code = serializers.CharField()

def validate(self, attrs):
if attrs["category"] not in DownloadRecord.CATEGORY_TASK_DICT:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个为什么不直接在serializer字段上加choices

)
pkg_parse_result.update(
{
"pkg_abs_path": package_info["pkg_relative_path"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

abs_pathrelative_path 迷惑性

try:
if files.md5sum(file_obj=storage.open(name=file_path)) != md5:
raise ValidationError(_("上传文件MD5校验失败,请确认重试"))
except Exception as e:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的异常捕获会把上面的 MD5校验异常捕获,抛出文件不存在的异常

upload_result = self.client.post(
path="/backend/package/upload/",
data={
**self.API_AUTH_PARAMS,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

**self.API_AUTH_PARAMS每个请求都需要的话,可以考虑在 PluginBaseTestCase 里重写self.client,请求时在参数里加上 API_AUTH_PARAMS

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

或者在更上层的BaseTestCase基类中去实现

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apps.utils.unittest.base.CustomAPIClient 加了 common_request_data ,上层 TestCasesetUp 等钩子通过self.client.common_request_data 设置通用请求

) -> List[Dict[str, Any]]:

# 获取或创建文件源
file_source_obj = BkJobFileSourceManager.get_or_create_file_source(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

每次handle的时候都去检查或创建,会带来额外的性能消耗?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

每次handle的时候都去检查或创建,会带来额外的性能消耗?
已加缓存

@ZhuoZhuoCrayon ZhuoZhuoCrayon changed the base branch from V2.1.346rc to V2.1.347rc September 15, 2021 09:16
@ZhuoZhuoCrayon ZhuoZhuoCrayon force-pushed the _V2.1.X/issue#2 branch 2 times, most recently from 60caa11 to 44e2e8b Compare September 16, 2021 09:24
@zhangzhw8 zhangzhw8 changed the base branch from V2.1.347rc to V2.1.348rc September 16, 2021 09:42
@zhangzhw8 zhangzhw8 merged commit 4b91618 into V2.1.348rc Sep 22, 2021
@ZhuoZhuoCrayon ZhuoZhuoCrayon deleted the _V2.1.X/issue#2 branch March 8, 2022 03:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants