[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Git][ftp-team/dak][master] Adjust n-s-i to flock



Title: GitLab

Joerg Jaspert pushed to branch master at Debian FTP Team / dak

Commits:

1 changed file:

Changes:

  • dak/new_security_install.py
    ... ... @@ -32,6 +32,9 @@ import sys
    32 32
     import time
    
    33 33
     import apt_pkg
    
    34 34
     import commands
    
    35
    +import errno
    
    36
    +from errno import EACCES, EAGAIN
    
    37
    +import fcntl
    
    35 38
     
    
    36 39
     from daklib import queue
    
    37 40
     from daklib import daklog
    
    ... ... @@ -87,25 +90,30 @@ def sudo(arg, fn, exit):
    87 90
     def do_Approve(): sudo("A", _do_Approve, True)
    
    88 91
     def _do_Approve():
    
    89 92
         print "Locking unchecked"
    
    90
    -    lockfile='/srv/security-master.debian.org/lock/unchecked.lock'
    
    91
    -    spawn("lockfile -r42 {0}".format(lockfile))
    
    92
    -
    
    93
    -    try:
    
    94
    -        # 1. Install accepted packages
    
    95
    -        print "Installing accepted packages into security archive"
    
    96
    -        for queue in ("embargoed",):
    
    97
    -            spawn("dak process-policy {0}".format(queue))
    
    98
    -
    
    99
    -        # 3. Run all the steps that are needed to publish the changed archive
    
    100
    -        print "Doing loadsa stuff in the archive, will take time, please be patient"
    
    101
    -        os.environ['configdir'] = '/srv/security-master.debian.org/dak/config/debian-security'
    
    102
    -        spawn("/srv/security-master.debian.org/dak/config/debian-security/cronscript unchecked-dinstall")
    
    103
    -
    
    104
    -        print "Triggering metadata export for packages.d.o and other consumers"
    
    105
    -        spawn("/srv/security-master.debian.org/dak/config/debian-security/export.sh")
    
    106
    -    finally:
    
    107
    -        os.unlink(lockfile)
    
    108
    -        print "Lock released."
    
    93
    +    lock_fd = os.open(os.path.join(cnf["Dir::Lock"], 'unchecked.lock'), os.O_RDWR | os.O_CREAT)
    
    94
    +    while True:
    
    95
    +        try:
    
    96
    +            fcntl.lockf(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
    
    97
    +            break
    
    98
    +        except IOError as e:
    
    99
    +            if errno.errorcode[e.errno] == 'EACCES' or errno.errorcode[e.errno] == 'EAGAIN':
    
    100
    +                print "Another process keeping the unchecked lock, waiting."
    
    101
    +                time.sleep(10)
    
    102
    +            else:
    
    103
    +                raise
    
    104
    +
    
    105
    +    # 1. Install accepted packages
    
    106
    +    print "Installing accepted packages into security archive"
    
    107
    +    for queue in ("embargoed",):
    
    108
    +        spawn("dak process-policy {0}".format(queue))
    
    109
    +
    
    110
    +    # 3. Run all the steps that are needed to publish the changed archive
    
    111
    +    print "Doing loadsa stuff in the archive, will take time, please be patient"
    
    112
    +    os.environ['configdir'] = '/srv/security-master.debian.org/dak/config/debian-security'
    
    113
    +    spawn("/srv/security-master.debian.org/dak/config/debian-security/cronscript unchecked-dinstall")
    
    114
    +
    
    115
    +    print "Triggering metadata export for packages.d.o and other consumers"
    
    116
    +    spawn("/srv/security-master.debian.org/dak/config/debian-security/export.sh")
    
    109 117
     
    
    110 118
     ########################################################################
    
    111 119
     ########################################################################
    


  • Reply to: