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: merge some bugs #1366

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion console/models/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class Meta:
install_number = models.IntegerField(default=0, help_text='安装次数')
is_official = models.BooleanField(default=False, help_text='是否官方认证')
details = models.TextField(null=True, blank=True, help_text="应用详情")
arch = models.CharField(max_length=32, default="amd64", help_text="架构")
arch = models.CharField(max_length=32, help_text="架构")


class RainbondCenterAppVersion(BaseModel):
Expand Down
14 changes: 10 additions & 4 deletions console/services/app_import_and_export_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,13 +437,17 @@ def __save_enterprise_import_info(self, import_record, metadata):
for app_template in metadata:
annotations = app_template.get("annotations", {})
app_describe = app_template.pop("describe", "")
apps = app_template.get("apps")
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 app exists, update it
if app:
app.scope = import_record.scope
app.describe = app_describe
app.arch = app.arch if arch in app.arch.split(",") else app.arch + "," + arch
app.save()
app_version = rainbond_app_repo.get_rainbond_app_version_by_app_id_and_version(
app.app_id, app_template["group_version"])
Expand All @@ -460,10 +464,11 @@ def __save_enterprise_import_info(self, import_record, metadata):
app_version.template_version = app_template["template_version"]
app_version.app_version_info = version_info,
app_version.version_alias = version_alias,
app_version.arch = arch
app_version.save()
else:
# create a new version
rainbond_app_versions.append(self.create_app_version(app, import_record, app_template))
rainbond_app_versions.append(self.create_app_version(app, import_record, app_template, arch))
else:
image_base64_string = app_template.pop("image_base64_string", "")
if annotations.get("image_base64_string"):
Expand All @@ -487,15 +492,15 @@ def __save_enterprise_import_info(self, import_record, metadata):
scope=import_record.scope,
describe=app_describe,
pic=pic_url,
)
arch=arch)
rainbond_apps.append(rainbond_app)
# create a new app version
rainbond_app_versions.append(self.create_app_version(rainbond_app, import_record, app_template))
rainbond_app_versions.append(self.create_app_version(rainbond_app, import_record, app_template, arch))
rainbond_app_repo.bulk_create_rainbond_app_versions(rainbond_app_versions)
rainbond_app_repo.bulk_create_rainbond_apps(rainbond_apps)

@staticmethod
def create_app_version(app, import_record, app_template):
def create_app_version(app, import_record, app_template, arch):
version = RainbondCenterAppVersion(
scope=import_record.scope,
enterprise_id=import_record.enterprise_id,
Expand All @@ -508,6 +513,7 @@ def create_app_version(app, import_record, app_template):
is_complete=1,
app_version_info=app_template.get("annotations", {}).get("version_info", ""),
version_alias=app_template.get("annotations", {}).get("version_alias", ""),
arch=arch,
)
if app_store.is_no_multiple_region_hub(import_record.enterprise_id):
version.region_name = import_record.region
Expand Down
13 changes: 10 additions & 3 deletions console/services/helm_app_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,14 @@ def check_helm_app(self, name, repo_name, chart_name, version, overrides, region
res, body = region_api.check_helm_app(region, tenant_name, data)
return res, body["bean"]

def create_helm_center_app(self, **kwargs):
def create_helm_center_app(self, center_app, region_name):
logger.info("begin create_helm_center_app")
return RainbondCenterApp(**kwargs).save()
res, body = region_api.get_cluster_nodes_arch(region_name)
chaos_arch = list(set(body.get("list")))
logger.info("arch{}".format(chaos_arch))
arch = chaos_arch[0] if chaos_arch else "amd64"
center_app["arch"] = arch
return RainbondCenterApp(**center_app).save()

def generate_template(self, cvdata, app_model, version, tenant, chart, region_name, enterprise_id, user_id, overrides,
app_id):
Expand Down Expand Up @@ -209,7 +214,9 @@ def generate_template(self, cvdata, app_model, version, tenant, chart, region_na
app_template=template,
template_version="v2",
enterprise_id=enterprise_id,
upgrade_time=time.time())
upgrade_time=time.time(),
arch=arch
)
app_version.region_name = region_name
app_version.save()

Expand Down
11 changes: 7 additions & 4 deletions console/services/share_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,10 +912,13 @@ def create_share_info(self, tenant, region_name, share_record, share_team, share
app_version.region_name = region_name
app_version.save()
if not market_id:
arch = list(local_app_version.arch.split(","))
if app_version.arch not in arch:
arch.append(app_version.arch)
local_app_version.arch = ",".join(arch)
if local_app_version.arch:
arch = list(local_app_version.arch.split(","))
if app_version.arch not in arch:
arch.append(app_version.arch)
local_app_version.arch = ",".join(arch)
else:
local_app_version.arch = app_version.arch
local_app_version.save()
share_record.step = 2
share_record.scope = scope
Expand Down
2 changes: 1 addition & 1 deletion console/views/helm_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def post(self, request, *args, **kwargs):
"enterprise_id": self.enterprise.enterprise_id,
"details": details
}
helm_app_service.create_helm_center_app(**center_app)
helm_app_service.create_helm_center_app(center_app, self.region_name)
data["exist"] = False
data["app_model_id"] = app_id
result = general_message(200, "success", "创建成功", bean=json.dumps(data))
Expand Down
Loading