[hotfix] Reuse FlinkConfigManager#isSnapshotCrdInstalled in controllers#1122
Open
Dennis-Mircea wants to merge 1 commit into
Open
[hotfix] Reuse FlinkConfigManager#isSnapshotCrdInstalled in controllers#1122Dennis-Mircea wants to merge 1 commit into
Dennis-Mircea wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change
FlinkConfigManageralready discovers whether theFlinkStateSnapshotCRD is installed at operator startup (via the boolean it accepts fromFlinkOperator) and stores the result in a final field. Despite that, bothFlinkDeploymentControllerandFlinkSessionJobControllerwere callingKubernetesClientUtils.isCrdInstalled(FlinkStateSnapshot.class)again from theirprepareEventSourcesmethods. That helper does not just hit the API server, it also constructs a brand-newKubernetesClient(new KubernetesClientBuilder().build()) with its own TLS handshake and auth chain, then issues alist().getItems()call. The result is three independent API roundtrips and three transient clients to answer the same question whose answer is already cached onFlinkConfigManager.This PR exposes that flag through a getter and switches both controllers to use it.
Brief change log
FlinkConfigManager#isSnapshotCrdInstalled()(plain Java getter, no Lombok) returning the existingsnapshotCrdInstalledfield.KubernetesClientUtils.isCrdInstalled(FlinkStateSnapshot.class)withflinkConfigManager.isSnapshotCrdInstalled()inFlinkDeploymentController#prepareEventSourcesandFlinkSessionJobController#prepareEventSources.KubernetesClientUtilsandFlinkStateSnapshotfrom both controllers.FlinkConfigManagerfield + constructor parameter onFlinkSessionJobController(it did not have one before). UpdatedFlinkOperator#registerSessionJobControllerandTestingFlinkSessionJobControllerto pass it in.FlinkDeploymentController, specialized two method signatures from rawContexttoContext<FlinkDeployment>(cleanupandreconcile), resolving raw-type warnings the IDE was flagging in the file we were already editing.Verifying this change
This change is already covered by existing tests, such as
FlinkDeploymentControllerTest,FlinkSessionJobControllerTest,FlinkStateSnapshotControllerTest,FlinkConfigManagerTest, andFlinkOperatorTest.Behavioral equivalence:
prepareEventSourcesis invoked once at JOSDK controller registration. ThesnapshotCrdInstalledflag is computed once atFlinkOperatorconstruction (right beforeFlinkConfigManageris built). Both points happen during operator startup with no possibility of the CRD state changing between them, so the answer used by both controllers is identical to today's behavior. The only difference is that we no longer build two transientKubernetesClientinstances and issue two extralist()calls.Does this pull request potentially affect one of the following parts:
CustomResourceDescriptors: noDocumentation