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

MirrorMaker2: Add warning for dangerously invalid configuration #9923

Merged
merged 4 commits into from
Apr 16, 2024

Conversation

maakuth
Copy link
Contributor

@maakuth maakuth commented Apr 5, 2024

Fixes #9905

Type of change

  • Bugfix

Description

In MirrorMaker2 configuration model, add check to ensure all mirrors have target set to the connect cluster. This is the only sane option anyway, but instead of raising an error message, it did start and behaved badly. See #9905.

Checklist

  • Write tests
  • Make sure all tests pass
  • Update documentation
  • Check RBAC rights for Kubernetes / OpenShift roles
  • Try your changes from Pod inside your Kubernetes and OpenShift cluster, not just locally
  • Reference relevant issue(s) and close them after merging
  • Update CHANGELOG.md
  • Supply screenshots for visual changes, such as Grafana dashboards

Fixes strimzi#9905

Signed-off-by: Markus Vuorio <markus.vuorio@upsert.fi>
@maakuth
Copy link
Contributor Author

maakuth commented Apr 5, 2024

This is a trivial change, so I don't think any documentation changes are needed. I am wondering whether the test coverage this way is sufficient, or would it be preferable to add another test case.

I have not run this yet on real clusters, just with test suite.

@scholzj scholzj added this to the 0.41.0 milestone Apr 5, 2024
Copy link
Member

@scholzj scholzj left a comment

Choose a reason for hiding this comment

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

I left one nit. As for the tests:

  • Would it make sense to separate the test for the non-existing alias from the test from the connect cluster not being target cluster?
  • Maybe it would be also worth having a test with multiple Mirror connectors where some of them have the right target cluster and some do not to see that it validates properly in that case as well.

Also, it seems like some other tests are failing now:

[ERROR] Errors: 
[ERROR] io.strimzi.operator.cluster.operator.assembly.KafkaMirrorMaker2AssemblyOperatorPodSetTest.testTopicsGroupsBlacklist(VertxTestContext)
[ERROR]   Run 1: KafkaMirrorMaker2AssemblyOperatorPodSetTest.testTopicsGroupsBlacklist:1115 » InvalidResource KafkaMirrorMaker2 resource validation failed: [Target cluster alias my-cluster-tgt is used in a mirror definition, but it is not the same as the connect cluster alias null]
[ERROR]   Run 2: KafkaMirrorMaker2AssemblyOperatorPodSetTest.testTopicsGroupsBlacklist:1115 » InvalidResource KafkaMirrorMaker2 resource validation failed: [Target cluster alias my-cluster-tgt is used in a mirror definition, but it is not the same as the connect cluster alias null]
[ERROR]   Run 3: KafkaMirrorMaker2AssemblyOperatorPodSetTest.testTopicsGroupsBlacklist:1115 » InvalidResource KafkaMirrorMaker2 resource validation failed: [Target cluster alias my-cluster-tgt is used in a mirror definition, but it is not the same as the connect cluster alias null]
[ERROR]   Run 4: KafkaMirrorMaker2AssemblyOperatorPodSetTest.testTopicsGroupsBlacklist:1115 » InvalidResource KafkaMirrorMaker2 resource validation failed: [Target cluster alias my-cluster-tgt is used in a mirror definition, but it is not the same as the connect cluster alias null]
[ERROR]   Run 5: KafkaMirrorMaker2AssemblyOperatorPodSetTest.testTopicsGroupsBlacklist:1115 » InvalidResource KafkaMirrorMaker2 resource validation failed: [Target cluster alias my-cluster-tgt is used in a mirror definition, but it is not the same as the connect cluster alias null]
[ERROR]   Run 6: KafkaMirrorMaker2AssemblyOperatorPodSetTest.testTopicsGroupsBlacklist:1115 » InvalidResource KafkaMirrorMaker2 resource validation failed: [Target cluster alias my-cluster-tgt is used in a mirror definition, but it is not the same as the connect cluster alias null]
[INFO] 
[ERROR] io.strimzi.operator.cluster.operator.assembly.KafkaMirrorMaker2AssemblyOperatorPodSetTest.testTopicsGroupsExclude(VertxTestContext)
[ERROR]   Run 1: KafkaMirrorMaker2AssemblyOperatorPodSetTest.testTopicsGroupsExclude:1065 » InvalidResource KafkaMirrorMaker2 resource validation failed: [Target cluster alias my-cluster-tgt is used in a mirror definition, but it is not the same as the connect cluster alias null]
[ERROR]   Run 2: KafkaMirrorMaker2AssemblyOperatorPodSetTest.testTopicsGroupsExclude:1065 » InvalidResource KafkaMirrorMaker2 resource validation failed: [Target cluster alias my-cluster-tgt is used in a mirror definition, but it is not the same as the connect cluster alias null]
[ERROR]   Run 3: KafkaMirrorMaker2AssemblyOperatorPodSetTest.testTopicsGroupsExclude:1065 » InvalidResource KafkaMirrorMaker2 resource validation failed: [Target cluster alias my-cluster-tgt is used in a mirror definition, but it is not the same as the connect cluster alias null]
[ERROR]   Run 4: KafkaMirrorMaker2AssemblyOperatorPodSetTest.testTopicsGroupsExclude:1065 » InvalidResource KafkaMirrorMaker2 resource validation failed: [Target cluster alias my-cluster-tgt is used in a mirror definition, but it is not the same as the connect cluster alias null]
[ERROR]   Run 5: KafkaMirrorMaker2AssemblyOperatorPodSetTest.testTopicsGroupsExclude:1065 » InvalidResource KafkaMirrorMaker2 resource validation failed: [Target cluster alias my-cluster-tgt is used in a mirror definition, but it is not the same as the connect cluster alias null]
[ERROR]   Run 6: KafkaMirrorMaker2AssemblyOperatorPodSetTest.testTopicsGroupsExclude:1065 » InvalidResource KafkaMirrorMaker2 resource validation failed: [Target cluster alias my-cluster-tgt is used in a mirror definition, but it is not the same as the connect cluster alias null]

