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

Fix k8sAndWorker mode in a zookeeper-less environment #15445

Merged
merged 9 commits into from Jan 12, 2024

Conversation

YongGang
Copy link
Contributor

@YongGang YongGang commented Nov 28, 2023

Description

Fix k8sAndWorker mode in a zookeeper-less environment

Release note

Fix this issue #15431


Key changed/added classes in this PR
  • KubernetesAndWorkerTaskRunnerFactory change to bind TaskRunnerFactory instance
  • KubernetesOverlordModule change to provide TaskRunnerFactory binding

This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

@asdf2014 asdf2014 marked this pull request as ready for review December 27, 2023 09:23
when(runnerConfig.getWorkerType()).thenReturn(RemoteTaskRunnerFactory.TYPE_NAME);
when(parentProvider.get()).thenReturn(remoteTaskRunnerFactory);
assertSame(remoteTaskRunnerFactory, module.provideRemoteTaskRunnerFactory(parentProvider, runnerConfig));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a test here to see that the KubernetesAndWorkerTaskRunnerFactory is initialized correctly please

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated the code, this Module change is reverted.

Comment on lines 48 to 49
HttpRemoteTaskRunnerFactory httpRemoteTaskRunnerFactory,
RemoteTaskRunnerFactory remoteTaskRunnerFactory,
@Nullable RemoteTaskRunnerFactory remoteTaskRunnerFactory,
Copy link
Contributor

Choose a reason for hiding this comment

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

The pattern I've usually seen here is to inject a Provider<X> into the constructor and then use the config to decide whether or not to call Provider.get() https://github.com/google/guice/wiki/InjectingProviders#injecting-providers.

Would this technique work? It seems slightly easier to follow as RemoteTaskRunnerFactory is already injectable from another module, so I'm not certain what the expected behavior is when 2 modules try to inject the same class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, the provider pattern is simpler. Updated the code.

Copy link
Contributor

@suneet-s suneet-s left a comment

Choose a reason for hiding this comment

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

I think the code changes look good.

To prove this works, a module test would be helpful here to validate that the KubernetesAndWorkerTaskRunnerFactory can be injected without any dependencies for the remoteTaskRunnerFactory being provided.

After the test, +1 from me

@@ -33,7 +34,11 @@ public class KubernetesAndWorkerTaskRunnerFactory implements TaskRunnerFactory<K

private final KubernetesTaskRunnerFactory kubernetesTaskRunnerFactory;
private final HttpRemoteTaskRunnerFactory httpRemoteTaskRunnerFactory;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this also be injected as a Provider since it is not needed when the remote task runner factory is configured?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed HttpRemoteTaskRunnerFactory to be injected as Provider.

@YongGang
Copy link
Contributor Author

YongGang commented Jan 4, 2024

I think the code changes look good.

To prove this works, a module test would be helpful here to validate that the KubernetesAndWorkerTaskRunnerFactory can be injected without any dependencies for the remoteTaskRunnerFactory being provided.

After the test, +1 from me

I find it's very hard to do module test on the Guice injection behavior, especially on the Provider pattern. The bindings appear to behave differently during testing compared to when the actual service starts.

@YongGang
Copy link
Contributor Author

I think the code changes look good.

To prove this works, a module test would be helpful here to validate that the KubernetesAndWorkerTaskRunnerFactory can be injected without any dependencies for the remoteTaskRunnerFactory being provided.

After the test, +1 from me

Added module test to verify the binding works

Copy link
Contributor

@suneet-s suneet-s left a comment

Choose a reason for hiding this comment

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

Very nice! Thanks @YongGang

@suneet-s suneet-s merged commit 0457c71 into apache:master Jan 12, 2024
53 checks passed
@LakshSingla LakshSingla added this to the 29.0.0 milestone Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants