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: adapt low version package to import high version #1377

Merged
merged 1 commit into from Aug 11, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions console/services/app_import_and_export_service.py
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
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