Skip to content
Snippets Groups Projects
  1. Sep 05, 2012
    • Iustin Pop's avatar
      Rework CLI modules and tests · 51000365
      Iustin Pop authored
      
      While investigating how we could test the Daemon.hs module, I realised
      that we have a very, erm, sub-optimal situation:
      
      - HTools/CLI.hs has a nice IO/pure separation testing in cmdline
        parsing, which allows some basic functionality to be tested, but
        uses direct 'read' in many options, which fails at runtime when
        evaluating the argument, and not when parsing the options
      - Daemon.hs lacks that, but has a much nicer 'reqWithConversion'
        helper that can be used for nicer option parsing, and uses that +
        tryRead instead of plain 'read'
      
      Since this situation is very bad, let's clean it up. We introduce yet
      another module, Common.hs, that holds functionality common to all
      command line programs (daemons or not). We move the parsing to this
      module, and introduce a type class to handle option types which
      support --help/--version. This allows removal of duplicated code from
      CLI.hs and Daemon.hs.
      
      The other part of the patch is cleanup/rework of the tests for this
      code: we introduce some helpers (checkOpt, passFailOpt,
      checkEarlyExit) that can be used from the much-slimmer now tests for
      CLI and Daemon. In the common module, we just test the yes/no helper
      we have. Many new tests for boolean options and numeric options are
      added.
      
      A side change is the removal of the obsolete `--replay-count',
      `--test-size' options (unused since commit 95f6c931, “Switch Haskell
      test harness to test-framework”).
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
      51000365
    • Iustin Pop's avatar
      Add query filter tests · 90171729
      Iustin Pop authored
      
      These tests are node specific only because we don't have other query
      types implemented yet, but what they actually test is the various
      filter types.
      
      The tests are trying to cover most filter functionality; missing for
      now is proper checking for ContainsFilter and TrueFilter, the rest
      should be more or less covered.
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
      90171729
    • Iustin Pop's avatar
      Add some unittests for node queries · b9bdc10e
      Iustin Pop authored
      
      These new tests check that:
      
      - no known fields return unknown
      - any unknown field returns unknown
      - the type of the fields is consistent between the getters and the
        field definition
      - the length of each result row corresponds with the number of fields
        queried, and the length of the field definitions returned
      - the length of the rows corresponds to the number of nodes
      - querying fields on empty fields returns all fields
      
      Finally this patch found a bug, in that the pinst_list/sinst_list
      fields were declared as QFTNumber (copy-paste error from
      pinst_cnt/sinst_cnt), yay!
      
      I also changed genEmptyCluster to ensure that it generates unique node
      names, so that the number of result rows is consistent with what we
      requested, and switched ResultEntry from a normal constructor to
      record syntax, so that we can extract the fields without having to use
      pattern matching.
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
      b9bdc10e
    • Iustin Pop's avatar
      Add unittests for the BasicTypes module · 1493a93b
      Iustin Pop authored
      
      This adds test properties for the various laws that the instances of
      Result should follow; I could not find (offline) laws about `mappend',
      but otherwise I implemented all laws that I could find.
      
      Note that we have to silence hlint warnings for the things we want to
      test, as otherwise hlint is all "this is already true based on the
      functor law, why 'fmap id' and not just 'id'?".
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
      1493a93b
    • Iustin Pop's avatar
      Move Version.hs up from under HTools/ · 2997cb0a
      Iustin Pop authored
      
      This is another module that is generic, and not htools-specific.
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
      2997cb0a
    • Iustin Pop's avatar
      Two tiny makefile fixes · 662de722
      Iustin Pop authored
      
      During the recent moves and renames, two things have slipped through,
      since I didn't run make check-local…
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
      662de722
  2. Sep 04, 2012
  3. Sep 03, 2012
    • Guido Trotter's avatar
      Instance autorepair design · 68640987
      Guido Trotter authored
      
      This design describes a tool that will perform automatic repairs on
      instances when they are detected to be unhealthy (living on offline or
      drained nodes, at the moment). These repairs can be scheduled
      automatically or requested as a one-off by a tool or person.
      
      Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
      Reviewed-by: default avatarBernardo Dal Seno <bdalseno@google.com>
      Reviewed-by: default avatarIustin Pop <iustin@google.com>
      68640987
    • Iustin Pop's avatar
      Add Query support for Nodes (no filtering, no RPC) · 046fe3f5
      Iustin Pop authored
      
      This is the initial support for Query2: basic infrastructure (except
      filtering) and node query support (without RPC).
      
      It implements all the fields (tests by comparison with list-fields on
      the Python side), except that:
      
      - filter is not done
      - since RPC is not integrated yet, the runtime gathering/computing is
        simply stubbed out
      
      However, the infrastructure seems pretty reasonable, so I'm sending as
      is.
      
      Note that I've split the functions/declarations into multiple files,
      to keep each file clean and readable.
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
      046fe3f5
    • Iustin Pop's avatar
      Stub query2 call integration into QueryD · 4cbe9bda
      Iustin Pop authored
      This patch corrects the definitions in Qlang.hs to match what Python
      expects on the wire; this means replacing some manual data type
      definitions with 'buildObject' so that we get serialisation (and field
      names) for free, adding (manually) JSON instances for types which are
      not represented as objects in JSON, etc. Due to more TH usage, I had
      to shift some definitions around, since TH breaks the "define in any
      order" property (☹️
      
      ).
      
      After that, we simply add a call into the stub Query/Query.hs module
      which, for all queries, responds with "query not supported". The
      reason for the deep directory structure is because I want to separate
      the functionality into multiple submodules, for smaller module size
      and readability.
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
      4cbe9bda
  4. Aug 28, 2012
    • Iustin Pop's avatar
      Reduce some more code duplication and split code · 62377cf5
      Iustin Pop authored
      
      The Qlang module defines ResultStatus, but it was already defined in
      Ganeti/Luxi.hs; let's remove the duplicate definition from there since
      the proper place is in the newer module.
      
      Also, in order to ease testing, we split some confd functions into a
      separate module; this can be imported easily into QC for testing.
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
      62377cf5
    • Iustin Pop's avatar
      Add configure-time switch for split queries · 42ab9ac4
      Iustin Pop authored
      
      And expand cli.GetClient() to allow opening the query socket, instead
      of the main master socket.
      
      Finally, enable the query socket use in gnt-cluster version, since
      that is already implemented fully in Queryd.hs/hconfd.
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
      42ab9ac4
    • Iustin Pop's avatar
      Rename Query2.hs to Qlang.hs · dc6a0f82
      Iustin Pop authored
      
      While starting to use the new filter types, I realised that what is
      currently implemented is the equivalent of `lib/qlang.py', not
      `lib/query.py', since we only deal with data types for now and not the
      actual query runtime functionality (RPC, config, etc.).
      
      Let's rename the file to be more consistent with the Python code base.
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
      dc6a0f82
    • Iustin Pop's avatar
      Re-enable standard hlint warnings · 2cdaf225
      Iustin Pop authored
      
      Commit 5a1e31b4 (Add infrastructure for, and two extra hlint rules)
      was intended to add two *extra* hlint rules, but I didn't realise at
      that time that "--hint" when first used overrides the built-in
      lints. As such, since then we were basically running with just those
      two rules, which resulted in many uncaught warnings/errors.
      
      This patch fixes that (by importing the standard lint rules in our
      custom hints file), and then goes to fix all the warnings that a
      current hlint gives me. Compared to our current style, we have just a
      few additions:
      
      - zipWithM instead of map foo . zip …
      - 'exitSuccess' instead of 'exitWith ExitSuccess'
      - more uses of '.'
      
      Additionally, we have to silence a case where hlint doesn't realise
      why we are using '\e -> const (return False (e :: IOError)' instead of
      just '\e -> return False' or even 'const (return False').
      
      One warning that is generated by hlint ("Use void") can't be fixed
      until we deprecate GHC 6.x, as only GHC 7 has the 'void' function in
      Control.Monad.
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
      2cdaf225
    • Iustin Pop's avatar
      Initial query daemon implementation · 25b54de0
      Iustin Pop authored
      
      This is just a new module that exports a runQueryD function, that can
      be imported to run a separate thread handling the luxi requests.
      
      Currently it needs access just to the configuration, in the future it
      will need access to an RPC runner too.
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
      25b54de0
    • Agata Murawska's avatar
      Datatypes for haskell RPC calls · d4709cce
      Agata Murawska authored
      
      We introduce typeclasses for RPC call and result and create a typeclass
      that binds the two together. For that we need to use
      MultiParamTypeClasses and FunctionalDependencies language pragmas, which
      allow us to ensure that RPC result type can be deduced based on the
      RPC call type.
      
      Signed-off-by: default avatarAgata Murawska <agatamurawska@google.com>
      Reviewed-by: default avatarIustin Pop <iustin@google.com>
      d4709cce
  5. Aug 27, 2012
  6. Aug 23, 2012
    • Iustin Pop's avatar
      Bump pep8 version to 1.2 · 5ae4945a
      Iustin Pop authored
      
      Debian Wheezy will ship with this version, and it has many improved checks compared to 0.6, so let's:
      
      - bump version in the docs
      - silence some new checks that are wrong due to our indent=2 instead of 4
      - fix lots of errors in the code where the indentation was wrong by 1
        or 2 spaces
      - fix a few cases of == True, False, None and replace with 'is'
      - re-indent some cases where the code is OK, but pep8 complains
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
      5ae4945a
  7. Aug 14, 2012
  8. Aug 09, 2012
  9. Aug 08, 2012
  10. Jul 23, 2012
    • Iustin Pop's avatar
      Build epydoc.conf using standard replace_vars_sed · fc1282b8
      Iustin Pop authored
      
      This is just begging to be converted to a standard replace_vars_sed
      rule, instead of custom sed calls.
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
      fc1282b8
    • Iustin Pop's avatar
      Simplify some make rules · 55398706
      Iustin Pop authored
      
      A rule of type "a/%: a/%.in" will also match "a/b/%: a/b/%.in", so no
      need for the explicit examples/hooks rule. As for the man rules, they
      are identical and thus can be collapsed.
      
      We still have the problem that globally, not all our %.in to %
      transformations are identical; this is suboptimal and should be
      cleaned sometime…
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
      55398706
    • Iustin Pop's avatar
      Explicitly terminate some make rules · 490bec02
      Iustin Pop authored
      
      Generic rules like:
      
        %: %.in
      
      have the downside that the source (%.in) itself matches the target
      (via %.in: %.in.in). This leads to things like:
      
        Looking for a rule with intermediate file `doc/examples/hooks/ipsec.in.in'.
         Trying pattern rule with stem `ipsec.in.in'.
         Trying implicit prerequisite `doc/examples/hooks/ipsec.in.in.in'.
         Trying pattern rule with stem `ipsec.in.in'.
         Trying implicit prerequisite `doc/examples/hooks/ipsec.in.in.in'.
         Looking for a rule with intermediate file `doc/examples/hooks/ipsec.in.in.in'.
        Rejecting impossible implicit prerequisite `doc/examples/hooks/ipsec.in.in'.
      
      To fix this, we need to tell make that such rules are terminating, so
      that it doesn't recurse into them.
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
      490bec02
    • Iustin Pop's avatar
      Remove ancient implicit make rules · 1d45f7a0
      Iustin Pop authored
      
      GNU Make contains some (ancient) implicit rules, that try to
      _automatically_ extract source files from RCS/SCCS version control
      systems. This is unneeded, and it pollutes the make -d output
      significantly: after removing these rules (by defining empty targets
      for their patterns), make -d line count goes from 5.3K to 3.3K.
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
      1d45f7a0
Loading