1. 05 Mar, 2008 1 commit
  2. 04 Mar, 2008 12 commits
    • Guido Trotter's avatar
      LockSet: handle empty case · b2dabfd6
      Guido Trotter authored
      A LockSet is mostly useful when it has some locks in it. On the other hand
      there are cases in which it must function even when empty. For example if a
      cluster has no instances in it there's no reason why locking all of them
      shouldn't work anyway. This patch adds test code for that situation and
      implements the necessary fixes to make it work.
      
      Reviewed-by: imsnah
      
      b2dabfd6
    • Guido Trotter's avatar
      LockSet: add missing check code · b5c0e9d9
      Guido Trotter authored
      This check that no operation had been performed before release() was missing in
      the test code. Adding it.
      
      Reviewed-by: imsnah
      
      b5c0e9d9
    • Guido Trotter's avatar
      LockSet: collapse two try/except into one · ea3f80bf
      Guido Trotter authored
      Reviewed-by: imsnah
      
      ea3f80bf
    • Guido Trotter's avatar
      SharedLock: remove wrong assertion in code · 9a39f854
      Guido Trotter authored
      r644 contained some cleanup code for LockSet. Among other things it removed a
      syntax error that allowed an assertion that previously wan't really checked to
      trigger. It turns out that even though the spirit of that assertion was correct
      its actual implementation was wrong.
      
      While it's true that no sharers must be waiting if an exclusive holder is not
      present it might happen that when all the sharers wake up one of them releases
      the lock before some other even has had a chance to run. In this case
      __shr_wait would still be greater than 0, even if the sharer is not actually
      waiting, just pending a wakeup to proceed.
      
      Thus, removing the assertion in question.
      
      Reviewed-by: imsnah
      9a39f854
    • Michael Hanselmann's avatar
      Codestyle updates for locking code · cdb08f44
      Michael Hanselmann authored
      Reviewed-by: ultrotter
      cdb08f44
    • Guido Trotter's avatar
      LockSet: make acquire() able to get the whole set · 3b7ed473
      Guido Trotter authored
      This new functionality makes it possible to acquire a whole set, by passing
      "None" to the acquire() function as the list of elements. This will avoid new
      additions to the set, and then acquire all the current elements. The list of
      all elements acquired will be returned at the end.
      
      Deletions can still happen during the acquire process and we'll deal with it by
      just skipping the deleted elements: it's effectively as if they were deleted
      before we called the function. After we've finished though we hold all the
      elements, so no more deletes can be performed before we release them.
      
      Any call to release() will then first of all release the "set-level" lock if
      we're holding it, and then all or some of the locks we have.
      
      Some new tests checks that this feature works as intended.
      
      Reviewed-by: imsnah
      
      3b7ed473
    • Guido Trotter's avatar
      LockSet: encapsulate acquire() in try-except · 806e20fd
      Guido Trotter authored
      This patch adds a try/except area around most of the acquire() code (everything
      after the intial condition checks). Since the except: clause contains just a
      'raise' nothing really changes except the indentation of the code.
      
      This is done in a separate commit to insulate and make clearer what the real
      code changes done in the upcoming patch are.
      
      Reviewed-by: imsnah
      
      806e20fd
    • Guido Trotter's avatar
      Make LockSet.__names() return a list, not a set · 0cf257c5
      Guido Trotter authored
      Previously the private version of the __names function returned directly a set.
      We'll keep this in the public interface but change the private version to a
      list in order to be able to sort() its result and then loop on it, even though
      we'll need to do this with the usual care that some keys may disappear in
      between.
      
      Reviewed-by: imsnah
      
      0cf257c5
    • Guido Trotter's avatar
      LockSet: improve remove() api · 3f404fc5
      Guido Trotter authored
      Lockset's remove() function used to return a list of locks we failed to remove.
      Rather than doing this we'll return a list of removed locks, so it's more
      similar to how acquire() behaves. This patch also fixes the relevant unit tests.
      
      Reviewed-by: imsnah
      
      3f404fc5
    • Guido Trotter's avatar
      LockSet: make acquire() return the set of names · 0cc00929
      Guido Trotter authored
      In a LockSet acquire() returned True on success. This code changes that to
      return a set containing the names of the elements acquired. This is still a
      true value if we acquired any lock but is slightly more useful (because if
      needed one has access to this data without querying for it). The only change
      happens if acquiring no locks, which though is a usage which should not
      normally happen because it has no practical use.
      
      The patch also changes a some tests to check that the new format is respected.
      
      Reviewed-by: imsnah
      
      0cc00929
    • Guido Trotter's avatar
      LockSet: invert try/for nesting in acquire() · 8b68f394
      Guido Trotter authored
      This patch changes nothing to the functionality of a LockSet. Rather than
      trying to do the whole for loop we try each of its steps. This opens the way to
      handle differently a single failure.
      
      Reviewed-by: imsnah
      8b68f394
    • Guido Trotter's avatar
      Initial GanetiLockManager implementation · 7ee7c0c7
      Guido Trotter authored
      Includes some locking-related constants and explanations on how the
      LockManager should be used, the class itself and its test cases.
      
      The class includes:
        - a basic constructor
        - functions to acquire and release lists of locks at the same level
        - functions to add and remove list of locks at modifiable levels
        - dynamic checks against out-of-order acquisitions and other illegal ops
      
      Its testing library checks that the LockManager behaves correctly and that the
      external assumptions it relies on are respected.
      
      Reviewed-by: imsnah
      7ee7c0c7
  3. 29 Feb, 2008 3 commits
  4. 28 Feb, 2008 5 commits
    • Guido Trotter's avatar
      LockSet: make acquire() fail faster on wrong locks · e6c200d6
      Guido Trotter authored
      This patch makes acquire() first look up all the locks in the dict and then try
      to acquire them later. The advantage is that if a lockname is already wrong
      since the beginning we won't need to first queue and acquire other locks to
      find this out.
      
      Of course since there is no locking between the two steps a delete() could
      still happen in between, but SharedLocks are safe in this regard and will just
      make the .acquire() operation fail if this unfortunate condition happens.
      
      Since the right way to check if an instance/node exists and make sure it won't
      stop existing after that is acquiring its lock this improves the common case
      (checking for an incorrect name) while not penalizing correctness, or
      performance as would happen if we kept a lock for the whole process.
      
      Reviewed-by: iustinp
      e6c200d6
    • Guido Trotter's avatar
      LockSet implementation and unit tests · aaae9bc0
      Guido Trotter authored
      A LockSet represents locking for a set of resources of the same type. A thread
      can acquire multiple resources at the same time, and release some or all of
      them, but cannot acquire more resources incrementally at different times
      without releasing all of them in between.
      
      Internally a LockSet uses a SharedLock for each resource to be able to grant
      both exclusive and shared acquisition. It also supports safe addition and
      removal of resources at runtime. Acquisitions are ordered alphabetically in
      order to grant them to be deadlock-free. A lot of assumptions about how the
      code interacts are made in order to grant both safety and speed; in order to
      document all of them the code features pretty lenghty comments.
      
      The test suit tries to catch most common interactions but cannot really tests
      tight race conditions, for which we still need to rely on human checking.
      
      This is the second basic building block for the Ganeti Lock Manager. Instance
      and Node locks will be put in LockSets to manage their acquisition and release.
      
      Reviewed-by: imsnah
      aaae9bc0
    • Guido Trotter's avatar
      Fix the gnt-cluster init man page · f3b100e1
      Guido Trotter authored
      Some options were missing in the gnt-cluster init man page.  This patch adds
      them, removes an empty line, and clarifies a bit more some requirements.
      
      Reviewed-by: schreiberal
      f3b100e1
    • Guido Trotter's avatar
      Don't allow renaming to an existing instance · 7bde3275
      Guido Trotter authored
      Even if the target instance is down or we are not checking for IP conflicts
      changing an instance name to a new one which is already in the cluster is
      doomed to fail, because in a lot of places (among which figures the mind of
      most users/admins) instance names are assumed to be unique.
      
      Reviewed-by: imsnah
      7bde3275
    • Alexander Schreiber's avatar
      Clarify online help for xc-instance reinstall. · 5336d63d
      Alexander Schreiber authored
      Reviewed-by: imsnah
      
      5336d63d
  5. 27 Feb, 2008 2 commits
  6. 26 Feb, 2008 2 commits
  7. 25 Feb, 2008 2 commits
  8. 23 Feb, 2008 1 commit
    • Guido Trotter's avatar
      Improve ganeti example cron file · 0d349b3a
      Guido Trotter authored
      The cron file in ganeti's example directory is now static, and executes
      ganeti-watcher in /usr/local/sbin no matter where it's really installed. With
      this patch we generate it at build time substituting the right value of
      @SBINDIR@ from ganeti.cron.in. We also make sure ganeti-watcher exists and is
      executable before running it.
      
      This is targeted at 1.2 as well.
      
      Reviewed-by: iustinp
      0d349b3a
  9. 22 Feb, 2008 3 commits
    • Manuel Franceschini's avatar
      Small comment fix. · 6c8af3d0
      Manuel Franceschini authored
      6c8af3d0
    • Manuel Franceschini's avatar
      c99a3cc0
    • Iustin Pop's avatar
      Break trunk by removing twisted · 81010134
      Iustin Pop authored
      This patch switches from the twisted usage for inter-node protocol to
      simple BaseHTTPServer/httplib. The patch has more deletions because we
      use no authentication, no encryption at all.
      
      As such, this is just for trunk, and only for testing. What it brings is
      the ability to use the rpc library from within multiple threads in
      parallel (or it should so).
      
      Since the changes are very few and non-intrusive, they can be reverted
      without impacting the rest of the code.
      
      This passes burnin. QA was not tested.
      
      Reviewed-by: imsnah
      81010134
  10. 21 Feb, 2008 1 commit
    • Guido Trotter's avatar
      Add a few SharedLock delete() tests · 84152b96
      Guido Trotter authored
      - Check that even a shared acquire() fails on a deleted lock
      - Check that delete() fails on a lock you share (must own it or nothing)
      
      These are assumptions I build on in future code, so better check for them.
      Currently no code change is necessary for them to be valid.
      
      Reviewed-by: iustinp
      84152b96
  11. 20 Feb, 2008 2 commits
    • Guido Trotter's avatar
      SharedLock: fix a wrong unit-test helper code · 4354ab03
      Guido Trotter authored
      The _doItDelete helper code was supposed to be used to dispatch threads that
      deleted the SharedLock. It actually just acquired it exclusively. This remained
      unnoticed as the helper thread is just used to test interaction, not the delete
      code by itself, and delete requires an exclusive acquire anyway.
      
      Reviewed-by: imsnah
      4354ab03
    • Guido Trotter's avatar
      Add another 1.1->1.2 compatibility alias · 00ce8b29
      Guido Trotter authored
      gnt-instance replace-disks used to be called replace_disks.
      
      Reviewed-by: iustinp
      00ce8b29
  12. 19 Feb, 2008 1 commit
    • Guido Trotter's avatar
      Add the delete() operation to SharedLock · a95fd5d7
      Guido Trotter authored
      This new operation lets a lock be cleanly deleted. The lock will be exclusively
      held before deletion, and after it pending and future acquires will raise an
      exception. Other SharedLock operations are modify to deal with delete() and to
      avoid code duplication.
      
      This patch also adds unit testing for the new function and its interaction with
      the other lock features. The helper threads are sligtly modified to handle and
      report the condition of a deleted lock. As a bonus a non-related unit test
      about not supporting non-blocking mode yet has been added as well.
      
      This feature will be used by the LockSet in order to support deadlock-free
      delete of resources. This in turn will be useful to gracefully handle the
      removal of instances and nodes from the cluster dealing with the fact that
      other operations may be pending on them.
      
      Reviewed-by: iustinp
      a95fd5d7
  13. 18 Feb, 2008 5 commits