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

Fix Kafka connect config name for deletion #361

Merged
merged 15 commits into from
Sep 19, 2023
27 changes: 9 additions & 18 deletions kpops/components/base_components/kafka_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def helm(self) -> Helm:
return helm

@property
def _connector_resetter_release_name(self) -> str:
def _resetter_release_name(self) -> str:
"""Get connector resetter's release name"""
suffix = "-clean"
clean_up_release_name = self.full_name + suffix
Expand All @@ -110,7 +110,7 @@ def _connector_resetter_release_name(self) -> str:

@property
def _resetter_helm_chart(self) -> str:
disrupted marked this conversation as resolved.
Show resolved Hide resolved
"""Get reseter Helm chart
"""Get resetter Helm chart

:return: returns the component resetter's helm chart
raminqaf marked this conversation as resolved.
Show resolved Hide resolved
"""
Expand All @@ -121,11 +121,6 @@ def dry_run_handler(self) -> DryRunHandler:
helm_diff = HelmDiff(self.config.helm_diff_config)
return DryRunHandler(self.helm, helm_diff, self.namespace)

@property
def _kafka_connect_resetter_chart(self) -> str:
"""Resetter chart for this component"""
return f"{self.repo_config.repository_name}/kafka-connect-resetter"

@property
def helm_flags(self) -> HelmFlags:
"""Return shared flags for Helm commands"""
Expand Down Expand Up @@ -193,9 +188,7 @@ def _run_connect_resetter(
f"Connector Cleanup: uninstalling cleanup job Helm release from previous runs for {self.full_name}"
)
)
self.__uninstall_connect_resetter(
self._connector_resetter_release_name, dry_run
)
self.__uninstall_connect_resetter(self._resetter_release_name, dry_run)

log.info(
magentaify(
Expand All @@ -207,14 +200,12 @@ def _run_connect_resetter(

if dry_run:
self.dry_run_handler.print_helm_diff(
stdout, self._connector_resetter_release_name, log
stdout, self._resetter_release_name, log
)

if not retain_clean_jobs:
log.info(magentaify("Connector Cleanup: uninstall Kafka Resetter."))
self.__uninstall_connect_resetter(
self._connector_resetter_release_name, dry_run
)
self.__uninstall_connect_resetter(self._resetter_release_name, dry_run)

def __install_connect_resetter(
self,
Expand All @@ -230,9 +221,9 @@ def __install_connect_resetter(
:return: The output of `helm upgrade --install`
"""
return self.helm.upgrade_install(
release_name=self._connector_resetter_release_name,
release_name=self._resetter_release_name,
namespace=self.namespace,
chart=self._kafka_connect_resetter_chart,
chart=self._resetter_helm_chart,
dry_run=dry_run,
flags=HelmUpgradeInstallFlags(
create_namespace=self.config.create_namespace,
Expand Down Expand Up @@ -305,7 +296,7 @@ def template(self) -> None:
offset_topic=self.offset_topic,
)
stdout = self.helm.template(
self._connector_resetter_release_name,
self._resetter_release_name,
self._resetter_helm_chart,
self.namespace,
values,
Expand Down Expand Up @@ -350,7 +341,7 @@ def add_input_topics(self, topics: list[str]) -> None:
def template(self) -> None:
values = self._get_kafka_connect_resetter_values()
stdout = self.helm.template(
self._connector_resetter_release_name,
self._resetter_release_name,
self._resetter_helm_chart,
self.namespace,
values,
Expand Down
4 changes: 1 addition & 3 deletions tests/components/test_kafka_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@

DEFAULTS_PATH = Path(__file__).parent / "resources"
CONNECTOR_NAME = "test-connector-with-long-name-0123456789abcdefghijklmnop"
CONNECTOR_FULL_NAME = (
"${pipeline_name}-test-connector-with-long-name-0123456789abcdefghijklmnop"
)
CONNECTOR_FULL_NAME = "${pipeline_name}-" + CONNECTOR_NAME
CONNECTOR_CLEAN_FULL_NAME = "${pipeline_name}-test-connector-with-long-name-clean"
CONNECTOR_CLASS = "com.bakdata.connect.TestConnector"

Expand Down