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

pkg/endpoint: make state synchronization atomic #32439

Merged
merged 2 commits into from
May 13, 2024

Commits on May 10, 2024

  1. pkg/endpoint: make state synchronization atomic

    BPF regeneration writes state into a new temporary directory. Once it
    has succeeded we need to swap the old and new directory. This is currently
    achieved by "backing up" the current state by renaming the directory.
    This code has a bunch of corner cases around cleaning up old directories
    and so on which are necessary since the synchronization isn't truly
    atomic.
    
    Instead, use the RENAME_EXCHANGE flag to atomically exchange the two
    existing directories. Also use hard links to retain existing state
    so that killing the agent during a synchronization doesn't lead
    to corruption.
    
    Signed-off-by: Lorenz Bauer <[email protected]>
    lmb committed May 10, 2024
    Configuration menu
    Copy the full SHA
    b220ee5 View commit details
    Browse the repository at this point in the history
  2. pkg/endpoint: always copy existing state during synchronization

    Endpoint regeneration goes to a lot of trouble to keep track of
    whether the on-disk state has changed, only to avoid doing a couple
    of readdir syscalls. The behaviour was added in commit  f6c4385
    ("pkg/endpoint: Keep BPF object files if compilation is skipped.")
    and the message does not indicate that performance was of particular
    concern.
    
    Do the safe thing and always perform the state copy.
    
    Signed-off-by: Lorenz Bauer <[email protected]>
    lmb committed May 10, 2024
    Configuration menu
    Copy the full SHA
    f86153e View commit details
    Browse the repository at this point in the history