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

[BUG] - IndexError during initialization with DigitalOcean provider #2810

Closed
viniciusdc opened this issue Oct 31, 2024 · 3 comments
Closed
Labels
type: bug 🐛 Something isn't working

Comments

@viniciusdc
Copy link
Contributor

viniciusdc commented Oct 31, 2024

Describe the bug

When initializing Nebari with DigitalOcean as the cloud provider, an IndexError: list index out of range is encountered.
https://github.com/nebari-dev/nebari/actions/runs/11601903835/job/32305692369?pr=2795

def kubernetes_versions() -> typing.List[str]:
"""Return list of available kubernetes supported by cloud provider. Sorted from oldest to latest."""
supported_kubernetes_versions = sorted(
[_["slug"].split("-")[0] for _ in _kubernetes_options()["options"]["versions"]]
)
filtered_versions = filter_by_highest_supported_k8s_version(
supported_kubernetes_versions
)
return [f"{v}-do.0" for v in filtered_versions]

This occurs because the HIGHEST_SUPPORTED_K8S_VERSION

HIGHEST_SUPPORTED_K8S_VERSION = ("1", "29", "2")

Which is lower than the Kubernetes versions currently supported by DigitalOcean (['1.29.9', '1.30.5', '1.31.1']).
As a result, the version filtering logic fails, leading to an empty list and subsequent error.

Expected behavior

Init shoudl work as expected, and also, the error message should be more descriptive

OS and architecture in which you are running Nebari

Linux (CI)

How to Reproduce the problem?

  • Run a nebari init for the DO deployment, or check how the DO tests are performing

Here's a code snippet you can use to reproduce the error:

import os
import requests
import typing
import re

from _nebari.constants import HIGHEST_SUPPORTED_K8S_VERSION


DIGITALOCEAN_TOKEN = (
    "dop_v1_**********"
)


def digital_ocean_request(url, method="GET", json=None):
    BASE_DIGITALOCEAN_URL = "https://api.digitalocean.com/v2/"

    headers = {"Authorization": f"Bearer {DIGITALOCEAN_TOKEN}"}

    method_map = {
        "GET": requests.get,
        "DELETE": requests.delete,
    }

    response = method_map[method](
        f"{BASE_DIGITALOCEAN_URL}{url}", headers=headers, json=json
    )
    response.raise_for_status()

    return response


def _kubernetes_options():
    return digital_ocean_request("kubernetes/options").json()


def filter_by_highest_supported_k8s_version(k8s_versions_list):
    filtered_k8s_versions_list = []
    for k8s_version in k8s_versions_list:
        version = tuple(
            filter(None, re.search(r"(\d+)\.(\d+)(?:\.(\d+))?", k8s_version).groups())
        )
        print(f"version: {version}")
        if version <= HIGHEST_SUPPORTED_K8S_VERSION:
            print(
                f"version: {version} is less than or equal to HIGHEST_SUPPORTED_K8S_VERSION: {HIGHEST_SUPPORTED_K8S_VERSION}"
            )
            filtered_k8s_versions_list.append(k8s_version)
    return filtered_k8s_versions_list


def kubernetes_versions() -> typing.List[str]:
    """Return list of available kubernetes supported by cloud provider. Sorted from oldest to latest."""
    supported_kubernetes_versions = sorted(
        [_["slug"].split("-")[0] for _ in _kubernetes_options()["options"]["versions"]]
    )
    print(f"supported_kubernetes_versions: {supported_kubernetes_versions}")
    filtered_versions = filter_by_highest_supported_k8s_version(
        supported_kubernetes_versions
    )
    print(f"filtered_versions: {filtered_versions}")
    return [f"{v}-do.0" for v in filtered_versions]


if __name__ == "__main__":
    versions = kubernetes_versions()
    print(f"versions: {versions}")
    sorted(versions)[-1]

Command output

No response

Versions and dependencies used.

No response

Compute environment

Digital Ocean

Integrations

No response

Anything else?

No response

@viniciusdc viniciusdc added type: bug 🐛 Something isn't working needs: triage 🚦 Someone needs to have a look at this issue and triage labels Oct 31, 2024
@viniciusdc
Copy link
Contributor Author

I am not entirely sure if this should be worked on, though, since we will be decommissioning DO soon. Addressing this requires a global update in the supported Kubertnes version across all providers. If we are happy with bumping it for all, then it becomes pretty straightforward to fix.

@Adam-D-Lewis Adam-D-Lewis removed the needs: triage 🚦 Someone needs to have a look at this issue and triage label Nov 5, 2024
@Adam-D-Lewis
Copy link
Member

We decided not to work on this given that Digital Ocean support is deprecated and will be removed in the release after 2024.11.1.

@viniciusdc
Copy link
Contributor Author

closing as per above, tracking discussion for DO deprecation and removal can be found here ehttps://github.com//issues/2749

@github-project-automation github-project-automation bot moved this from New 🚦 to Done 💪🏾 in 🪴 Nebari Project Management Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Something isn't working
Projects
Status: Done 💪🏾
Development

No branches or pull requests

2 participants