- Oct 26, 2012
-
-
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 follows a conversation we had for how to deal with optional-but-required fields in JSON serialisations: fields which are optional (can be either a given type or 'null'), but where the 'null' value is required. There are just a few of these in the Python code, but we should support them nevertheless. The patch changes the 'isOptional' attribute from boolean to a custom ADT, three-typed. This allows us to keep the same path on load (which deals with both cases), but use a custom save path where we explicitly save the 'null' value. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
- Oct 25, 2012
-
-
Dato Simó authored
Change {exp,act}Code to {exp,act}Ver, which gives a better idea that the integer fields represent version numbers. Also: - errors.py: update OpPrereqError's docstring to note that an error code is always expected as the second argument (it was previously optional). Signed-off-by:
Dato Simó <dato@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
Dato Simó authored
The isOptional function is no longer used after a1505857 (“Convert opcode TH code to the use of Field type”). Signed-off-by:
Dato Simó <dato@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
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
In Python, formatError also returns the exit code, but I find that splitting them leads to clearer code. 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>
-
Iustin Pop authored
These are almost generic, so let's change the signatures a bit a make them fully so. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Adeodato Simo <dato@google.com>
-
Iustin Pop authored
This 'simple' way of defining objects will be used also for errors, so let's make it less Luxi-specific. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Michael Hanselmann <hansmi@google.com>
-
- Oct 22, 2012
-
-
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>
-
Helga Velroyen authored
Small simplifications of other unit tests using the (==?) operator when possible, and typo fixes. Signed-off-by:
Helga Velroyen <helgav@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
- Oct 19, 2012
-
-
Dato Simó authored
eitherToResult now converts from `Either a b` to `GenericResult`, not necessarily from `Either String` only. Also, fix a typo. Signed-off-by:
Dato Simó <dato@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
- Oct 18, 2012
-
-
Iustin Pop authored
Since we now have the GeneralResult as a multi-purpose monad, we can remove the custom OpResult monad, and just use 'GeneralResult FailMode' as our type. This allows removal of a few bits of specialised infrastructure, relying instead on the generic one. The restriction on using OpResult as a general monad remains as before. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Michael Hanselmann <hansmi@google.com>
-
Helga Velroyen authored
Furthermore, a few messages have their capitalisation changed (fixed). Signed-off-by:
Helga Velroyen <helgav@google.com> Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
- Oct 17, 2012
-
-
Iustin Pop authored
Currently, our error monad—Result—has a plain string error type. This is not good, as we don't have structured errors, we can't pass back proper error information to Python code, etc. To solve this, we generalise this type as 'GenericResult a', and make Result an alias to 'GenericResult String' for compatibility with the old code. New error hierarchies will be introduced as different types. Furthermore, we generalise our helper functions too, so that they can work on any 'GeneralInstance a' type, not only Result. There are two small drawbacks to this generalisation. First, a Monad instance requires (at least for the way we use it) a 'fail :: String -> m a' instance, so we need to be able to build an 'a' value from a string; therefore, we can implement the Monad instance only for a newly-introduced typeclass, 'FromString', which requires the needed conversion function. Second, due to the fact that 'String' is a type alias (for [Char]) instead of an actual type, we need to enable the FlexibleInstances language pragma; as far as I know, this has no significant drawbacks. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Michael Hanselmann <hansmi@google.com>
-
Dato Simó authored
This commit adds a Group.allTags field to store the tags of node groups, and teaches each loader backend in HTools to populate it (additionally, the IAllocator class in lib/cmdlib.py now includes tags for groups too). Test data is updated to include an empty set of tags for node groups in all affected test cases. Signed-off-by:
Dato Simó <dato@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
Dato Simó authored
The mergeData function in Loader.hs included a step to filter an instance's tags to include only the exclusion tags (as specified via the commandline, or cluster-level tags). Later on, code in Node.hs assumed Instance.tags to contain only tags to be used for exclusion. Because in the future we will need to access the full list of an instance's tags (and not only exclusion tags), this commits deprecates the 'tags' field, and introduces Instance.exclTags and Instance.allTags. Instance.allTags is now populated from the different backends (Text, Luxi, Rapi, etc.), and Instance.exclTags is only populated from Loader.mergeData, as was done previously. This means that loading tags from e.g. Text or Simu and assuming that they'll be used as exclusion tags without going through Loader.hs will no longer work; but this was already the case with other fields, and 'mergeData' or 'loadExternalData' continue to be the only entry points to get a consistent view of the cluster. (Additionally, there were no tests that made this assumption that I could find.) Signed-off-by:
Dato Simó <dato@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
- Oct 16, 2012
-
-
Iustin Pop authored
This only supports test delay for now, is not built by default (only on demand), and is also not installed anywhere. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
Iustin Pop authored
Also add some more haddock structure to the module. The RPC call itself is rather trivial. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
Iustin Pop authored
By accident, we sent the node object as call data in this rpc call, instead the version request (i.e. nothing). This is due to the fact that the 'call' data comes second, not first in the function argument. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Agata Murawska <agatamurawska@google.com>
-
- Oct 15, 2012
-
-
Iustin Pop authored
Before we reorganised the source tree, the 'Result' type was exported from HTools/Types.hs. This changed during the reorg, but at that time we didn't change the exports; instead, we kept re-exporting it from the old module for compatibility. In light of future changes to the Result type, let's stop this re-export and cleanup the imports of the other modules. One test is slightly rewritten with explicit types declaration (part of the values already needed one, let's make it explicit). Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Michael Hanselmann <hansmi@google.com>
-
- Oct 11, 2012
-
-
Dato Simó authored
The comments in parseData had become out of date with the implementations of load{Group,Node,Inst}. This commit updates the field list in comments to match the implementations. Signed-off-by:
Dato Simó <dato@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
Iustin Pop authored
While grepping for htools imports in the non-htools subdirectory, I saw that our haddock prologue and title are very very old and refer to the old htools-only state. Let's cleanup a bit… Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Michael Hanselmann <hansmi@google.com>
-
Iustin Pop authored
This patch removes the last HTools module imports from non-htools code (the HTools.Types module), but it requires an associated cleanup: using luxi-specific constants for luxi timeouts (the only effect is that one timeout decreases from 15 to 10, the default value in the python code), and moving of the (now) RAPI specific constants to RAPI.hs (which allows simplifying their type/usage). Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Michael Hanselmann <hansmi@google.com>
-
Iustin Pop authored
… and also use it to simplify 'needsLiveData'. Additionally, add an explicit export list to Ganeti.Query.Types, since otherwise we'd (re)export all imported symbols. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Agata Murawska <agatamurawska@google.com>
-
Iustin Pop authored
This patch adds support for classic-style queries (before query2) to the query socket server. The patch is rather trivial, since as in Python we just piggy-back on the query2 implementation. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Agata Murawska <agatamurawska@google.com>
-
Iustin Pop authored
And associated unittests. This will be needed for classic-style queries. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Michael Hanselmann <hansmi@google.com>
-
Iustin Pop authored
When initially implementing the node query, I thought the 'powered' field is a representation of the run-time powered status, which would make its query complex. In reality, it's a simple config query, which we can support easily. We also add a small helper, so that we don't hardcode the RSUnavail case in many places. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Agata Murawska <agatamurawska@google.com>
-
Iustin Pop authored
We don't add a type class for fully-generic handling, but we do abstract the duplicate part. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Agata Murawska <agatamurawska@google.com>
-
Iustin Pop authored
… and use it in the Query implementation, removing the last non-correct query field for Groups. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Michael Hanselmann <hansmi@google.com>
-
Iustin Pop authored
This makes the "all" names queries consistent with the Python results. The change requires updating the unittests, at which point a duplicate error message is simplified. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Michael Hanselmann <hansmi@google.com>
-
Iustin Pop authored
We do this not quite generically, which means we have to add another layer in the call chain, and rename the current query function, plus add special-case code for each query type. Hopefully we will be able to improve on this in the future. A (good) side effect of this patch is that we get the desired ordering when names are requested, matching the Python code. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Agata Murawska <agatamurawska@google.com>
-
Iustin Pop authored
This replicates in the Haskell Query2 implementation the behaviour of the Python code: if a "simple" filter is passed (one that contains only Or aggregators and EQ binary ops on the name field), then an failure is flagged if the given values are not known. Our implementation is pretty straightforward, with a few details: - we ignore any NumericValues passed, since that inconsistency will be flagged by the filter compiler - we return an the non-normalized names from the getRequestedNames function, and not the fully-normalized ones; this will be done later in individual query functions - we test a few of the desired behaviours of the above-mentioned function Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Agata Murawska <agatamurawska@google.com>
-
- Oct 10, 2012
-
-
Iustin Pop authored
The disk free/total values are optional ones, wrapped in a Maybe, so we shouldn't directly serialise them. In order to simplify the embedded extraction, we add a small helper function. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Agata Murawska <agatamurawska@google.com>
-
Iustin Pop authored
We need to only query the default (first enabled) hypervisor, not all hypervisors. For this, we need to add a manual check to ensure that we don't have a corrupt config (there's no "NonEmptyList" type…). Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Michael Hanselmann <hansmi@google.com>
-
Iustin Pop authored
The String parameter to 'nodeLiveFieldExtract' is the query2 field name, not the RPC-layer field name. Grrr for not having a real data type for this. Furthermore, we add some safety check that we don't return JSNull via rsNormal… Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Agata Murawska <agatamurawska@google.com>
-
Iustin Pop authored
This patch makes regex-pcre optional, allowing its disable via a preprocessor define NO_REGEX_PCRE. This define will be added to config.ac/Makefile.am in the next patch. The patch also changes multi-line strings into string concatenation, due to limitations with the CPP language extension. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
- Oct 08, 2012
-
-
Iustin Pop authored
This patch adds a NiceSort equivalent and the corresponding unittest (partially copied from Python unittest). The difference between the Python version and this one is that this implementation doesn't use regular expressions, and as such it doesn't have the 8-groups limitation. The key-based version is separate from the non-key one (since we don't have default arguments in Haskell), and is tested less in its absolute properties but only that it is identical to the non-key version under some transformations (the non-key version is much more tested). This will be needed later in query name sorting. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Michael Hanselmann <hansmi@google.com>
-
Iustin Pop authored
This allows the command completion to treat them as separate option types; this is not useful in build-bash-completion right now, but might become so in the future. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Michael Hanselmann <hansmi@google.com>
-
Iustin Pop authored
This defines the arguments supported and then modifies the --help-completion output to include them too. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Michael Hanselmann <hansmi@google.com>
-