Skip to content
Open
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ shell.nix
build.nix
.direnv

# ignore deploments
# ignore deployments
do-jupyterhub
jupyterhub-aws
gcp-jupyterhub
Expand Down
16 changes: 8 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ci:
repos:
# general
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: end-of-file-fixer
exclude: "^docs-sphinx/cli.html"
Expand All @@ -37,12 +37,12 @@ repos:
exclude: "^src/_nebari/template/"

- repo: https://github.com/crate-ci/typos
rev: v1.30.0
rev: v1
hooks:
- id: typos

- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
rev: v2.4.2
hooks:
- id: codespell
args:
Expand All @@ -54,20 +54,20 @@ repos:
- tomli

# python
- repo: https://github.com/psf/black
rev: 25.1.0
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 26.5.1
hooks:
- id: black
args: ["--line-length=88", "--exclude=/src/_nebari/template/"]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.9
rev: v0.15.20
hooks:
- id: ruff
args: ["--fix"]

- repo: https://github.com/pycqa/isort
rev: 6.0.1
rev: 9.0.0a3
hooks:
- id: isort
name: isort
Expand All @@ -77,7 +77,7 @@ repos:

# terraform
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.97.4
rev: v1.108.0
hooks:
- id: terraform_fmt
args:
Expand Down
8 changes: 2 additions & 6 deletions src/_nebari/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ def deploy_configuration(
disable_checks: bool = False,
) -> Dict[str, Any]:
if config.prevent_deploy:
raise ValueError(
textwrap.dedent(
"""
raise ValueError(textwrap.dedent("""
Deployment prevented due to the prevent_deploy setting in your nebari-config.yaml file.
You could remove that field to deploy your Nebari, but please do NOT do so without fully understanding why that value was set in the first place.

Expand All @@ -29,9 +27,7 @@ def deploy_configuration(

PLEASE get in touch with Nebari development team at https://github.com/nebari-dev/nebari for assistance in proceeding.
Your data may be at risk without our guidance.
"""
)
)
"""))

if config.domain is None:
logger.info(
Expand Down
12 changes: 4 additions & 8 deletions src/_nebari/provider/cicd/linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ def generate_lint_message(config):
# lint/validate nebari-config.yaml
all_pass, messages, validate_code = nebari_validate(config)

pass_lint = textwrap.dedent(
"""
pass_lint = textwrap.dedent("""
This is an automatic response from the Nebari linter.
I just wanted to let you know that I linted your `nebari-config.yaml` in your PR and I didn't find any
problems.
"""
)
""")

# it should be better to parse this messages first
bad_lint = (
Expand All @@ -56,12 +54,10 @@ def generate_lint_message(config):

if not pr_config:
status = "no configuration file"
message = textwrap.dedent(
"""
message = textwrap.dedent("""
This is an automatic response from the Nebari linter.
I was trying to look for the `nebari-config.yaml` file to lint for you, but couldn't find any...
"""
)
""")

elif all_pass:
status = "Success"
Expand Down
54 changes: 16 additions & 38 deletions src/_nebari/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -1331,8 +1331,7 @@ def _version_specific_upgrade(
provider_full_name = provider_enum_name_map[provider]
if not config.get(provider_full_name, {}).get("node_groups", {}):
try:
text = textwrap.dedent(
f"""
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.

Expand All @@ -1343,8 +1342,7 @@ 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_ = kwargs.get("attempt_fixes", False) or Confirm.ask(
text,
default=True,
Expand All @@ -1370,8 +1368,7 @@ def _version_specific_upgrade(
except KeyError:
pass
else:
text = textwrap.dedent(
"""
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.

Expand All @@ -1380,8 +1377,7 @@ 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:
"""
)
""")
text += json.dumps(
{
"general": {"instance": "e2-highmem-4"},
Expand Down Expand Up @@ -1467,8 +1463,7 @@ def _version_specific_upgrade(

rich.print("\n ⚠️ Upgrade Warning ⚠️")

text = textwrap.dedent(
"""
text = textwrap.dedent("""
Please ensure no users are currently logged in prior to deploying this
update.

Expand All @@ -1489,8 +1484,7 @@ def _version_specific_upgrade(
mounted.

For more details check our [green][link=https://www.nebari.dev/docs/references/release/]release notes[/link][/green].
"""
)
""")
rich.print(text)
keycloak_admin = None

Expand Down Expand Up @@ -1522,15 +1516,11 @@ def _version_specific_upgrade(
)
except ValueError as e:
if "invalid_grant" in str(e):
rich.print(
textwrap.dedent(
"""
rich.print(textwrap.dedent("""
[red bold]Failed to connect to the Keycloak server.[/red bold]\n
[yellow]Please set the [bold]KEYCLOAK_ADMIN_USERNAME[/bold] and [bold]KEYCLOAK_ADMIN_PASSWORD[/bold]
environment variables with the Keycloak root credentials and try again.[/yellow]
"""
)
)
"""))
exit()
else:
# Handle other exceptions
Expand Down Expand Up @@ -1633,8 +1623,7 @@ def _version_specific_upgrade(
):
rich.print("\n ⚠️ Upgrade Warning ⚠️")

text = textwrap.dedent(
"""
text = textwrap.dedent("""
In this release, we have updated our maximum supported Kubernetes version from 1.29 to 1.31.
Please note that Nebari will NOT automatically upgrade your running Kubernetes version as part of
the redeployment process.
Expand All @@ -1645,8 +1634,7 @@ def _version_specific_upgrade(

For more information on upgrading Kubernetes for your specific cloud provider, please visit:
https://www.nebari.dev/docs/how-tos/kubernetes-version-upgrade
"""
)
""")
rich.print(text)

# If the Nebari provider is Azure, we must handle a major version upgrade
Expand All @@ -1657,9 +1645,7 @@ def _version_specific_upgrade(

if config.get("provider", "") == "azure":
rich.print("\n ⚠️ Azure Provider Upgrade Notice ⚠️")
rich.print(
textwrap.dedent(
"""
rich.print(textwrap.dedent("""
In this Nebari release, the Azure Terraform provider has been upgraded
from version 3.97.1 to 4.7.0. This major update includes internal schema
changes for certain resources, most notably the `azurerm_storage_account`.
Expand All @@ -1670,9 +1656,7 @@ def _version_specific_upgrade(

For detailed information on the Azure provider 4.x changes, please visit:
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/4.0-upgrade-guide
"""
)
)
"""))

# Prompt user for confirmation
continue_ = kwargs.get("attempt_fixes", False) or Confirm.ask(
Expand Down Expand Up @@ -1753,8 +1737,7 @@ def _version_specific_upgrade(
]:
rich.print("\n ⚠️ Node Taints Update ⚠️")

text = textwrap.dedent(
"""
text = textwrap.dedent("""
Starting with Nebari version 2025.4.1, node taints will be automatically applied to all non-general node groups by default.
Node taints help ensure that specific workloads run only on designated nodes,
improving resource utilization and isolation. This change will include:
Expand All @@ -1764,8 +1747,7 @@ def _version_specific_upgrade(

If you prefer not to use node taints, you can opt out by adding `taints: []`
to each node group definition in your nebari-config.yaml file.
"""
)
""")
rich.print(text)

provider_full_name = provider_enum_name_map.get(provider)
Expand Down Expand Up @@ -2074,9 +2056,7 @@ def _version_specific_upgrade(
namespace = config.get("namespace", "dev")

rich.print("\n ⚠️ CRITICAL UPGRADE WARNING ⚠️")
rich.print(
textwrap.dedent(
f"""
rich.print(textwrap.dedent(f"""
This version includes a major [bold red]Keycloak upgrade[/bold red] from the [green]keycloak[/green] chart (15.0.2)
to the [green]keycloakx[/green] chart (7.1.3). This upgrade changes the underlying architecture
from JBoss/WildFly to Quarkus.
Expand All @@ -2092,9 +2072,7 @@ def _version_specific_upgrade(

After this upgrade step completes, you will need to run:
[cyan]nebari deploy -c {config_filename}[/cyan] to apply the changes
"""
)
)
"""))
# Get all available contexts
contexts, active_context = kubernetes.config.list_kube_config_contexts()

Expand Down
12 changes: 4 additions & 8 deletions tests/tests_unit/test_cli_keycloak.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,15 @@ def parse_yaml(stdout_str: str, headers: list):


def test_parse_table():
table_str = dedent(
""" Keycloak Users (Count: 3)
table_str = dedent(""" Keycloak Users (Count: 3)
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Username ┃ Email ┃ Groups ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ test-dev │ test-dev@example.com │ ['analyst', 'developer'] │
│ test-admin │ test-admin@example.com │ ['admin'] │
│ test-nogroup │ test-nogroup@example.com │ [] │
└──────────────┴──────────────────────────┴──────────────────────────┘
"""
)
""")
expected = [
{
"username": "test-dev",
Expand All @@ -160,14 +158,12 @@ def test_parse_table():


def test_parse_yaml():
yaml_str = dedent(
"""
yaml_str = dedent("""
- name: test
roles:
- allow-test-to-pass
- other-role
"""
)
""")
expected = [
{
"name": "test",
Expand Down
Loading
Loading