Skip to content

Commit

Permalink
Merge branch 'ADCM-4560' into 'develop'
Browse files Browse the repository at this point in the history
ADCM-4560 Fixed migration ADCM settings

See merge request arenadata/development/adcm!3033
  • Loading branch information
a-alferov committed Sep 28, 2023
2 parents db113c1 + 34a6da3 commit f69fe51
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
4 changes: 3 additions & 1 deletion conf/adcm/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

type: adcm
name: ADCM
version: 2.9
version: 3.0

actions:
run_ldap_sync:
Expand Down Expand Up @@ -45,6 +45,8 @@
type: "group"
activatable: true
active: true
ui_options:
advanced: true
subs:
- name: "url"
description: "URL to send collected statistic"
Expand Down
4 changes: 2 additions & 2 deletions python/api_v2/tests/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@ def setUp(self) -> None:
config_log = ConfigLog.objects.get(pk=self.original_adcm.config.current)
config_log.config["job_log"]["log_rotation_on_fs"] = 120
config_log.config["job_log"]["log_rotation_in_db"] = 50
config_log.config["config_rotation"] = 10
config_log.save()
config_log.config["config_rotation"]["config_rotation_in_db"] = 10
config_log.save(update_fields=["config"])

def test_adcm_2_6_upgrade_success(self):
init()
Expand Down
24 changes: 18 additions & 6 deletions python/cm/bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,26 @@ def upgrade_adcm(adcm, bundle):
with transaction.atomic():
adcm.prototype = new_proto
adcm.save()
config_log_old = ConfigLog.objects.get(obj_ref=adcm.config, id=adcm.config.current)
switch_config(adcm, new_proto, old_proto)
config_log_new = ConfigLog.objects.get(obj_ref=adcm.config, id=adcm.config.current)
if rpm.compare_versions("2.6", old_proto.version) > -1 and rpm.compare_versions(new_proto.version, "2.7") > -1:
config_log_new.config["audit_data_retention"].update(config_log_old.config["job_log"])
config_log_new.config["audit_data_retention"]["config_rotation_in_db"] = config_log_old.config.get(
"config_rotation", config_log_new.config["audit_data_retention"]["config_rotation_in_db"]

if rpm.compare_versions(old_proto.version, "2.6") <= 0 <= rpm.compare_versions(new_proto.version, "2.7"):
config_log_old = ConfigLog.objects.get(obj_ref=adcm.config, id=adcm.config.previous)
config_log_new = ConfigLog.objects.get(obj_ref=adcm.config, id=adcm.config.current)
log_rotation_on_fs = config_log_old.config.get("job_log", {}).get(
"log_rotation_on_fs", config_log_new.config["audit_data_retention"]["log_rotation_on_fs"]
)
config_log_new.config["audit_data_retention"]["log_rotation_on_fs"] = log_rotation_on_fs

log_rotation_in_db = config_log_old.config.get("job_log", {}).get(
"log_rotation_in_db", config_log_new.config["audit_data_retention"]["log_rotation_in_db"]
)
config_log_new.config["audit_data_retention"]["log_rotation_in_db"] = log_rotation_in_db

config_rotation_in_db = config_log_old.config.get("config_rotation", {}).get(
"config_rotation_in_db", config_log_new.config["audit_data_retention"]["config_rotation_in_db"]
)
config_log_new.config["audit_data_retention"]["config_rotation_in_db"] = config_rotation_in_db

config_log_new.save(update_fields=["config"])

logger.info(
Expand Down
2 changes: 1 addition & 1 deletion python/cm/tests/test_management_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def _get_expected_data() -> dict:
bundles = [
{
"name": "ADCM",
"version": "2.9",
"version": Bundle.objects.get(name="ADCM").version,
"edition": "community",
"date": Bundle.objects.get(name="ADCM").date.strftime(date_fmt),
},
Expand Down

0 comments on commit f69fe51

Please sign in to comment.