diff --git a/docs/docs/user/migration-guide/v2-v3.md b/docs/docs/user/migration-guide/v2-v3.md index c7b5bfc99..a51330cf1 100644 --- a/docs/docs/user/migration-guide/v2-v3.md +++ b/docs/docs/user/migration-guide/v2-v3.md @@ -4,12 +4,12 @@ KPOps handles long (more than 53 characters) Helm releases names differently. Helm will not find your (long) old release names anymore. Therefore, it is recommended that you should once destroy your pipeline with KPOps v2 to remove old Helm release names. After a clean destroy, re-deploy your pipeline with the KPOps v3. -For example if you have a component with the Helm release name `example-component-name-too-long-fake-fakefakefakefakefake`. The new release name will shorten the original name to 52 characters and then replace the last 6 characters of the trimmed name with the first 5 characters of the result of SHA-1(helm_release_name). +For example if you have a component with the Helm release name `example-component-name-too-long-fake-fakefakefakefakefake`. The new release name will shorten the original name to 53 characters and then replace the last 6 characters of the trimmed name with the first 5 characters of the result of SHA-1(helm_release_name). ```console -example-component-name-too-long-fake-fakefakef-0a7fc ----> 52 chars +example-component-name-too-long-fake-fakefakef-0a7fc ----> 53 chars ---------------------------------------------- ----- ^Shortened helm_release_name ^first 5 characters of SHA1(helm_release_name) ``` diff --git a/kpops/component_handlers/helm_wrapper/utils.py b/kpops/component_handlers/helm_wrapper/utils.py index 5f5577842..4b892996f 100644 --- a/kpops/component_handlers/helm_wrapper/utils.py +++ b/kpops/component_handlers/helm_wrapper/utils.py @@ -4,16 +4,17 @@ log = logging.getLogger("HelmUtils") ENCODING = "utf-8" -RELEASE_NAME_MAX_LEN = 52 +RELEASE_NAME_MAX_LEN = 53 def create_helm_release_name(name: str, suffix: str = "") -> str: """Shortens the long Helm release name. - Creates a 52 character long release name if the name length exceeds the Helm release character length. - It first trims the string and fetches the first RELEASE_NAME_MAX_LEN - len(suffix) characters. - Then it replaces the last 6 characters with the SHA-1 encoded string (with "-") to avoid collision - and append the suffix if given. + Helm has a limit of 53 characters for release names. + If the name exceeds the character limit: + 1. trim the string and fetch the first RELEASE_NAME_MAX_LEN - len(suffix) characters. + 2. replace the last 6 characters with the SHA-1 encoded string (with "-") to avoid collision + 3. append the suffix if given :param name: The Helm release name to be shortened. :param suffix: The release suffix to preserve diff --git a/tests/component_handlers/helm_wrapper/test_utils.py b/tests/component_handlers/helm_wrapper/test_utils.py index 4a7111d88..a0acc4707 100644 --- a/tests/component_handlers/helm_wrapper/test_utils.py +++ b/tests/component_handlers/helm_wrapper/test_utils.py @@ -8,9 +8,9 @@ def test_helm_release_name_for_long_names(): actual_release_name = create_helm_release_name(long_release_name) - expected_helm_release_name = "example-component-name-too-long-fake-fakefakef-0a7fc" + expected_helm_release_name = "example-component-name-too-long-fake-fakefakefa-0a7fc" assert expected_helm_release_name == actual_release_name - assert len(expected_helm_release_name) == 52 + assert len(expected_helm_release_name) == 53 def test_helm_release_name_for_install_and_clean_must_be_different(): @@ -30,4 +30,4 @@ def test_helm_release_name_for_short_names(): actual_helm_release_name = create_helm_release_name(short_release_name) assert actual_helm_release_name == short_release_name - assert len(actual_helm_release_name) < 53 + assert len(actual_helm_release_name) <= 53 diff --git a/tests/components/test_kafka_connector.py b/tests/components/test_kafka_connector.py index 3e01259a2..16d178f02 100644 --- a/tests/components/test_kafka_connector.py +++ b/tests/components/test_kafka_connector.py @@ -17,7 +17,7 @@ CONNECTOR_NAME = "test-connector-with-long-name-0123456789abcdefghijklmnop" CONNECTOR_FULL_NAME = "${pipeline.name}-" + CONNECTOR_NAME CONNECTOR_CLEAN_FULL_NAME = CONNECTOR_FULL_NAME + "-clean" -CONNECTOR_CLEAN_RELEASE_NAME = "${pipeline.name}-test-connector-with-lon-612f3-clean" +CONNECTOR_CLEAN_RELEASE_NAME = "${pipeline.name}-test-connector-with-long-612f3-clean" CONNECTOR_CLASS = "com.bakdata.connect.TestConnector" RESETTER_NAMESPACE = "test-namespace"