fabric8io / kubernetes-client

Java client for Kubernetes & OpenShift

Home Page:http://fabric8.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

minor simplification in the code of leader election

wind57 opened this issue · comments

Is your task related to a problem? Please describe

It's not a problem, no

Describe the solution you'd like

slightly simper when reading the code

Describe alternatives you've considered

none, really.

Additional context

LeaderElector::canBecomeLeader has such a condition in place:

!leaderElectionRecord.getRenewTime().plus(leaderElectionConfig.getLeaseDuration()).isAfter(now())

it is somehow complicated to read, especially if you try to "map" these two periods in your head on a scale. Would you consider (IMHO) simpler:

now().isAfter(leaderElectionRecord.getRenewTime().plus(leaderElectionConfig.getLeaseDuration()))

It is the same condition, but inverted. The fact that there is no negation !, makes it far easier to read; but it might be only to me.

Thank you for looking at this

Thanks for your feedback.
This sounds OK, do you want to create a PR to fix it?