Skip to content

Leader election worker thread is not started as a daemon #2619

Description

@archy-rock3t-cloud

What happened (please include outputs or screenshots):

LeaderElection.run sets threading.daemon = True before starting the onstarted_leading worker. That assigns an unused attribute on the threading module; it does not affect the thread. The thread is created without daemon=True, so it inherits the caller's (main thread) non-daemon status and can block interpreter shutdown.

import threading
threading.daemon = True
t = threading.Thread(target=lambda: None)
print(t.daemon)   # False

What you expected to happen:

The worker is a daemon thread, created as Thread(target=..., daemon=True).

How to reproduce it (as minimally and precisely as possible):

Run the snippet above; the created thread reports daemon == False.

Environment:

  • Kubernetes version (kubectl version): n/a (client-side)
  • OS (e.g., MacOS 10.13.6): any
  • Python version (python --version): 3.12
  • Python client version (pip list | grep kubernetes): master

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions