Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
5 changes: 5 additions & 0 deletions sample-operators/mysql-schema/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@
<artifactId>operator-framework-junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ private Connection getConnection() throws SQLException {

@Override
public void delete(MySQLSchema primary, Context<MySQLSchema> context) {
log.debug("Deleting schema");
Comment thread
csviri marked this conversation as resolved.
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new debug log line is quite generic and may not help diagnose which resource is being deleted during flaky runs. Consider including identifying details (e.g., schema name/namespace and possibly username/secret when available) so the log can be correlated to a specific reconciliation/deletion event.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that those are already included from MDC

try (Connection connection = getConnection()) {
var userName = primary.getStatus() != null ? primary.getStatus().getUserName() : null;
SchemaService.deleteSchemaAndRelatedUser(
Expand Down
7 changes: 5 additions & 2 deletions sample-operators/mysql-schema/src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@
limitations under the License.

-->
<Configuration status="WARN">
<Configuration name="TestConfig" status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d %threadId %-30c{1.} [%-5level] %msg p:[%X{resource.name}:%X{resource.namespace}:%X{resource.resourceVersion}] e:[%X{eventsource.name}:%X{eventsource.event.action}:%X{eventsource.event.resource.name}:%X{eventsource.event.resource.namespace}:%X{eventsource.event.resource.resourceVersion}] %n%throwable"/>
</Console>
</Appenders>
<Loggers>
<Root level="debug">
<Logger level="debug" name="io.javaoperatorsdk.operator" additivity="false">
<AppenderRef ref="Console"/>
</Logger>
<Root level="info">
<AppenderRef ref="Console"/>
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sample-operators/mysql-schema/src/main/resources/log4j2.xml is a runtime (main) resource, but the configuration is now named TestConfig and changes the global logging behavior (root debug -> info). This diverges from the other sample operators’ main Log4j2 configs (e.g. sample-operators/leader-election/src/main/resources/log4j2.xml:19-27 uses an unnamed <Configuration> with root debug) and may make debugging the sample harder. If this change is intended only for stabilizing tests, consider moving it to src/test/resources/log4j2.xml (so it only affects tests), or keep main logging consistent and add targeted logger overrides instead.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@csviri this might be valid

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh, yes forgot to push the change for this, thank you, now should look better, actually might update the leader election sample, since root logger should not be on debug.

</Root>
</Loggers>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,8 @@
import io.javaoperatorsdk.operator.sample.dependent.SchemaDependentResource;

import static java.util.concurrent.TimeUnit.MINUTES;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;

class MySQLSchemaOperatorE2E {

Expand Down Expand Up @@ -114,10 +110,10 @@ void test() {
.inNamespace(operator.getNamespace())
.withName(testSchema.getMetadata().getName())
.get();
assertThat(updatedSchema.getStatus(), is(notNullValue()));
assertThat(updatedSchema.getStatus().getStatus(), equalTo("CREATED"));
assertThat(updatedSchema.getStatus().getSecretName(), is(notNullValue()));
assertThat(updatedSchema.getStatus().getUserName(), is(notNullValue()));
assertThat(updatedSchema.getStatus()).isNotNull();
assertThat(updatedSchema.getStatus().getStatus()).isEqualTo("CREATED");
assertThat(updatedSchema.getStatus().getSecretName()).isNotNull();
assertThat(updatedSchema.getStatus().getUserName()).isNotNull();
});

client
Expand All @@ -137,7 +133,7 @@ void test() {
.inNamespace(operator.getNamespace())
.withName(testSchema.getMetadata().getName())
.get();
assertThat(updatedSchema, is(nullValue()));
assertThat(updatedSchema).isNull();
});
}
}