Uploaded image for project: 'RHEL Conversions'
  1. RHEL Conversions
  2. RHELC-1099

Prevent simultaneous instances of convert2rhel on a single system

XMLWordPrintable

    • False
    • False
    • Hide

      None

      Show
      None
    • 3
    • 1.4 GA
    • Testable

      If convert2rhel is running more than once in parallel, the system may be put into an inconsistent state. We can prevent convert2rhel from doing this by implementing a lock file.

      Acceptance Criteria

      1. On start, convert2rhel finds its own PID.
      2. create a temporary file in /run (or /var/run) that contains the PID
      3. attempt to os.rename() the temporary file to convert2rhel.pid
      4. if the rename fails because the file already exists, check for a stale file:
        1. check whether the pid in the file matches with a running process. If that is convert2rhel then we know that convert2rhel is already running.
          1. remove the temporary file
          2. output an error message
          3. exit.
        2. If the pid is not a running process or obviously not convert2rhel, then remove the pid file and go back to step 3.
      5. if the rename fails for another reason, issue an unexpected error, remove the temporary file, and exit
      6. If the rename succeeds then we are now the only running version of convert2rhel.
      7. On convert2rhel exit, remove the convert2rhel.pid file.(Use a context manager to make sure the file is always removed on exit. https://docs.python.org/2.7/library/contextlib.html )

              jochapma@redhat.com Joseph Chapman (Inactive)
              tkuratom@redhat.com Toshio Kuratomi
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: