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

Add image tag field to streams-bootstrap app values #499

Merged
merged 28 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
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
33 changes: 32 additions & 1 deletion docs/docs/schema/defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@
"additionalProperties": true,
"description": "Helm app values.",
"properties": {
"imageTag": {
"default": "latest",
"description": "",
"title": "Imagetag",
"type": "string"
},
"nameOverride": {
"anyOf": [
{
Expand Down Expand Up @@ -278,6 +284,12 @@
"additionalProperties": true,
"description": "Settings specific to Kafka Apps.",
"properties": {
"imageTag": {
"default": "latest",
"description": "",
"title": "Imagetag",
"type": "string"
},
"nameOverride": {
"anyOf": [
{
Expand Down Expand Up @@ -725,7 +737,14 @@
"KubernetesAppValues": {
"additionalProperties": true,
"description": "Settings specific to Kubernetes apps.",
"properties": {},
"properties": {
"imageTag": {
"default": "latest",
"description": "",
"title": "Imagetag",
"type": "string"
}
},
"title": "KubernetesAppValues",
"type": "object"
},
Expand Down Expand Up @@ -920,6 +939,12 @@
"additionalProperties": true,
"description": "Settings specific to producers.",
"properties": {
"imageTag": {
"default": "latest",
"description": "",
"title": "Imagetag",
"type": "string"
},
"nameOverride": {
"anyOf": [
{
Expand Down Expand Up @@ -1273,6 +1298,12 @@
"default": null,
"description": "Kubernetes event-driven autoscaling config"
},
"imageTag": {
"default": "latest",
"description": "",
"title": "Imagetag",
"type": "string"
},
"nameOverride": {
"anyOf": [
{
Expand Down
18 changes: 18 additions & 0 deletions docs/docs/schema/pipeline.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@
"additionalProperties": true,
"description": "Helm app values.",
"properties": {
"imageTag": {
"default": "latest",
"description": "",
"title": "Imagetag",
"type": "string"
},
"nameOverride": {
"anyOf": [
{
Expand Down Expand Up @@ -588,6 +594,12 @@
"additionalProperties": true,
"description": "Settings specific to producers.",
"properties": {
"imageTag": {
"default": "latest",
"description": "",
"title": "Imagetag",
"type": "string"
},
"nameOverride": {
"anyOf": [
{
Expand Down Expand Up @@ -941,6 +953,12 @@
"default": null,
"description": "Kubernetes event-driven autoscaling config"
},
"imageTag": {
"default": "latest",
"description": "",
"title": "Imagetag",
"type": "string"
},
"nameOverride": {
"anyOf": [
{
Expand Down
10 changes: 9 additions & 1 deletion kpops/components/base_components/kafka_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
from abc import ABC
from collections.abc import Callable
from typing import Any
from typing import Any, Self

import pydantic
from pydantic import AliasChoices, ConfigDict, Field
Expand Down Expand Up @@ -131,6 +131,14 @@ class KafkaApp(PipelineComponent, ABC):
description=describe_attr("app", __doc__),
)

@pydantic.model_validator(mode="after")
def warning_for_latest_image_tag(self) -> Self:
if self.app.image_tag == "latest" and "$" not in self.name:
raminqaf marked this conversation as resolved.
Show resolved Hide resolved
log.warning(
f"The imageTag for component '{self.name}' is not set and defaults to 'latest'. Please, consider providing a stable imageTag."
)
return self

@override
async def deploy(self, dry_run: bool) -> None:
if self.to:
Expand Down
9 changes: 9 additions & 0 deletions kpops/components/base_components/kafka_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from kpops.utils.docstring import describe_attr

try:
from typing import Self # pyright: ignore[reportAttributeAccessIssue]

Check failure on line 30 in kpops/components/base_components/kafka_connector.py

View workflow job for this annotation

GitHub Actions / Test (ubuntu-22.04, 3.10)

Type of "Self" is unknown (reportUnknownVariableType)
except ImportError:
from typing_extensions import Self

Expand Down Expand Up @@ -134,6 +134,15 @@
app["name"] = component_name
return KafkaConnectorConfig(**app)

@pydantic.model_validator(mode="after")
def warning_for_latest_image_tag(self) -> Self:

Check failure on line 138 in kpops/components/base_components/kafka_connector.py

View workflow job for this annotation

GitHub Actions / Test (ubuntu-22.04, 3.10)

Return type is unknown (reportUnknownParameterType)
if self.resetter_values.image_tag == "latest":
log.warning(
f"The imageTag for the Kafka Connect resetter in component '{self.name}' is not set and defaults to 'latest'. "
f"Please, consider providing a stable imageTag."
)
return self

@cached_property
def _resetter(self) -> KafkaConnectorResetter:
kwargs: dict[str, Any] = {}
Expand All @@ -160,7 +169,7 @@
connector=self.full_name,
brokers=self.config.kafka_brokers,
),
**self.resetter_values.model_dump(),

Check failure on line 172 in kpops/components/base_components/kafka_connector.py

View workflow job for this annotation

GitHub Actions / Test (ubuntu-22.04, 3.10)

Type of "model_dump" is partially unknown
),
)

Expand Down Expand Up @@ -212,7 +221,7 @@
_connector_type: KafkaConnectorType = PrivateAttr(KafkaConnectorType.SOURCE)

@pydantic.model_validator(mode="after")
def populate_offset_topic(self) -> Self:

Check failure on line 224 in kpops/components/base_components/kafka_connector.py

View workflow job for this annotation

GitHub Actions / Test (ubuntu-22.04, 3.10)

Return type is unknown (reportUnknownParameterType)
if self.offset_topic:
self._resetter.app.config.offset_topic = self.offset_topic
return self
Expand Down
9 changes: 8 additions & 1 deletion kpops/components/base_components/kubernetes_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@


class KubernetesAppValues(CamelCaseConfigModel, DescConfigModel):
"""Settings specific to Kubernetes apps."""
"""Settings specific to Kubernetes apps.

:param image_tag: The image tag of the Kubernetes app.
"""

image_tag: str = Field(
raminqaf marked this conversation as resolved.
Show resolved Hide resolved
default="latest", description=describe_attr("imageTag", __doc__)
)

model_config = ConfigDict(
extra="allow",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
helm-app:
name: ${component.type}
namespace: example-namespace
app:
imageTag: latest
8 changes: 0 additions & 8 deletions tests/components/test_kafka_sink_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,6 @@ def test_connector_config_parsing(
handlers: ComponentHandlers,
connector_config: KafkaConnectorConfig,
):
connector = KafkaSinkConnector(
name=CONNECTOR_NAME,
config=config,
handlers=handlers,
app=connector_config,
resetter_namespace=RESETTER_NAMESPACE,
)

topic_pattern = ".*"
connector = KafkaSinkConnector(
name=CONNECTOR_NAME,
Expand Down
1 change: 1 addition & 0 deletions tests/components/test_streams_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def test_default_configs(self, config: KpopsConfig, handlers: ComponentHandlers)
)
assert streams_bootstrap.version == "2.9.0"
assert streams_bootstrap.namespace == "test-namespace"
assert streams_bootstrap.app.image_tag == "latest"

@pytest.mark.asyncio()
async def test_should_deploy_streams_bootstrap_app(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@
brokers: http://k8kafka-cp-kafka-headless.kpops.svc.cluster.local:9092
connector: atm-fraud-postgresql-connector
connectorType: sink
imageTag: latest
name: postgresql-connector
namespace: ${NAMESPACE}
prefix: atm-fraud-
Expand Down Expand Up @@ -429,5 +430,6 @@
value.converter.schema.registry.url: http://k8kafka-cp-schema-registry.${NAMESPACE}.svc.cluster.local:8081
name: postgresql-connector
prefix: atm-fraud-
resetter_values: {}
resetter_values:
imageTag: latest
type: kafka-sink-connector
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
brokers: http://k8kafka-cp-kafka-headless.kpops.svc.cluster.local:9092
connector: word-count-redis-sink-connector
connectorType: sink
imageTag: latest
name: redis-sink-connector
namespace: ${NAMESPACE}
prefix: word-count-
Expand All @@ -164,5 +165,6 @@
value.converter: org.apache.kafka.connect.storage.StringConverter
name: redis-sink-connector
prefix: word-count-
resetter_values: {}
resetter_values:
imageTag: latest
type: kafka-sink-connector
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- _cleaner:
app:
imageTag: latest
resources:
limits:
memory: 2G
Expand All @@ -21,6 +22,7 @@
type: producer-app-cleaner
version: 2.9.0
app:
imageTag: latest
resources:
limits:
memory: 2G
Expand Down Expand Up @@ -50,6 +52,7 @@
- _cleaner:
app:
image: some-image
imageTag: latest
labels:
pipeline: resources-custom-config
persistence:
Expand Down Expand Up @@ -77,6 +80,7 @@
version: 2.9.0
app:
image: some-image
imageTag: latest
labels:
pipeline: resources-custom-config
persistence:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
topics: []
commandLine:
CONVERT_XML: true
imageTag: latest
persistence:
enabled: false
resources:
Expand Down Expand Up @@ -105,6 +106,7 @@
topics: []
commandLine:
CONVERT_XML: true
imageTag: latest
persistence:
enabled: false
resources:
Expand Down Expand Up @@ -253,6 +255,7 @@
brokers: http://k8kafka-cp-kafka-headless.kpops.svc.cluster.local:9092
connector: resources-pipeline-with-inflate-should-inflate-inflated-sink-connector
connectorType: sink
imageTag: latest
name: should-inflate-inflated-sink-connector
namespace: example-namespace
prefix: resources-pipeline-with-inflate-
Expand Down Expand Up @@ -280,7 +283,8 @@
transforms.changeTopic.replacement: resources-pipeline-with-inflate-should-inflate-index-v1
name: should-inflate-inflated-sink-connector
prefix: resources-pipeline-with-inflate-
resetter_values: {}
resetter_values:
imageTag: latest
to:
models: {}
topics:
Expand All @@ -293,6 +297,7 @@
type: kafka-sink-connector
- _cleaner:
app:
imageTag: latest
persistence:
enabled: false
statefulSet: false
Expand All @@ -317,6 +322,7 @@
type: streams-app-cleaner
version: 2.4.2
app:
imageTag: latest
persistence:
enabled: false
statefulSet: false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
- _cleaner:
app:
image: fake-image
imageTag: latest
persistence:
enabled: false
statefulSet: false
Expand All @@ -26,6 +27,7 @@
version: 2.4.2
app:
image: fake-image
imageTag: latest
persistence:
enabled: false
statefulSet: false
Expand Down Expand Up @@ -71,6 +73,7 @@
brokers: http://k8kafka-cp-kafka-headless.kpops.svc.cluster.local:9092
connector: resources-kafka-connect-sink-es-sink-connector
connectorType: sink
imageTag: latest
name: es-sink-connector
namespace: example-namespace
prefix: resources-kafka-connect-sink-
Expand All @@ -97,6 +100,7 @@
topics: example-output
name: es-sink-connector
prefix: resources-kafka-connect-sink-
resetter_values: {}
resetter_values:
imageTag: latest
type: kafka-sink-connector

Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
topics: []
commandLine:
CONVERT_XML: true
imageTag: latest
persistence:
enabled: false
resources:
Expand Down Expand Up @@ -105,6 +106,7 @@
topics: []
commandLine:
CONVERT_XML: true
imageTag: latest
persistence:
enabled: false
resources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
topics: []
commandLine:
CONVERT_XML: true
imageTag: latest
persistence:
enabled: false
resources:
Expand Down Expand Up @@ -104,6 +105,7 @@
topics: []
commandLine:
CONVERT_XML: true
imageTag: latest
persistence:
enabled: false
resources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
topics: []
commandLine:
CONVERT_XML: true
imageTag: latest
persistence:
enabled: false
resources:
Expand Down Expand Up @@ -104,6 +105,7 @@
topics: []
commandLine:
CONVERT_XML: true
imageTag: latest
persistence:
enabled: false
resources:
Expand Down
Loading
Loading