From 2ff30120fe2d373d8b9b2acf59a48245944884b5 Mon Sep 17 00:00:00 2001 From: Adam Lewis <23342526+Adam-D-Lewis@users.noreply.github.com> Date: Tue, 7 May 2024 14:41:37 -0500 Subject: [PATCH 01/10] change default gcp instances to cost optimized e2 family instances --- src/_nebari/stages/infrastructure/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/_nebari/stages/infrastructure/__init__.py b/src/_nebari/stages/infrastructure/__init__.py index f430c49126..170e23ca54 100644 --- a/src/_nebari/stages/infrastructure/__init__.py +++ b/src/_nebari/stages/infrastructure/__init__.py @@ -314,9 +314,9 @@ class GCPNodeGroup(schema.Base): DEFAULT_GCP_NODE_GROUPS = { - "general": GCPNodeGroup(instance="n1-standard-8", min_nodes=1, max_nodes=1), - "user": GCPNodeGroup(instance="n1-standard-4", min_nodes=0, max_nodes=5), - "worker": GCPNodeGroup(instance="n1-standard-4", min_nodes=0, max_nodes=5), + "general": GCPNodeGroup(instance="e2-highmem-4", min_nodes=1, max_nodes=1), + "user": GCPNodeGroup(instance="e2-standard-4", min_nodes=0, max_nodes=5), + "worker": GCPNodeGroup(instance="e2-standard-4", min_nodes=0, max_nodes=5), } From 6bbb3b70f598b253ca720935b23341c604095745 Mon Sep 17 00:00:00 2001 From: Adam Lewis <23342526+Adam-D-Lewis@users.noreply.github.com> Date: Tue, 14 May 2024 11:43:11 -0500 Subject: [PATCH 02/10] add upgrade message --- src/_nebari/upgrade.py | 47 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/_nebari/upgrade.py b/src/_nebari/upgrade.py index 2a98ff6f4b..f53377c0a7 100644 --- a/src/_nebari/upgrade.py +++ b/src/_nebari/upgrade.py @@ -784,6 +784,53 @@ def _version_specific_upgrade( return config +class Upgrade_2024_6_1(UpgradeStep): + version = "2024.6.1" + + def _version_specific_upgrade( + self, config, start_version, config_filename: Path, *args, **kwargs + ): + if provider := config.get("provider", ""): + if provider == ProviderEnum.gcp.value: + provider_full_name = provider_enum_name_map[provider] + if not config.get(provider_full_name, {}).get("node_groups", {}): + try: + continue_ = Prompt.ask( + f"""The default node groups for GCP have been changed to cost efficient e2 family nodes reducing the running cost of Nebari on GCP by ~50%. + This change will affect your current deployment, and will result in ~15 minutes of downtime during the upgrade step as the node groups are switched out, but shouldn't result in data loss. + + As always, make sure to [backup data](https://www.nebari.dev/docs/how-tos/manual-backup/) before upgrading. + + Would you like to upgrade to the cost effective node groups [purple]{config_filename}[/purple]? + If not, select "N" and the old default node groups will be added to the nebari config file. + """, + choices=["y", "N"], + default="y", + ) + if continue_ == "N": + config[provider_full_name]["node_groups"] = { + "general": { + "instance": "n1-standard-8", + "min_nodes": 1, + "max_nodes": 1, + }, + "user": { + "instance": "n1-standard-4", + "min_nodes": 0, + "max_nodes": 5, + }, + "worker": { + "instance": "n1-standard-4", + "min_nodes": 0, + "max_nodes": 5, + }, + } + except KeyError: + pass + + return config + + __rounded_version__ = str(rounded_ver_parse(__version__)) # Manually-added upgrade steps must go above this line From 75270ba13d5d1e58f106787f1bc28f8fb1f0290f Mon Sep 17 00:00:00 2001 From: Adam Lewis <23342526+Adam-D-Lewis@users.noreply.github.com> Date: Tue, 14 May 2024 11:57:29 -0500 Subject: [PATCH 03/10] make upgrade step 2024.5.2 --- src/_nebari/upgrade.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/_nebari/upgrade.py b/src/_nebari/upgrade.py index f53377c0a7..11d14d3ad8 100644 --- a/src/_nebari/upgrade.py +++ b/src/_nebari/upgrade.py @@ -784,8 +784,8 @@ def _version_specific_upgrade( return config -class Upgrade_2024_6_1(UpgradeStep): - version = "2024.6.1" +class Upgrade_2024_5_2(UpgradeStep): + version = "2024.5.2" def _version_specific_upgrade( self, config, start_version, config_filename: Path, *args, **kwargs From c45b0832a5e8418bc28abef3007930401f5a60c1 Mon Sep 17 00:00:00 2001 From: Adam Lewis <23342526+Adam-D-Lewis@users.noreply.github.com> Date: Tue, 14 May 2024 12:57:25 -0500 Subject: [PATCH 04/10] add upgrade message --- src/_nebari/upgrade.py | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/src/_nebari/upgrade.py b/src/_nebari/upgrade.py index 11d14d3ad8..df3ae66c19 100644 --- a/src/_nebari/upgrade.py +++ b/src/_nebari/upgrade.py @@ -3,6 +3,7 @@ import re import secrets import string +import textwrap from abc import ABC from pathlib import Path from typing import Any, ClassVar, Dict @@ -787,6 +788,10 @@ def _version_specific_upgrade( class Upgrade_2024_5_2(UpgradeStep): version = "2024.5.2" + @staticmethod + def _wrap(s): + return "\n".join("\n".join(textwrap.wrap(x)) for x in s.splitlines()) + def _version_specific_upgrade( self, config, start_version, config_filename: Path, *args, **kwargs ): @@ -795,15 +800,18 @@ def _version_specific_upgrade( provider_full_name = provider_enum_name_map[provider] if not config.get(provider_full_name, {}).get("node_groups", {}): try: - continue_ = Prompt.ask( - f"""The default node groups for GCP have been changed to cost efficient e2 family nodes reducing the running cost of Nebari on GCP by ~50%. - This change will affect your current deployment, and will result in ~15 minutes of downtime during the upgrade step as the node groups are switched out, but shouldn't result in data loss. + text = f""" +The default node groups for GCP have been changed to cost efficient e2 family nodes reducing the running cost of Nebari on GCP by ~50%. \ +This change will affect your current deployment, and will result in ~15 minutes of downtime during the upgrade step as the node groups are switched out, but shouldn't result in data loss. - As always, make sure to [backup data](https://www.nebari.dev/docs/how-tos/manual-backup/) before upgrading. +As always, make sure to [link=https://www.nebari.dev/docs/how-tos/manual-backup]backup data[/link] before upgrading. - Would you like to upgrade to the cost effective node groups [purple]{config_filename}[/purple]? - If not, select "N" and the old default node groups will be added to the nebari config file. - """, +Would you like to upgrade to the cost effective node groups [purple]{config_filename}[/purple]? +If not, select "N" and the old default node groups will be added to the nebari config file. +""".rstrip() + wrapped_text = self._wrap(text) + continue_ = Prompt.ask( + wrapped_text, choices=["y", "N"], default="y", ) @@ -827,7 +835,22 @@ def _version_specific_upgrade( } except KeyError: pass + else: + text = f""" +The default node groups for GCP have been changed to cost efficient e2 family nodes reducing the running cost of Nebari on GCP by ~50%. +Consider upgrading your node group instance types to the new default configuration. + +Upgrading your general node will result in ~15 minutes of downtime during the upgrade step as the node groups are switched out, but shouldn't result in data loss. + +As always, make sure to [link=https://www.nebari.dev/docs/how-tos/manual-backup]backup data[/link] before upgrading. + +The new default node groups instances are: +{json.dumps({'general': {'instance': 'e2-highmem-4'}, 'user': {'instance': 'e2-standard-4'}, 'worker': {'instance': 'e2-standard-4'}}, indent=4)} +Hit enter to continue +""".rstrip() + wrapped_text = self._wrap(text) + Prompt.ask(wrapped_text) return config From 647104851d340a1b413c9b63e026a017b43f37bf Mon Sep 17 00:00:00 2001 From: Adam Lewis <23342526+Adam-D-Lewis@users.noreply.github.com> Date: Tue, 14 May 2024 13:05:52 -0500 Subject: [PATCH 05/10] add link --- src/_nebari/upgrade.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/_nebari/upgrade.py b/src/_nebari/upgrade.py index df3ae66c19..013bf3f64b 100644 --- a/src/_nebari/upgrade.py +++ b/src/_nebari/upgrade.py @@ -804,7 +804,7 @@ def _version_specific_upgrade( The default node groups for GCP have been changed to cost efficient e2 family nodes reducing the running cost of Nebari on GCP by ~50%. \ This change will affect your current deployment, and will result in ~15 minutes of downtime during the upgrade step as the node groups are switched out, but shouldn't result in data loss. -As always, make sure to [link=https://www.nebari.dev/docs/how-tos/manual-backup]backup data[/link] before upgrading. +As always, make sure to backup data before upgrading. See https://www.nebari.dev/docs/how-tos/manual-backup for more information. Would you like to upgrade to the cost effective node groups [purple]{config_filename}[/purple]? If not, select "N" and the old default node groups will be added to the nebari config file. @@ -842,7 +842,7 @@ def _version_specific_upgrade( Upgrading your general node will result in ~15 minutes of downtime during the upgrade step as the node groups are switched out, but shouldn't result in data loss. -As always, make sure to [link=https://www.nebari.dev/docs/how-tos/manual-backup]backup data[/link] before upgrading. +As always, make sure to backup data before upgrading. See https://www.nebari.dev/docs/how-tos/manual-backup for more information. The new default node groups instances are: {json.dumps({'general': {'instance': 'e2-highmem-4'}, 'user': {'instance': 'e2-standard-4'}, 'worker': {'instance': 'e2-standard-4'}}, indent=4)} From 02f04c339f880540064d2223176830afdd02f5fa Mon Sep 17 00:00:00 2001 From: Adam Lewis <23342526+Adam-D-Lewis@users.noreply.github.com> Date: Tue, 14 May 2024 13:08:35 -0500 Subject: [PATCH 06/10] reset to develop --- src/_nebari/stages/infrastructure/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/_nebari/stages/infrastructure/__init__.py b/src/_nebari/stages/infrastructure/__init__.py index 170e23ca54..f430c49126 100644 --- a/src/_nebari/stages/infrastructure/__init__.py +++ b/src/_nebari/stages/infrastructure/__init__.py @@ -314,9 +314,9 @@ class GCPNodeGroup(schema.Base): DEFAULT_GCP_NODE_GROUPS = { - "general": GCPNodeGroup(instance="e2-highmem-4", min_nodes=1, max_nodes=1), - "user": GCPNodeGroup(instance="e2-standard-4", min_nodes=0, max_nodes=5), - "worker": GCPNodeGroup(instance="e2-standard-4", min_nodes=0, max_nodes=5), + "general": GCPNodeGroup(instance="n1-standard-8", min_nodes=1, max_nodes=1), + "user": GCPNodeGroup(instance="n1-standard-4", min_nodes=0, max_nodes=5), + "worker": GCPNodeGroup(instance="n1-standard-4", min_nodes=0, max_nodes=5), } From 86e50fbd86c0f2ff9b9d6f413e695c2dfc46db62 Mon Sep 17 00:00:00 2001 From: Marcelo Villa Date: Thu, 23 May 2024 11:49:49 -0400 Subject: [PATCH 07/10] Use textwrap.dedent instead of custom wrapper --- src/_nebari/upgrade.py | 102 +++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 54 deletions(-) diff --git a/src/_nebari/upgrade.py b/src/_nebari/upgrade.py index 013bf3f64b..e812f3cb40 100644 --- a/src/_nebari/upgrade.py +++ b/src/_nebari/upgrade.py @@ -788,69 +788,63 @@ def _version_specific_upgrade( class Upgrade_2024_5_2(UpgradeStep): version = "2024.5.2" - @staticmethod - def _wrap(s): - return "\n".join("\n".join(textwrap.wrap(x)) for x in s.splitlines()) def _version_specific_upgrade( self, config, start_version, config_filename: Path, *args, **kwargs ): - if provider := config.get("provider", ""): - if provider == ProviderEnum.gcp.value: - provider_full_name = provider_enum_name_map[provider] - if not config.get(provider_full_name, {}).get("node_groups", {}): - try: - text = f""" -The default node groups for GCP have been changed to cost efficient e2 family nodes reducing the running cost of Nebari on GCP by ~50%. \ -This change will affect your current deployment, and will result in ~15 minutes of downtime during the upgrade step as the node groups are switched out, but shouldn't result in data loss. - -As always, make sure to backup data before upgrading. See https://www.nebari.dev/docs/how-tos/manual-backup for more information. - -Would you like to upgrade to the cost effective node groups [purple]{config_filename}[/purple]? -If not, select "N" and the old default node groups will be added to the nebari config file. -""".rstrip() - wrapped_text = self._wrap(text) - continue_ = Prompt.ask( - wrapped_text, - choices=["y", "N"], - default="y", - ) - if continue_ == "N": - config[provider_full_name]["node_groups"] = { - "general": { - "instance": "n1-standard-8", - "min_nodes": 1, - "max_nodes": 1, - }, - "user": { - "instance": "n1-standard-4", - "min_nodes": 0, - "max_nodes": 5, - }, - "worker": { - "instance": "n1-standard-4", - "min_nodes": 0, - "max_nodes": 5, - }, - } - except KeyError: - pass - else: + if (provider := config.get("provider", "")) == ProviderEnum.gcp.value: + provider_full_name = provider_enum_name_map[provider] + if not config.get(provider_full_name, {}).get("node_groups", {}): + try: text = f""" -The default node groups for GCP have been changed to cost efficient e2 family nodes reducing the running cost of Nebari on GCP by ~50%. -Consider upgrading your node group instance types to the new default configuration. + The default node groups for GCP have been changed to cost efficient e2 family nodes reducing the running cost of Nebari on GCP by ~50%. \ + This change will affect your current deployment, and will result in ~15 minutes of downtime during the upgrade step as the node groups are switched out, but shouldn't result in data loss. + + As always, make sure to backup data before upgrading. See https://www.nebari.dev/docs/how-tos/manual-backup for more information. + + Would you like to upgrade to the cost effective node groups [purple]{config_filename}[/purple]? + If not, select "N" and the old default node groups will be added to the nebari config file. + """ + continue_ = Prompt.ask( + textwrap.dedent(text), + choices=["y", "N"], + default="y", + ) + if continue_ == "N": + config[provider_full_name]["node_groups"] = { + "general": { + "instance": "n1-standard-8", + "min_nodes": 1, + "max_nodes": 1, + }, + "user": { + "instance": "n1-standard-4", + "min_nodes": 0, + "max_nodes": 5, + }, + "worker": { + "instance": "n1-standard-4", + "min_nodes": 0, + "max_nodes": 5, + }, + } + except KeyError: + pass + else: + text = f""" + The default node groups for GCP have been changed to cost efficient e2 family nodes reducing the running cost of Nebari on GCP by ~50%. + Consider upgrading your node group instance types to the new default configuration. -Upgrading your general node will result in ~15 minutes of downtime during the upgrade step as the node groups are switched out, but shouldn't result in data loss. + Upgrading your general node will result in ~15 minutes of downtime during the upgrade step as the node groups are switched out, but shouldn't result in data loss. -As always, make sure to backup data before upgrading. See https://www.nebari.dev/docs/how-tos/manual-backup for more information. + As always, make sure to backup data before upgrading. See https://www.nebari.dev/docs/how-tos/manual-backup for more information. -The new default node groups instances are: -{json.dumps({'general': {'instance': 'e2-highmem-4'}, 'user': {'instance': 'e2-standard-4'}, 'worker': {'instance': 'e2-standard-4'}}, indent=4)} + The new default node groups instances are: + {json.dumps({'general': {'instance': 'e2-highmem-4'}, 'user': {'instance': 'e2-standard-4'}, 'worker': {'instance': 'e2-standard-4'}}, indent=4)} -Hit enter to continue -""".rstrip() - wrapped_text = self._wrap(text) - Prompt.ask(wrapped_text) + Hit enter to continue + """ + Prompt.ask(textwrap.dedent(text)) return config From 9555dbce34f43500a25ddbea7c7c7c0223914e3e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 23 May 2024 15:49:58 +0000 Subject: [PATCH 08/10] [pre-commit.ci] Apply automatic pre-commit fixes --- src/_nebari/upgrade.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/_nebari/upgrade.py b/src/_nebari/upgrade.py index e812f3cb40..947bb51fc1 100644 --- a/src/_nebari/upgrade.py +++ b/src/_nebari/upgrade.py @@ -788,7 +788,6 @@ def _version_specific_upgrade( class Upgrade_2024_5_2(UpgradeStep): version = "2024.5.2" - def _version_specific_upgrade( self, config, start_version, config_filename: Path, *args, **kwargs ): From fbb888fdd4562d59d04d94190e413229840acb22 Mon Sep 17 00:00:00 2001 From: Marcelo Villa Date: Thu, 23 May 2024 17:53:50 -0500 Subject: [PATCH 09/10] Add json dump after dedenting text. --- src/_nebari/upgrade.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/_nebari/upgrade.py b/src/_nebari/upgrade.py index 947bb51fc1..e1379df07b 100644 --- a/src/_nebari/upgrade.py +++ b/src/_nebari/upgrade.py @@ -795,8 +795,9 @@ def _version_specific_upgrade( provider_full_name = provider_enum_name_map[provider] if not config.get(provider_full_name, {}).get("node_groups", {}): try: - text = f""" - The default node groups for GCP have been changed to cost efficient e2 family nodes reducing the running cost of Nebari on GCP by ~50%. \ + text = textwrap.dedent( + f""" + The default node groups for GCP have been changed to cost efficient e2 family nodes reducing the running cost of Nebari on GCP by ~50%. This change will affect your current deployment, and will result in ~15 minutes of downtime during the upgrade step as the node groups are switched out, but shouldn't result in data loss. As always, make sure to backup data before upgrading. See https://www.nebari.dev/docs/how-tos/manual-backup for more information. @@ -804,8 +805,9 @@ def _version_specific_upgrade( Would you like to upgrade to the cost effective node groups [purple]{config_filename}[/purple]? If not, select "N" and the old default node groups will be added to the nebari config file. """ + ) continue_ = Prompt.ask( - textwrap.dedent(text), + text, choices=["y", "N"], default="y", ) @@ -830,7 +832,8 @@ def _version_specific_upgrade( except KeyError: pass else: - text = f""" + text = textwrap.dedent( + """ The default node groups for GCP have been changed to cost efficient e2 family nodes reducing the running cost of Nebari on GCP by ~50%. Consider upgrading your node group instance types to the new default configuration. @@ -839,11 +842,18 @@ def _version_specific_upgrade( As always, make sure to backup data before upgrading. See https://www.nebari.dev/docs/how-tos/manual-backup for more information. The new default node groups instances are: - {json.dumps({'general': {'instance': 'e2-highmem-4'}, 'user': {'instance': 'e2-standard-4'}, 'worker': {'instance': 'e2-standard-4'}}, indent=4)} - - Hit enter to continue """ - Prompt.ask(textwrap.dedent(text)) + ) + text += json.dumps( + { + "general": {"instance": "e2-highmem-4"}, + "user": {"instance": "e2-standard-4"}, + "worker": {"instance": "e2-standard-4"}, + }, + indent=4, + ) + text += "\n\nHit enter to continue" + Prompt.ask(text) return config From 4b5ff03cd8a6c5eca91947d9f2bd70c93a67986f Mon Sep 17 00:00:00 2001 From: Marcelo Villa Date: Thu, 23 May 2024 17:55:52 -0500 Subject: [PATCH 10/10] Update upgrade version number as it will likely be happening in June and not May. --- src/_nebari/upgrade.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/_nebari/upgrade.py b/src/_nebari/upgrade.py index e1379df07b..e35d7ea309 100644 --- a/src/_nebari/upgrade.py +++ b/src/_nebari/upgrade.py @@ -785,8 +785,8 @@ def _version_specific_upgrade( return config -class Upgrade_2024_5_2(UpgradeStep): - version = "2024.5.2" +class Upgrade_2024_6_1(UpgradeStep): + version = "2024.6.1" def _version_specific_upgrade( self, config, start_version, config_filename: Path, *args, **kwargs