Skip to content

Commit

Permalink
fix: adapt low version package to import high version
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhangSetSail committed Aug 11, 2023
1 parent a8ca867 commit 0b2c3ce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 6 additions & 5 deletions console/services/app_import_and_export_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def start_import_apps(self, scope, event_id, file_names, team_name=None, enterpr
import_record.status = "importing"
import_record.save()

def get_and_update_import_by_event_id(self, event_id):
def get_and_update_import_by_event_id(self, event_id, arch):
import_record = app_import_record_repo.get_import_record_by_event_id(event_id)
if not import_record:
raise RecordNotFound("import_record not found")
Expand All @@ -288,7 +288,7 @@ def get_and_update_import_by_event_id(self, event_id):
if import_record.status != "success":
if status == "success":
logger.debug("app import success !")
self.__save_enterprise_import_info(import_record, body["bean"]["metadata"])
self.__save_enterprise_import_info(import_record, body["bean"]["metadata"], arch)
import_record.source_dir = body["bean"]["source_dir"]
import_record.format = body["bean"]["format"]
import_record.status = "success"
Expand Down Expand Up @@ -427,7 +427,7 @@ def delete_import_app_dir(self, tenant, region, event_id):

app_import_record_repo.delete_by_event_id(event_id)

def __save_enterprise_import_info(self, import_record, metadata):
def __save_enterprise_import_info(self, import_record, metadata, arch):
rainbond_apps = []
rainbond_app_versions = []
metadata = json.loads(metadata)
Expand All @@ -441,8 +441,9 @@ def __save_enterprise_import_info(self, import_record, metadata):
if annotations.get("describe", ""):
app_describe = annotations.pop("describe", "")
app = rainbond_app_repo.get_rainbond_app_by_app_id(import_record.enterprise_id, app_template["group_key"])
arch_map = {a.get("arch"): 1 for a in apps}
arch = "&".join(list(arch_map.keys()))
if not arch:
arch_map = {a.get("arch", "amd64"): 1 for a in apps}
arch = "&".join(list(arch_map.keys()))
# if app exists, update it
if app:
app.scope = import_record.scope
Expand Down
3 changes: 2 additions & 1 deletion console/views/center_pool/app_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,10 @@ def get(self, request, event_id, *args, **kwargs):
paramType: path
"""
sid = None
arch = request.GET.get("arch")
try:
sid = transaction.savepoint()
record, apps_status = import_service.get_and_update_import_by_event_id(event_id)
record, apps_status = import_service.get_and_update_import_by_event_id(event_id, arch)
transaction.savepoint_commit(sid)
result = general_message(200, 'success', "查询成功", bean=record.to_dict(), list=apps_status)
except Exception as e:
Expand Down

0 comments on commit 0b2c3ce

Please sign in to comment.