-
Notifications
You must be signed in to change notification settings - Fork 10
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
Try and associate a pull policy when we know its a floating tag. #423
base: main
Are you sure you want to change the base?
Conversation
...c/test/java/io/kroxylicious/testing/kafka/testcontainers/TestcontainersKafkaClusterTest.java
Outdated
Show resolved
Hide resolved
impl/src/main/java/io/kroxylicious/testing/kafka/testcontainers/TestcontainersKafkaCluster.java
Outdated
Show resolved
Hide resolved
impl/src/main/java/io/kroxylicious/testing/kafka/testcontainers/TestcontainersKafkaCluster.java
Outdated
Show resolved
Hide resolved
@@ -837,4 +847,6 @@ private String buildScramUsersEnvVar() { | |||
.collect(Collectors.joining(";")); | |||
} | |||
|
|||
record PerImagePullPolicy(DockerImageName dockerImageName, ImagePullPolicy pullPolicy) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PerImagePullPolicy is not a good name. ImageWithPullPolicy
might be better.
impl/src/main/java/io/kroxylicious/testing/kafka/testcontainers/TestcontainersKafkaCluster.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm seeing test failures locally because kafka-native:latest
has moved to Kafka 3.9.0 😢
Not sure how to handle that.
2024-11-21 12:19:49 ERROR tc.quay.io/ogunalp/kafka-native:latest:549 - Log output from the failed container:
__ ____ __ _____ ___ __ ____ ______
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2024-11-20 23:19:06,290 ERROR [io.qua.run.Application] (main) Failed to start application: java.lang.RuntimeException: Failed to start quarkus
at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
at io.quarkus.runtime.Application.start(Application.java:101)
at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:121)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:71)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:124)
at io.quarkus.runner.GeneratedMain.main(Unknown Source)
Caused by: java.lang.IllegalArgumentException: requirement failed: advertised.listeners cannot use the nonroutable meta-address 0.0.0.0. Use a routable IP address.
at scala.Predef$.require(Predef.scala:337)
at kafka.server.KafkaConfig.validateValues(KafkaConfig.scala:1022)
at kafka.server.KafkaConfig.<init>(KafkaConfig.scala:852)
at kafka.server.KafkaConfig.<init>(KafkaConfig.scala:185)
at kafka.server.KafkaConfig.fromProps(KafkaConfig.scala:101)
at com.ozangunalp.kafka.server.EmbeddedKafkaBroker.start(EmbeddedKafkaBroker.java:216)
at com.ozangunalp.kafka.server.Startup.startup(Startup.java:38)
at com.ozangunalp.kafka.server.Startup_Observer_startup_lDxI_XYb49w9c3LH146P8PmORkk.notify(Unknown Source)
at io.quarkus.arc.impl.EventImpl$Notifier.notifyObservers(EventImpl.java:351)
at io.quarkus.arc.impl.EventImpl$Notifier.notify(EventImpl.java:333)
at io.quarkus.arc.impl.EventImpl.fire(EventImpl.java:80)
at io.quarkus.arc.runtime.ArcRecorder.fireLifecycleEvent(ArcRecorder.java:163)
at io.quarkus.arc.runtime.ArcRecorder.handleLifecycleEvents(ArcRecorder.java:114)
at io.quarkus.deployment.steps.LifecycleEventsBuildStep$startupEvent1144526294.deploy_0(Unknown Source)
at io.quarkus.deployment.steps.LifecycleEventsBuildStep$startupEvent1144526294.deploy(Unknown Source)
... 7 more
.isNotNull().satisfies(perImagePullPolicy -> { | ||
assertThat(perImagePullPolicy.dockerImageName().getVersionPart()).isEqualTo("latest-kafka-" + version.value()); | ||
final ImagePullPolicy actualPullPolicy = perImagePullPolicy.pullPolicy(); | ||
assertThat(actualPullPolicy).isInstanceOf(ImagePullPolicy.class); // We can't see `AlwaysPullPolicy` as it's not public |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm not convinced this should actually be this policy. Its not strictly part of this test either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It serves to document that you wish to assert that an always pull policy is in place, but you cannot because of the protection policy. I'd have made the test assert the policy's class name (ugly/fragile though that is).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you see my suggestion to implement our own ImagePullPolicy. We'd implement the class to give always behaviour for tags that start latest and default otherwise. It would be cinch to unit test too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had but I hadn't realised the implications that is probably a good move.
I think this PR then just becomes about sorting the image selection so it all happens in one testable place.
@@ -378,6 +382,10 @@ | |||
<systemPropertyVariables> | |||
<container.logs.dir>${project.build.directory}/container-logs/</container.logs.dir> | |||
</systemPropertyVariables> | |||
<argLine> | |||
--add-opens java.base/java.util=ALL-UNNAMED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Required so we can use junit-pioneer to mess with env vars.
@@ -115,8 +129,8 @@ public class TestcontainersKafkaCluster implements Startable, KafkaCluster, Kafk | |||
// This uid needs to match the uid used by the kafka container to execute the kafka process | |||
private static final String KAFKA_CONTAINER_UID = "1001"; | |||
private static final int READY_TIMEOUT_SECONDS = 120; | |||
private final DockerImageName kafkaImage; | |||
private final DockerImageName zookeeperImage; | |||
public static final String MAJOR_MINOR_PATCH = "\\d+(\\.\\d+(\\.\\d+)?)?"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Precompile the RE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doh good point.
pom.xml
Outdated
<dependency> | ||
<groupId>org.junit-pioneer</groupId> | ||
<artifactId>junit-pioneer</artifactId> | ||
<version>2.3.0</version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extract a variable for this.
I verified that with your refactoring on this PR, |
|
||
private static Stream<Version> fixedVersions() { | ||
return Stream.of( | ||
version("3.6.0"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to stop at 3.6.0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the same set as the TemplateTest which tries to actually fire things up (this test was written as that was failing and hard to debug).
I'm not sure the set of versions actually matters but while we are talking about it I'll add the missing versions.
Signed-off-by: Sam Barker <[email protected]> rh-pre-commit.version: 2.0.1 rh-pre-commit.check-secrets: ENABLED
Signed-off-by: Sam Barker <[email protected]> rh-pre-commit.version: 2.0.1 rh-pre-commit.check-secrets: ENABLED
Signed-off-by: Sam Barker <[email protected]> rh-pre-commit.version: 2.0.1 rh-pre-commit.check-secrets: ENABLED
Signed-off-by: Sam Barker <[email protected]> rh-pre-commit.version: 2.0.1 rh-pre-commit.check-secrets: ENABLED
Signed-off-by: Sam Barker <[email protected]> rh-pre-commit.version: 2.0.1 rh-pre-commit.check-secrets: ENABLED
Did you rebase already? If you haven't container base tests will fail against the new images because the Kafka configuration will be wrong. |
Enforce we always pull Release and Snapshot tags. It then works of the assumption that older versioned tags are stable so the cached copy is likely to be good. It will fall back to the default policy if the versioned image is less than 7 days old. Signed-off-by: Sam Barker <[email protected]> rh-pre-commit.version: 2.0.1 rh-pre-commit.check-secrets: ENABLED
Signed-off-by: Sam Barker <[email protected]> rh-pre-commit.version: 2.0.1 rh-pre-commit.check-secrets: ENABLED
Quality Gate failedFailed conditions |
It doesn't like the regex. I need to have another go at simplifying it or its usage.
Errr I wrote tests. What's happening to coverage??? A question for Monday |
|
||
import io.kroxylicious.testing.kafka.common.Version; | ||
|
||
public class FloatingTagPullPolicy extends AbstractImagePullPolicy implements ImagePullPolicy { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not make this a KroxyliciousPullPolicy that knows about the special rules for latest etc and otherwise just falls back to PullPolicy.defaultPolicy() for all other tags. That way TestcontainerKafkaCluster can just use the policy unconditionally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I follow. I think this could be applied unconditionally, it's not currently however.
Extending the abstract means we are only invoked if there is already an image in the cache.
Type of change
Description
Fixes #421
Additional Context
We should default to pull always when we know we are specifying a floating tag.
Checklist
Please go through this checklist and make sure all applicable tasks have been done