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

[patch] Handle upgrade when instance does not exist #1415

Merged
merged 1 commit into from
Dec 17, 2024
Merged
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
23 changes: 13 additions & 10 deletions python/src/mas/cli/upgrade/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def upgrade(self, argv):
self.noConfirm = args.no_confirm
self.skipPreCheck = args.skip_pre_check
self.licenseAccepted = args.accept_license
next_mas_channel = None

if instanceId is None:
self.printH1("Set Target OpenShift Cluster")
Expand Down Expand Up @@ -70,18 +69,22 @@ def upgrade(self, argv):
print()
instanceId = prompt(HTML('<Yellow>Enter MAS instance ID: </Yellow>'), completer=suiteCompleter, validator=InstanceIDValidator(), validate_while_typing=False)

current_mas_channel = getMasChannel(self.dynamicClient, instanceId)

if current_mas_channel not in self.upgrade_path:
self.fatalError(f"No upgrade available, {instanceId} is are already on the latest release {current_mas_channel}")

next_mas_channel = self.upgrade_path[current_mas_channel]
currentChannel = getMasChannel(self.dynamicClient, instanceId)
if currentChannel is not None:
if currentChannel not in self.upgrade_path:
self.fatalError(f"No upgrade available, {instanceId} is are already on the latest release {currentChannel}")
nextChannel = self.upgrade_path[currentChannel]
else:
# We still allow the upgrade to proceed even though we can't detect the MAS instance. The upgrade may be being
# queued up to run after install for instance
currentChannel = "Unknown"
nextChannel = "Unknown"

if not self.licenseAccepted:
self.printH1("License Terms")
self.printDescription([
"To continue with the upgrade, you must accept the license terms:",
self.licenses[next_mas_channel]
self.licenses[nextChannel]
])

if self.noConfirm:
Expand All @@ -92,8 +95,8 @@ def upgrade(self, argv):

self.printH1("Review Settings")
print_formatted_text(HTML(f"<LightSlateGrey>Instance ID ..................... {instanceId}</LightSlateGrey>"))
print_formatted_text(HTML(f"<LightSlateGrey>Current MAS Channel ............. {current_mas_channel}</LightSlateGrey>"))
print_formatted_text(HTML(f"<LightSlateGrey>Next MAS Channel ................ {next_mas_channel}</LightSlateGrey>"))
print_formatted_text(HTML(f"<LightSlateGrey>Current MAS Channel ............. {currentChannel}</LightSlateGrey>"))
print_formatted_text(HTML(f"<LightSlateGrey>Next MAS Channel ................ {nextChannel}</LightSlateGrey>"))
print_formatted_text(HTML(f"<LightSlateGrey>Skip Pre-Upgrade Checks ......... {self.skipPreCheck}</LightSlateGrey>"))

if not self.noConfirm:
Expand Down
Loading