-
Notifications
You must be signed in to change notification settings - Fork 218
Leader Election #1358
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
Leader Election #1358
Conversation
f6aa23f
to
e3cd675
Compare
Note that the e2e test has to be this was because of the |
1d83237
to
f1b0297
Compare
f1b0297
to
de9d553
Compare
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.
Made some changes, also have some comments but looks good otherwise.
|
||
public LeaderElectionConfigurationBuilder() {} | ||
|
||
public static LeaderElectionConfigurationBuilder aLeaderElectionConfiguration() { |
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 don't really see the point of this builder as it is just creating the object using the publicly available constructors…
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.
deleted. Added an additional constructor.
@@ -30,26 +30,26 @@ | |||
/** | |||
* Handles calls and results of a Reconciler and finalizer related logic | |||
*/ | |||
class ReconciliationDispatcher<R extends HasMetadata> { | |||
class ReconciliationDispatcher<P extends HasMetadata> { |
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 would be better to do these kind of changes in different PRs as this makes things more difficult to review
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.
yes, will try to do in the future.
this.identity = identity(config); | ||
Lock lock = new LeaseLock(config.getLeaseNamespace(), config.getLeaseName(), identity); | ||
// releaseOnCancel is not used in the underlying implementation | ||
leaderElector = new LeaderElectorBuilder(client, |
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.
This API is quite awkward, imo… maybe we should improve it in the Fabric8 client project?
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, yes, this could be better there.
ExecutorServiceManager.init(); | ||
controllers.start(); | ||
// first start the controller manager before leader election, |
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.
This is a bit smelly, imo. Would it make sense to put the election-related behavior in the ControllerManager
to simplify the state management?
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 has nothing to do with the controllers, it's more like a logic regarding the whole operator. Not saying that it is ideally describing the domain, but I don't think it should be in the controller. Controllers actually should not know if there is such thing as leader election in the background.
.inNamespace(namespace).withName(TEST_RESOURCE_NAME).get().getStatus(); | ||
|
||
assertThat(actualStatus).isNotNull(); | ||
assertThat(actualStatus.getReconciledBy()).hasSizeGreaterThan(actualListSize + 2); |
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 +2? Why not use a set on the status so that we can check that both instances have reconciled the resource?
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.
Added a named constant
@@ -70,7 +72,18 @@ public Duration getRetryPeriod() { | |||
return retryPeriod; | |||
} | |||
|
|||
public Optional<String> getIdentity() { | |||
return Optional.ofNullable(identity); | |||
public String getIdentity() { |
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.
TBH I don't think this is good, would like to keep the POJOs clear without any logic
79b4b6b
to
951d28d
Compare
This reverts commit 93a260a.
Kudos, SonarCloud Quality Gate passed! |
Fixes #411 Co-authored-by: Chris Laprun <[email protected]>
Very much looking forward to this! Thanks for implementing it. |
Fixes #411 Co-authored-by: Chris Laprun <[email protected]>
Fixes #411 Co-authored-by: Chris Laprun <[email protected]>
No description provided.