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

fix: 修复云原生应用部署操作会被重复记录问题 #1534

Merged
merged 3 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions apiserver/paasng/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -809,10 +809,8 @@ msgstr "Delete"

#: paasng/bk_plugins/pluginscenter/constants.py:147
#: paasng/misc/audit/constants.py:88
#, fuzzy
#| msgid "已下架"
msgid "下架"
msgstr "Archived"
msgstr "archive"

#: paasng/bk_plugins/pluginscenter/constants.py:148
msgid "重新上架"
Expand Down Expand Up @@ -1718,16 +1716,16 @@ msgstr "renew"
msgid "部署"
msgstr "Deploy"

#: paasng/misc/audit/models.py:103
#, python-brace-format
msgid " {self.module_name} 模块{env}"
msgstr " {self.module_name} module {env}"

#: paasng/misc/audit/models.py:105
#, python-brace-format
msgid " {self.module_name} 模块"
msgstr " {self.module_name} module"

#: paasng/misc/audit/models.py:103
#, python-brace-format
msgid " {self.module_name} 模块{env}"
msgstr " {self.module_name} module {env}"

#: paasng/misc/audit/models.py:107
#, python-brace-format
msgid "{env}"
Expand All @@ -1736,7 +1734,7 @@ msgstr "{env}"
#: paasng/misc/audit/models.py:122
#, python-brace-format
msgid "{user} {operation}{module_env_info}{result}"
msgstr "{user} {operation}{module_env_info}{result}"
msgstr "{user} {operation}{module_env_info} {result}"

#: paasng/misc/audit/models.py:127
#, python-brace-format
Expand Down
3 changes: 3 additions & 0 deletions apiserver/paasng/paasng/misc/audit/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from paasng.misc.audit import constants
from paasng.misc.audit.models import AppLatestOperationRecord, AppOperationRecord
from paasng.misc.audit.service import DataDetail, add_app_audit_record
from paasng.platform.applications.constants import ApplicationType
from paasng.platform.applications.models import Application, ModuleEnvironment
from paasng.platform.engine.constants import JobStatus
from paasng.platform.engine.models import Deployment
Expand Down Expand Up @@ -102,6 +103,8 @@ def on_model_post_save(sender, instance, created, raw, using, update_fields, *ar
def on_deploy_finished(sender: ModuleEnvironment, deployment: Deployment, **kwargs):
"""当普通应用部署完成后,记录操作审计记录"""
application = deployment.app_environment.application
if application.type != ApplicationType.DEFAULT:
return
result_code = JOB_STATUS_TO_RESULT_CODE.get(deployment.status, constants.ResultCode.ONGOING)
add_app_audit_record(
app_code=application.code,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def finish_archive(self, operation_id: str, status: ReleaseStatus, error_detail:
action_id=AppAction.BASIC_DEVELOP,
operation=OperationEnum.OFFLINE,
target=OperationTarget.APP,
module_name=offline_op.app_environmenv.module.name,
module_name=offline_op.app_environment.module.name,
environment=offline_op.app_environment.environment,
result_code=result_code,
)