Skip to content

Commit

Permalink
Merge pull request #753 from NethServer/feat-7082
Browse files Browse the repository at this point in the history
Disable updates during NS7 migration

Refs NethServer/dev#7082
  • Loading branch information
DavidePrincipi authored Nov 26, 2024
2 parents 7cda9a4 + 15519d0 commit de681a8
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 2 deletions.
25 changes: 23 additions & 2 deletions core/imageroot/usr/local/agent/pypkg/cluster/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,23 @@ def _get_leader_core_version():
leader_core_version = semver.Version(999)
return leader_core_version

def get_disabled_updates_reason(rdb):
"""
Returns a string describing why updates are disabled.
If updates are enabled, returns an empty string.
Possible return values:
- "ns7_migration": Updates are disabled due to NS7 migration.
- "": Updates are enabled.
"""
for kflags in rdb.keys('node/*/flags'):
if rdb.sismember(kflags, 'nomodules'):
return "ns7_migration"
return ""

def list_updates(rdb, skip_core_modules=False, with_testing_update=False):
if get_disabled_updates_reason(rdb) != "":
return [] # updates are disabled
updates = []
installed_modules = list_installed(rdb, skip_core_modules)
available_modules = _get_available_modules(rdb)
Expand Down Expand Up @@ -475,7 +491,12 @@ def get_node_core_versions(rdb):

def list_core_modules(rdb):
"""List core modules and if they can be updated."""
updates = list_updates(rdb, skip_core_modules=False)
if get_disabled_updates_reason(rdb) == "":
updates = list_updates(rdb, skip_core_modules=False)
updates_are_active = True
else:
updates = []
updates_are_active = False
def _get_module_update(module_id):
for oupdate in updates:
if oupdate['id'] == module_id:
Expand All @@ -495,7 +516,7 @@ def _calc_core_update(current, latest):
vlatest = semver.parse_version_info(latest)
except:
vlatest = semver.Version(0)
if vlatest > vcur:
if updates_are_active and vlatest > vcur:
return latest
else:
return ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,12 @@ def calculate_node_install_destinations(module):
continue
return module_destinations

disabled_updates_reason = cluster.modules.get_disabled_updates_reason(rdb)

# Prepare variables for later use
for a in available:
a["updates"] = []
a["disabled_updates_reason"] = disabled_updates_reason
a["installed"] = []
if a["source"] in installed.keys():
a["installed"] = installed[a["source"]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"update": "0.0.2"
}
],
"disabled_updates_reason": "",
"installed": [
[
{
Expand Down Expand Up @@ -193,6 +194,10 @@
"type": "string",
"description": "Date and time of last modification to remote repodata"
},
"disabled_updates_reason": {
"enum": ["", "ns7_migration"],
"description": "A non-empty strings indicates that updates are disabled for some reason. The string value identifies the reason."
},
"updates": {
"type": "array",
"items": {
Expand Down
2 changes: 2 additions & 0 deletions core/ui/public/i18n/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,8 @@
"num_instances_updated": "{numInstances} instances updated",
"n_instances_will_be_updated_c": "Update of {num} instance will start in a moment... | Update of {num} instances will start in a moment...",
"version_version_available": "Version {version} available",
"updates_disabled_ns7_migration_title": "Updates are suspended",
"updates_disabled_ns7_migration_description": "There is an ongoing NS7 migration. Updates will resume once the migration is complete.",
"app_categories": {
"core": "Core",
"development": "Development",
Expand Down
17 changes: 17 additions & 0 deletions core/ui/src/views/SoftwareCenter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,18 @@
/>
</cv-column>
</cv-row>
<cv-row v-if="updatesAreDisabledForMigration">
<cv-column>
<NsInlineNotification
kind="info"
:title="$t('software_center.updates_disabled_ns7_migration_title')"
:description="
$t('software_center.updates_disabled_ns7_migration_description')
"
:showCloseButton="false"
/>
</cv-column>
</cv-row>
<div>
<cv-search
:label="$t('software_center.search_placeholder')"
Expand Down Expand Up @@ -437,6 +449,11 @@ export default {
.filter((repository) => repository.testing)
.map((repository) => repository.name);
},
updatesAreDisabledForMigration() {
return this.modules.some(
(m) => m["disabled_updates_reason"] == "ns7_migration"
);
},
},
watch: {
"q.search": function () {
Expand Down

0 comments on commit de681a8

Please sign in to comment.