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

windows: Fixes following container log rotation #124444

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on May 1, 2024

  1. windows: Fixes following container log rotation

    If we're following a file, that file will remain open, and we continue
    to read data from it when new data becomes available.
    
    On Windows, this can be an issue if the container logs needs to be rotated.
    Log rotation is done by renaming the file, but this action may fail if
    the file is already opened.
    
    Setting the FILE_SHARE_DELETE flag when opening the file will prevent this
    issue, as documented: "Delete access allows both delete and rename operations" [1].
    
    In golang, there's no way to set this flag [2], the sharemode is always set to:
    sharemode := uint32(FILE_SHARE_READ | FILE_SHARE_WRITE)
    
    Thus, we need to open the file ourselves with the right flags.
    
    [1] https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea?redirectedfrom=MSDN
    [2] https://cs.opensource.google/go/go/+/refs/tags/go1.22.2:src/syscall/syscall_windows.go;l=366
    claudiubelu committed May 1, 2024
    Configuration menu
    Copy the full SHA
    96f62df View commit details
    Browse the repository at this point in the history