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

Refactor/Clean leader election related classes #5937

Merged
merged 5 commits into from Apr 29, 2024

Conversation

wind57
Copy link
Contributor

@wind57 wind57 commented Apr 23, 2024

No description provided.

@wind57
Copy link
Contributor Author

wind57 commented Apr 23, 2024

I am trying to see if we can use the already existing leader logic/classes from fabric8 in spring-cloud-kubernetes. There is already an implementation there, but may be we can refactor and use what you folks already have in place. '

As such, I am trying to poke a little into the code base to understand how things are done, thus this PR with minor clean-ups. Thank you for looking into it

@wind57
Copy link
Contributor Author

wind57 commented Apr 23, 2024

I will mark this one as ready after the build passes, but in order to do that, someone has to approve that, so that the build starts

private Runnable onStartLeading;
private Runnable onStopLeading;
private Consumer<String> onNewLeader;
private final Runnable onStartLeading;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

just add final, nothing more changes in this class

@@ -46,10 +45,9 @@ public class LeaderElector {

protected static final Double JITTER_FACTOR = 1.2;

private KubernetesClient kubernetesClient;
private LeaderElectionConfig leaderElectionConfig;
private final KubernetesClient kubernetesClient;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

add final

private final AtomicReference<LeaderElectionRecord> observedRecord = new AtomicReference<>();
private final AtomicReference<LocalDateTime> observedTime = new AtomicReference<>();
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 dropped the observedTime variable, it was updated, but never used

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure why this was added on the first place. I need to do some digging before we can merge this.

Copy link
Contributor

Choose a reason for hiding this comment

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

The go client switch how time was tracked so that it was local to each elector, but we never fully implemented that.

Copy link
Member

Choose a reason for hiding this comment

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

I traced it back to the initial implementation but it was never used. I guess I left that there for a follow up.

@wind57
Copy link
Contributor Author

wind57 commented Apr 23, 2024

@manusa can I ask please to re-start the pipeline?

@wind57
Copy link
Contributor Author

wind57 commented Apr 23, 2024

hmm, there is a failing test, but its not related to these changes. I took a look at it, and it of course passes locally (DefaultMockServerWebSocketTest). I pushed a placeholder commit to try and re-trigger

Copy link

sonarcloud bot commented Apr 23, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@wind57 wind57 marked this pull request as ready for review April 23, 2024 11:56
@wind57
Copy link
Contributor Author

wind57 commented Apr 25, 2024

@manusa asking for your input please here, I can keep this one up to date with master branch, but what is the overall process with PRs? thank you

@rohanKanojia
Copy link
Member

@wind57 : Usually we require 2 approvals for a pull request to get merged. Most people working on these projects are also working on other projects, so it might take a week or two for pull request to get merged.

@manusa manusa changed the title clean-up Refactor/Clean leader election related classes Apr 29, 2024
Copy link
Member

@manusa manusa left a comment

Choose a reason for hiding this comment

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

LGTM, thx!

@manusa manusa added this to the 6.13.0 milestone Apr 29, 2024 — with automated-tasks
@manusa manusa merged commit e873bf6 into fabric8io:main Apr 29, 2024
20 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
Development

Successfully merging this pull request may close these issues.

None yet

4 participants