Skip to content
  • Iustin Pop's avatar
    Fix PID file writing in Haskell daemons · a4c0fe1e
    Iustin Pop authored
    
    
    Currently, the code uses createFile, which has the effect of always
    truncating the file. This is bad, as the content of the PID file is
    wiped even when we wouldn't be able to lock it!
    
    We switch to openFd (createFile is just a wrapper over that), and we
    use an explicit set of flags; defaultFileFlags is already safe
    (trunc=False), but I prefer to set it explicitly with our desired
    flags.
    
    Note that this bug doesn't manifest in normal usage, as daemon-util
    won't try to start the daemon if already running. But if anyone or
    anything does call ganeti-confd explicitly, the pid file will be
    emptied and the daemon will keep trying to be restarted forever…
    
    Signed-off-by: default avatarIustin Pop <iustin@google.com>
    Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
    a4c0fe1e