You probably just need to fix the custom resource used by these tests that test something different and are now failing this validation.

@@ -114,6 +114,11 @@ public static KafkaMirrorMaker2Connectors fromCrd(Reconciliation reconciliation,
} else if (!existingClusterAliases.contains(mirror.getTargetCluster())) {
errorMessages.add("Target cluster alias " + mirror.getTargetCluster() + " is used in a mirror definition, but cluster with this alias does not exist in cluster definitions");
}

String connectCluster = kafkaMirrorMaker2.getSpec().getConnectCluster();
Copy link
Member

Choose a reason for hiding this comment

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

If there will be multiple sets of mirrors, you will be extracting this again and again. Would it make sense to get it only once before we start the for loop?

@maakuth
Copy link
Contributor Author

maakuth commented Apr 12, 2024

  • Would it make sense to separate the test for the non-existing alias from the test from the connect cluster not being target cluster?

The non-existing-alias will also keep failing because this added test, but maybe it does make sense to add another test just for this check.

  • Maybe it would be also worth having a test with multiple Mirror connectors where some of them have the right target cluster and some do not to see that it validates properly in that case as well.

This makes sense.

… comments

Fixes strimzi#9905

Signed-off-by: Markus Vuorio <markus.vuorio@upsert.fi>
Signed-off-by: Markus Vuorio <markus.vuorio@upsert.fi>
@maakuth maakuth force-pushed the mm2-add-target-cluster-error branch from 721d7a0 to 7217596 Compare April 12, 2024 11:55
@maakuth maakuth marked this pull request as ready for review April 12, 2024 12:07
Signed-off-by: Markus Vuorio <markus.vuorio@upsert.fi>
Copy link
Member

@scholzj scholzj left a comment

Choose a reason for hiding this comment

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

Thanks. Looks good to me.

Copy link
Member

@ppatierno ppatierno left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the PR!

@scholzj
Copy link
Member

scholzj commented Apr 15, 2024

/azp run regression

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@scholzj scholzj merged commit 8027891 into strimzi:main Apr 16, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants