- Nov 21, 2012
-
-
Iustin Pop authored
These are needed for completing the node opcode parameters. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
Iustin Pop authored
This makes it easy to generate sets of "things" that don't even need to have arbitrary instances, but which have bounded/enum instances. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Adeodato Simo <dato@google.com>
-
Iustin Pop authored
This fixes a FIXME actually recommending this move :) Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
Iustin Pop authored
The QR_VIA_OP/QR_VIA_LUXI types in Python are using yet another validation mode: QR_VIA_OP is the base type, and QR_VIA_LUXI extends it (when doing luxi queries). But on the wire they have the same representation. To accommodate this properly, we split the ItemType in two: a QueryTypeOp and a QueryTypeLuxi, joining them back together in ItemType itself. This requires custom serialisation/deserialisation, but allows us to express correctly that at opcode level, we only accept a QueryTypeOp, but at Luxi query level, we accept either of them. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
Iustin Pop authored
This is a very basic type and 'Objects' is a heavy-weight module. By moving it to 'types' we simplify (in the future) the import chains. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Adeodato Simo <dato@google.com>
-
Iustin Pop authored
Currently, we have some types that we kept as dictionaries in the objects representation (due to inconsistent behaviour, or other technical reasons). This should be improved in the future, but in the meantime we can improve the Container type by allowing its keys to be non-strings; this is needed, for example, for better safe in DiskParams type, where we don't want arbitrary strings as keys, but only the actually defined types. To implement this change, we generalise the type (Container → GenericContainer), and in the process we introduce a type class for "things that can be represented as strings". This is very similar to a combination of Read and Show, but with custom string representation. The new type class is needed because in JSON representation, object keys must be strings, so we need to be able to serialised/deserialise the generic keys to/from plain strings. We also add the instance for DiskTemplate at the same time. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Adeodato Simo <dato@google.com>
-
Iustin Pop authored
These are needed both in opcodes and (potentially) outside, so we add them in the main Types module. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Michael Hanselmann <hansmi@google.com>
-
- Nov 20, 2012
-
-
Iustin Pop authored
Sorry… Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Helga Velroyen <helgav@google.com>
-
Iustin Pop authored
This mirrors the ht.py types PositiveInt, NonNegative, etc., except that they work at a more generic level (any numeric type, respectively any non-empty list). Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Adeodato Simo <dato@google.com>
-
Iustin Pop authored
This is yet-another version-specific warning (fixed in later hlint versions), but it's better to keep it clean. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
Michele Tartara authored
This adds tests that existing test files can be parsed by the Haskell parser as well, plus one new test file. Signed-off-by:
Michele Tartara <mtartara@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
Iustin Pop authored
Use more monadic combinators instead of explicit code. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Adeodato Simo <dato@google.com>
-
Iustin Pop authored
There are already three cases where we copied type definitions between the htools-specific types into the main ganeti code. Let's stop doing this
☺️ and create a common types module that holds these. Note that there already exists BasicTypes.hs, but that refers to very low-level types, and can't use TH derivation itself. A side effect of this unification is that there is a small conflict between AdminStatus/AdminOffline and InstanceStatus/AdminOffline. As such, I renamed AdminOffline and AdminDown to StatusOffline/StatusDown in the InstanceStatus type. The patch also moves the tests related to these types to a new test module. Signed-off-by:Iustin Pop <iustin@google.com> Reviewed-by:
Adeodato Simo <dato@google.com>
-
- Nov 16, 2012
-
-
Michele Tartara authored
They mimic their python counterparts. Added functions: * getSourceDir * testDataFilename * readTestData * readPythonTestData Signed-off-by:
Michele Tartara <mtartara@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
Michele Tartara authored
Signed-off-by:
Michele Tartara <mtartara@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
- Nov 15, 2012
-
-
Iustin Pop authored
Currently, THH.hs "injects" into the built code names of library functions like Text.JSON.makeObj, Ganeti.JSON.fromObj, etc. built directly from strings, via (e.g.) varE (mkName "makeObj") This means that the "makeObj" name must exist in the target module, i.o.w. must be imported there. This leads to the strange case of having to have imports that do not appear at all in the used (template) code, but are needed to satisfy this "hidden" dependency; look at Ganeti/Jobs.hs before this patch, for example. This is also not very obvious, because we usually import Text.JSON anyway; I only stumbled upon it while doing some cleanup work. So to clean this up, the current patch changes the THH.hs to use not string-derived, but identifier-derived names («'identifier» versus «mkName "identifier"»); this is better, as the names must be resolvable when compiling THH itself (once), and not when compiling the multiple derived modules. As you can see, this allows removal of extraneous imports from various modules. Background information: an `mkName "foo"` results in a name of flavour NameS (“An unqualified name; dynamically bound”) or alternatively to a qualified name, but still dynamically bound. Whereas what we want is a statically bound name: `'foo` results in a NameG flavour, “Global name bound outside of the TH AST: An original name”. One more explanation: the change is similar to going from 'x = eval "map"' to 'x = map'; the name is no longer dynamically evaluated, but statically when the module is compiled. In our case, previously names were bound at target module compile time, now they are bound at THH.hs compile time. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
- Nov 14, 2012
-
-
Iustin Pop authored
This is not a quickcheck property, since it doesn't have any variable/arbitrary inputs. So let's make it a test case, and shorten a bit the name. Also, sorry for not catching this in the review. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Michele Tartara <mtartara@google.com>
-
- Nov 13, 2012
-
-
Michael Hanselmann authored
A new LUXI request is added, in both Python and Haskell. Signed-off-by:
Michael Hanselmann <hansmi@google.com> Reviewed-by:
Bernardo Dal Seno <bdalseno@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
Iustin Pop authored
Some GHC flags are very useful, but only appear in more recent GHC versions. To support the use of such flags while still supporting older compilers, let's add conditional checks and enabling based on the results. Currently only `-fwarn-incomplete-uni-patterns` is enabled, which detects refutable patterns in lambda expressions and pattern bindings (e.g. "let (Just x) = y"); such constructs are bad as they can lead to runtime exceptions. Additionally, fix an existing such bad construct in a test case; we workaround it by using error, since that should never fail. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
Michele Tartara authored
Attoparsec is known to have had issues with parsing non-ASCII strings. This test makes sure that parsing of Unicode characters works fine. Signed-off-by:
Michele Tartara <mtartara@google.com> [iustin: small doc string fixes] Reviewed-by:
Iustin Pop <iustin@google.com>
-
Iustin Pop authored
Sorry, I broke lint again :), by introducing two sub-standard changes. Additionally, this silences an older existing warning that only triggers with some versions of hlint (e.g. 1.8.28 which is present in Wheezy). Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
- Nov 12, 2012
-
-
Iustin Pop authored
We need to change a few things, most importantly CLI options defaults, but otherwise we already used the path to files from functions which were already in the I/O monad, so we don't have to change much of the code flow. Additionally, Path.hs now has an explicit export list, to stop accidental leakage of symbols. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Helga Velroyen <helgav@google.com>
-
Iustin Pop authored
Currently, keyToFilename uses itself the default config path. In the light of making that an function in the IO monad, let's remove the "default" path functionality from this function and make it always require the config path; its caller, readSSConfFile, can then do the maybe/default path change. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Michael Hanselmann <hansmi@google.com>
-
Iustin Pop authored
Some options have defaults that depend on the environment, and we could handle these in two ways: - use a place-holder value (e.g. data X a = Default | Custom a) that is later read from the environment - move the options list to IO monad, where it can read the environment, etc. The second option allows also displaying the actual defaults in the `--help' output, even though it's not as nice, so I went with it. This patch only changes the option types, without actually changing any options yet. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Helga Velroyen <helgav@google.com>
-
Iustin Pop authored
Currently, we keep information about the "target" of a tag operation in a data type similar to (TagKind, Maybe String). This is unsafe, as nothing (at the type level) prevents us from accidentally having (TagCluster, Just "instance1.example.com"), or (TagInstance, Nothing). To fix this problem, we rename the current TagObject type to TagType (an internal utility type), and create TagObject as a better/safer data type (see the definition), which doesn't allow such possibilities in the future. The downside is that, since at encoding level (both opcode and luxi) this is done in an ugly way (type elements spread at the same level as level as other value), we have to add custom encoders/decoders. The encoder is shared between the OpCode and Luxi usage, the decoder is different however as Luxi uses custom decoding. This also fixes the recent breakage in confd w.r.t. QueryTags. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Michael Hanselmann <hansmi@google.com>
-
Iustin Pop authored
Doh, this is exactly the opposite of what we wanted… good thing no test failed so far :) Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
- Nov 08, 2012
-
-
Iustin Pop authored
This should be the last module rename, promise! We rename this to conform to the other hierarchies (e.g. Query), and to not have both Confd.hs and Confd/*.hs. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
Dato Simó authored
Also, adjust comment to $(genOpCode) block to avoid repetition of "only". Signed-off-by:
Dato Simó <dato@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
Dato Simó authored
In addition to ReqQueryTags in Luxi.hs, the TagObject ADT is also required for the "kind" attribute of OpTagsSet and OpTagsDel, which are coming to OpCodes.hs next. Hence, we move TagObject there, and adjust imports accordingly. Signed-off-by:
Dato Simó <dato@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
- Nov 06, 2012
-
-
Iustin Pop authored
This tests that the same Luxi calls are defined in Python and Haskell. It doesn't test yet that their serialisation is correct though. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
- Oct 26, 2012
-
-
Iustin Pop authored
Five modules under the HTools/ directories are backend implementations, so let's move them to a separate directory, to more clearly show the hierarchy. I wanted to do this for a while, but merging between branches is always an issue, so let's do it know since we have an opportunity. This patch contains the actual renames, the required changed module names, imports, etc., but no other changes. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Michael Hanselmann <hansmi@google.com>
-
Iustin Pop authored
Sorry! Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Michael Hanselmann <hansmi@google.com>
-
Iustin Pop authored
Testing with a newer hlint found a few minor issues; but all are real, valid recommendations: - don't use "if cond then f x else f y", but "f (if cond then x else y)" - "if a then b else True" is equivalent to the simpler "not a || b" - and as usual, one more ignore to our "testing basic properties" module Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Michael Hanselmann <hansmi@google.com>
-
Iustin Pop authored
This is very THH specific, and applies to all serialisations generated by THH, so I'm adding it in its own module. Probably we should add some more generic tests, but in general THH code is tested by the various definitions; this new field type however is not (yet), so this is why I want this specific unittest. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
- Oct 25, 2012
-
-
Iustin Pop authored
This patch converts all the call paths from 'Result' (which contains just string errors) to 'ErrorResult', which holds GanetiException-encoded errors. We can now return proper OpPrereq/OpExec errors to the clients of the luxi/query socket. The patch touches many files as we had to convert the entire call chains in a single round. But it should be pretty straightforward otherwise: - change 'Result' into 'ErrorResult' - add error annotations: change "Bad msg" into "Bad (XXXEror msg)" - add a helper function for confd, where we don't send to client formatted exceptions, to convert back from ErrorResult into Result - change tests similarly, where needed Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Michael Hanselmann <hansmi@google.com>
-
Iustin Pop authored
As described in the module doc string, while writing this it dawned upon me that we're mixing all errors together into a single hierarchy (well, type on the Haskell side), which is not good. Some errors are used purely within noded, some in the CLI frontends, etc. so these should not be the same type; frontend functions should only be able to raise frontend errors, not backend ones. As to this patch itself, I've used again Template Haskell to generate both the data type and the serialisation functions, as the initial version, hand-written, seemed too prone to errors due to string matching. A small unittest for checking serialisation consistency is also added. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
- Oct 22, 2012
-
-
Iustin Pop authored
This is just a bit of cleanup. The (.&&.) operator is internally just: a .&& b = conjoin [a, b] so let's replace 'a .&&. b .&&. c .&&. d' directly with 'conjoin [a, b, c, d]'. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
Iustin Pop authored
After seeing how nice HUnit formats the error message on failed 'assertEqual', I think we can do better with ==?. Currently it says (on one line): "Expected equality, but 1 /= 2". This patch changes the code to format it similar to HUnit: Expected equality, but got mismatch expected: 1 but got: 2 (on three lines). This makes it more clear what is the expected and what is the wrong value. A few tests have been modified to ensure that the expected value is the second argument to ==?. This is different than HUnit, but makes more sense in the operator version (I think). Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Helga Velroyen <helgav@google.com>
-
Helga Velroyen authored
This includes: * The operator (/=?), which checks for inequality and prints an error message if it encounters equality. (Basically the negation of the (==?) operator). * Application of this operator in the test property prop_addPri_NoN1Fail. Signed-off-by:
Helga Velroyen <helgav@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
Helga Velroyen authored
This patch includes: * The 'failN1' flag is now only set if there is strictly less memory available than required for failover. * Unit tests for that. Signed-off-by:
Helga Velroyen <helgav@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-