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 race condition in leader election for OCP #455

Merged
merged 1 commit into from
Jun 14, 2023

Conversation

SchSeba
Copy link
Collaborator

@SchSeba SchSeba commented Jun 11, 2023

In OCP we have two steps to prepare a node before we drain it. first we get leader election and annotate the node with Draining and then we pause the MCP and mark the node as MCP paused.

if the config_daemon get a reset between the fist part to the second it will get stuck because one node will take the leader election BUT it will not mark the node as Draining as there is another node already draining. and the node with the draining label will try to get the drain lock again but the first node has it.

with this change if the node as Draning or MCP pause label it will not try to take the lock again and just continue after the reset.

@SchSeba SchSeba requested review from e0ne and zeeke June 11, 2023 13:25
@github-actions
Copy link

Thanks for your PR,
To run vendors CIs use one of:

  • /test-all: To run all tests for all vendors.
  • /test-e2e-all: To run all E2E tests for all vendors.
  • /test-e2e-nvidia-all: To run all E2E tests for NVIDIA vendor.

To skip the vendors CIs use one of:

  • /skip-all: To skip all tests for all vendors.
  • /skip-e2e-all: To skip all E2E tests for all vendors.
  • /skip-e2e-nvidia-all: To skip all E2E tests for NVIDIA vendor.
    Best regards.

@github-actions
Copy link

Thanks for your PR,
To run vendors CIs use one of:

  • /test-all: To run all tests for all vendors.
  • /test-e2e-all: To run all E2E tests for all vendors.
  • /test-e2e-nvidia-all: To run all E2E tests for NVIDIA vendor.

To skip the vendors CIs use one of:

  • /skip-all: To skip all tests for all vendors.
  • /skip-e2e-all: To skip all E2E tests for all vendors.
  • /skip-e2e-nvidia-all: To skip all E2E tests for NVIDIA vendor.
    Best regards.

@coveralls
Copy link

coveralls commented Jun 11, 2023

Pull Request Test Coverage Report for Build 5257619445

  • 0 of 11 (0.0%) changed or added relevant lines in 1 file are covered.
  • 16 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-0.2%) to 25.767%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/daemon/daemon.go 0 11 0.0%
Files with Coverage Reduction New Missed Lines %
api/v1/helper.go 3 41.92%
pkg/utils/openshift_context.go 3 10.34%
pkg/daemon/daemon.go 4 42.68%
controllers/sriovibnetwork_controller.go 6 62.26%
Totals Coverage Status
Change from base Build 5143456346: -0.2%
Covered Lines: 1957
Relevant Lines: 7595

💛 - Coveralls

pkg/daemon/daemon.go Outdated Show resolved Hide resolved
@adrianchiris
Copy link
Collaborator

adrianchiris commented Jun 12, 2023

if the config_daemon get a reset between the fist part to the second it will get stuck because one node will take the leader election BUT it will not mark the node as Draining as there is another node already draining. and the node with the draining label will try to get the drain lock again but the first node has it.

marking the node as draining (via node annotation) is done during leader election.
what may happen is that another node got leader elected and has outdated caches then it would also mark its own node as draining.

in this case, i think in getDrainLock we should allow to continue if node already has draining annotation. and not rely on drainable attr.

in such "edge" cases we may get more than one node draining but its better than deadlock.

driving this whole process from controller should solve all of these cases
#427 is a good start

pkg/daemon/daemon.go Outdated Show resolved Hide resolved
In OCP we have two steps to prepare a node before we drain it.
first we get leader election and annotate the node with Draining
and then we pause the MCP and mark the node as MCP paused.

if the config_daemon get a reset between the fist part to the second
it will get stuck because one node will take the leader election
BUT it will not mark the node as Draining as there is another node
already draining. and the node with the draining label will try to get
the drain lock again but the first node has it.

with this change if the node as Draning or MCP pause label it will not
try to take the lock again and just continue after the reset.

Signed-off-by: Sebastian Sch <[email protected]>
@github-actions
Copy link

Thanks for your PR,
To run vendors CIs use one of:

  • /test-all: To run all tests for all vendors.
  • /test-e2e-all: To run all E2E tests for all vendors.
  • /test-e2e-nvidia-all: To run all E2E tests for NVIDIA vendor.

To skip the vendors CIs use one of:

  • /skip-all: To skip all tests for all vendors.
  • /skip-e2e-all: To skip all E2E tests for all vendors.
  • /skip-e2e-nvidia-all: To skip all E2E tests for NVIDIA vendor.
    Best regards.

@SchSeba
Copy link
Collaborator Author

SchSeba commented Jun 13, 2023

Hi @adrianchiris please take another look when you have time :)

Copy link
Collaborator

@adrianchiris adrianchiris left a comment

Choose a reason for hiding this comment

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

LGTM

@adrianchiris adrianchiris merged commit e84d536 into k8snetworkplumbingwg:master Jun 14, 2023
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.

3 participants