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: operator name null #1464

Merged
merged 3 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions console/services/app_actions/app_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ def deploy(self, tenant, service, user, oauth_instance=None, service_copy_path=N
else:
logger.warning("service_source is not exist for service {0}".format(service.service_id))
try:
body['operator'] = user.nick_name
re = region_api.build_service(service.service_region, tenant.tenant_name, service.service_alias, body)
if re and re.get("bean") and re.get("bean").get("status") != "success":
logger.error("deploy component failure {}".format(re))
Expand Down Expand Up @@ -600,6 +601,7 @@ def batch_operations(self, tenant, region_name, user, action, service_ids, oauth
if code != 200:
raise AbortRequest(415, "failed to get component", "组件信息获取失败")
# 获取数据中心信息
data['operator'] = user.nick_name
try:
_, body = region_api.batch_operation_service(region_name, tenant.tenant_name, data)
events = body["bean"]["batch_result"]
Expand Down
2 changes: 1 addition & 1 deletion console/services/group_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def batch_delete_app_services(self, user, tenant_id, region_name, app_id):
if service.create_status == "complete":
service_dict["service_id"] = service.service_id
stop_infos_list.append(service_dict)
body = {"operation": "stop", "stop_infos": stop_infos_list}
body = {"operation": "stop", "stop_infos": stop_infos_list,"operator":user.nick_name}
try:
region_api.batch_operation_service(region_name, tenant.tenant_name, body)
except region_api.CallApiError as e:
Expand Down
5 changes: 3 additions & 2 deletions console/services/k8s_attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ def update_k8s_attribute(self, tenant, component, region_name, attribute):
region_api.update_component_k8s_attribute(tenant.tenant_name, region_name, component.service_alias, attribute)

@transaction.atomic
def delete_k8s_attribute(self, tenant, component, region_name, name):
def delete_k8s_attribute(self, tenant, component, region_name, name, operator):
k8s_attribute_repo.delete(component.service_id, name)
region_api.delete_component_k8s_attribute(tenant.tenant_name, region_name, component.service_alias, {"name": name})
region_api.delete_component_k8s_attribute(tenant.tenant_name, region_name, component.service_alias,
{"name": name, "operator": operator})


k8s_attribute_service = ComponentK8sAttributeService()
2 changes: 1 addition & 1 deletion console/services/market_app/app_restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def __init__(self, tenant, region: RegionConfig, user, app: ServiceGroup, compon
self.original_app = OriginalApp(tenant, region, app, component_group.ID, self.support_labels)
self.snapshot = self._get_snapshot()
self.new_app = self._create_new_app()
super(AppRestore, self).__init__(self.original_app, self.new_app)
super(AppRestore, self).__init__(self.original_app, self.new_app,self.user)

def restore(self):
# Sync the new application to the data center first
Expand Down
3 changes: 2 additions & 1 deletion console/services/market_app/app_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def __init__(self,
self.property_changes.ensure_dep_changes(self.new_app, self.original_app)
self.app_property_changes = self._get_app_property_changes()

super(AppUpgrade, self).__init__(self.original_app, self.new_app)
super(AppUpgrade, self).__init__(self.original_app, self.new_app,self.user)

def preinstall(self):
self.pre_install_plugins()
Expand Down Expand Up @@ -264,6 +264,7 @@ def _sync_plugins(self, plugins: [Plugin]):
region_api.sync_plugins(self.tenant_name, self.region_name, body)

def _install_predeploy(self):

try:
helm_chart_parameter = dict()
helm_chart_parameter["app_name"] = self.app_template["group_name"]
Expand Down
10 changes: 8 additions & 2 deletions console/services/market_app/market_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@


class MarketApp(object):
def __init__(self, original_app: OriginalApp, new_app: NewApp):
def __init__(self, original_app: OriginalApp, new_app: NewApp,user):
self.original_app = original_app
self.new_app = new_app

self.user = user

self.tenant_name = self.new_app.tenant.tenant_name
self.region_name = self.new_app.region_name

Expand Down Expand Up @@ -73,6 +75,7 @@ def predeploy(self, helm_chart_parameter):
builds = self._generate_builds("export_helm_chart")
res = []
body = {
"operator": self.user.nick_name,
"operation": "export",
"build_infos": builds,
"helm_chart": {
Expand All @@ -89,7 +92,8 @@ def predeploy(self, helm_chart_parameter):

return res

def deploy(self):
def deploy(self,):
Copy link
Contributor

Choose a reason for hiding this comment

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

多了一个逗号


builds = self._generate_builds()
upgrades = self._generate_upgrades()

Expand All @@ -98,6 +102,7 @@ def deploy(self):
res = []
if builds:
body = {
"operator": self.user.nick_name,
"operation": "build",
"build_infos": builds,
}
Expand All @@ -106,6 +111,7 @@ def deploy(self):

if upgrades:
body = {
"operator": self.user.nick_name,
"operation": "upgrade",
"upgrade_infos": upgrades,
}
Expand Down
1 change: 1 addition & 0 deletions console/services/market_app_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,7 @@ def __deploy_services(self, tenant, user, service_list, app_templates):
body = dict()
code, data = app_manage_service.deploy_services_info(
body, service_list, tenant, user, oauth_instance=None, template_apps=app_templates, upgrade=False)
data['operator'] = user.nick_name
if code == 200:
# 获取数据中心信息
one_service = service_list[0]
Expand Down
5 changes: 4 additions & 1 deletion console/views/k8s_attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ def put(self, request, name, *args, **kwargs):
attribute = request.data.get("attribute", {})
if name != attribute.get("name", ""):
raise AbortRequest(400, "参数错误")
attribute['operator'] = self.user.nick_name
k8s_attribute_service.update_k8s_attribute(self.tenant, self.service, self.region_name, attribute)
return Response(general_message(200, "success", "修改成功"))

def delete(self, request, name, *args, **kwargs):
k8s_attribute_service.delete_k8s_attribute(self.tenant, self.service, self.region_name, name)
k8s_attribute_service.delete_k8s_attribute(self.tenant, self.service, self.region_name, name,self.user.nick_name)
return Response(general_message(200, "success", "删除成功"))


Expand All @@ -32,5 +33,7 @@ def get(self, request, *args, **kwargs):

def post(self, request, *args, **kwargs):
attribute = request.data.get("attribute", {})
attribute['operator'] = self.user.nick_name
k8s_attribute_service.create_k8s_attribute(self.tenant, self.service, self.region_name, attribute)
attribute['operator'] = self.user.nick_name
Copy link
Contributor

Choose a reason for hiding this comment

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

重复了

return Response(general_message(200, "success", "创建成功"))
Loading