ganeti-local
13 years agohtools: allow different result types
Iustin Pop [Sat, 2 Jul 2011 08:18:46 +0000 (10:18 +0200)]
htools: allow different result types

This patch extends the previous patch changes to allow that each
Cluster function returns a different result type, as long as we have
an auxiliary function that processes that into the standard
IAllocResult type.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

13 years agohtools: start reorganising the IAllocator workflow
Iustin Pop [Sat, 2 Jul 2011 07:29:50 +0000 (09:29 +0200)]
htools: start reorganising the IAllocator workflow

Currently, all IAllocator requests return the same result type: a list
of strings (usually nodes, but can also be instance:nodes). This won't
be true in the future, with the new request types that will return
opcode lists.

Therefore we will need to support multiple result types in the
workflow; the first step is to make the final formatResponse step
result-type-indepedent, so we take out the formatRVal invocation out
of this function.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

13 years agohtools: split more code from hail/main
Iustin Pop [Sat, 2 Jul 2011 06:18:22 +0000 (08:18 +0200)]
htools: split more code from hail/main

The logic of request processing is not separated into its own
function, and (beside CLI interaction, e.g. verbosity handling) all
logic is now in IAllocator.hs.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

13 years agohtools: move code from hail.hs to IAllocator.hs
Iustin Pop [Sat, 2 Jul 2011 06:12:18 +0000 (08:12 +0200)]
htools: move code from hail.hs to IAllocator.hs

This will make it easier to unittest the code, and keeps all login in a
single module.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

13 years agohtools: add parsing of input node-evac messages
Iustin Pop [Thu, 30 Jun 2011 10:05:21 +0000 (12:05 +0200)]
htools: add parsing of input node-evac messages

This is a lot of duplication with modeMreloc, which will get sorted
out once we convert mreloc to change-group.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

13 years agohtools: remove pre-2.4 compatibility from RAPI
Iustin Pop [Mon, 4 Jul 2011 14:20:38 +0000 (16:20 +0200)]
htools: remove pre-2.4 compatibility from RAPI

This was potentially hiding issues in the group query, so let's remove
it since we're now bound to the current Ganeti version.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

13 years agohtools: introduce new data type for node-evac
Iustin Pop [Wed, 29 Jun 2011 16:02:44 +0000 (18:02 +0200)]
htools: introduce new data type for node-evac

The evac-mode goes into the Types.hs module since it needs to be
available to Cluster.hs too.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

13 years agohtools: docstring fixes and improvements
Iustin Pop [Mon, 4 Jul 2011 14:05:47 +0000 (16:05 +0200)]
htools: docstring fixes and improvements

No code changes (except one definition being moved around in QC.hs)
are contained in this patch.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

13 years agoFix some issues in htools apidoc generation
Iustin Pop [Sun, 3 Jul 2011 21:36:53 +0000 (23:36 +0200)]
Fix some issues in htools apidoc generation

First, auto-generated files were not processed if HsColour thus the
'source' link in Haddock documentation was dangling.

Second, we document the original Python constant name in the
Ganeti.Constants source, so that it's easily retrievable (as opposed
to undoing the name transformation).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

13 years agoReplace an mkdir -p with @mkdir_p@ in Makefile.am
Iustin Pop [Fri, 8 Jul 2011 09:59:36 +0000 (11:59 +0200)]
Replace an mkdir -p with @mkdir_p@ in Makefile.am

Oops, this shouldn't have gone in in the first place…

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

13 years agoExclude auto-generated Haskell code from coverage
Iustin Pop [Sat, 2 Jul 2011 19:45:12 +0000 (21:45 +0200)]
Exclude auto-generated Haskell code from coverage

Especially for Ganeti.Constants, which has many declarations, it
doesn't make sense to check for coverage.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

13 years agoUpdate multi-reloc design doc with enhanced results
Iustin Pop [Thu, 7 Jul 2011 13:25:43 +0000 (15:25 +0200)]
Update multi-reloc design doc with enhanced results

In order to increase the amount of information returned from the
IAllocator plugin, we enhance the return values from the node-evac and
change-group operations.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

13 years agognt-cluster {command|copyfile}: Support per-group operations
Michael Hanselmann [Mon, 11 Jul 2011 21:49:30 +0000 (23:49 +0200)]
gnt-cluster {command|copyfile}: Support per-group operations

This patch allows commands to be run on and files to be copied to all
nodes within a specific group.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agocli.GetOnlineNodes: Support node group filter, use query2
Michael Hanselmann [Mon, 11 Jul 2011 21:48:12 +0000 (23:48 +0200)]
cli.GetOnlineNodes: Support node group filter, use query2

This patc changes cli.GetOnlineNodes to use query2, which does the
filtering in the master daemon, and adds a new parameter to filter by
node group.

Unittests were added for the old implementation and then adopted to
ensure no functionality was lost.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agoRemove references to multi-relocate from iallocator doc
Michael Hanselmann [Mon, 11 Jul 2011 19:00:09 +0000 (21:00 +0200)]
Remove references to multi-relocate from iallocator doc

For some reason these were still in tere.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agoht.WithDesc: Work around pylint warning
Michael Hanselmann [Fri, 8 Jul 2011 22:26:27 +0000 (00:26 +0200)]
ht.WithDesc: Work around pylint warning

Explicitely defining “__call__” silences a pylint warning when wrapped
type check functions are used directly. I had no idea pylint is this
intelligent.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agoMerge branch 'devel-2.4'
Michael Hanselmann [Mon, 11 Jul 2011 14:50:27 +0000 (16:50 +0200)]
Merge branch 'devel-2.4'

* devel-2.4:
  ht: Add new check for numbers
  Fix off-by-one bug in job serial generation
  Shorten some unbreakable lines in man pages
  Correct some spelling mistakes
  Fix bug in recreate-disks for DRBD instances
  Fix a lint warning
  KVM: configure bridged NICs at migration start
  Fix RAPI documentation regarding master role
  Fix bug in drbd8 replace disks on current nodes

Conflicts:
lib/cmdlib.py: Trivial
lib/opcodes.py: Trivial

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agoht: Add new check for numbers
Michael Hanselmann [Fri, 8 Jul 2011 19:33:16 +0000 (21:33 +0200)]
ht: Add new check for numbers

Places which receive floats can usually also deal with integers, e.g.
OpTestDelay. Tests are added and the new check function is used for the
aforementioned opcode and verifying query results.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agoFix off-by-one bug in job serial generation
Michael Hanselmann [Thu, 7 Jul 2011 19:10:20 +0000 (21:10 +0200)]
Fix off-by-one bug in job serial generation

Commit 009e73d0 (September 2009) changed the job queue to generate
multiple job serials at once. Ever since it would return one more than
requested.

The “serial” file in the job queue directory is defined to contain the
“last job ID used” (design-2.0). With the change above, the serial file
would always contain the next serial number. The first value returned by
the generating function was the one contained in the file, so during the
switch in 2009 one job may have been overwritten.

This patch changes the code to always return the exact number of
serials, to keep the last used serial on disk and adds an assertion.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agoReverts the patch series about console wrappers
Iustin Pop [Mon, 11 Jul 2011 13:42:17 +0000 (15:42 +0200)]
Reverts the patch series about console wrappers

This reverts commits 030a9cb8022b83bf43ec14dfbafd943299bc01c4 and
ae082df0000a785b693b2f4aa434650a81a94bdf.

There are two problems:

- Makefile.am breakage, which is trivial to revert
- unittest breakage, which honestly I'm not sure how to fix and how
  serial consoles interact with the unpause helper

After the reset, the startup --paused still works but won't unpause
the instance automatically (if I understood the code correctly).

Furthermore, the code also fixes a style issue in hv_kvm.py (too long
line) introduced by the next commit after the above two.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

13 years agoAdd gnt-instance start --pause
Stephen Shirley [Thu, 23 Jun 2011 15:15:28 +0000 (17:15 +0200)]
Add gnt-instance start --pause

Creates the instance, but pauses execution before booting. This combined
with 'gnt-instance console' unpausing instances means that the entire
boot process can be viewed and monitored.

Signed-off-by: Stephen Shirley <diamond@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

13 years agoAdding a wrapper around connecting to kvm console
Stephen Shirley [Fri, 24 Jun 2011 11:29:48 +0000 (13:29 +0200)]
Adding a wrapper around connecting to kvm console

The wrapper will connect to the console, and check in the background if
the instance is paused, unpausing it as necessary.

Signed-off-by: Stephen Shirley <diamond@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

13 years agoAdding a wrapper around "xm console"
Stephen Shirley [Thu, 23 Jun 2011 09:42:23 +0000 (11:42 +0200)]
Adding a wrapper around "xm console"

The wrapper will connect to the console, and check in the background if
the instance is paused, unpausing it as necessary.

Signed-off-by: Stephen Shirley <diamond@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

13 years agoFix lint error
Michael Hanselmann [Tue, 5 Jul 2011 22:54:42 +0000 (00:54 +0200)]
Fix lint error

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

13 years agoRAPI: Document all feature strings
Michael Hanselmann [Mon, 27 Jun 2011 22:13:23 +0000 (00:13 +0200)]
RAPI: Document all feature strings

- Use constants and an assertion
- Update documentation for node migration

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agoRemove old node evacuation opcode
Michael Hanselmann [Mon, 23 May 2011 13:58:29 +0000 (15:58 +0200)]
Remove old node evacuation opcode

LUNodeEvacStrategy has been replaced with LUNodeEvacuate.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

13 years agoChange RAPI for new node evacuation opcode
Michael Hanselmann [Mon, 23 May 2011 12:43:33 +0000 (14:43 +0200)]
Change RAPI for new node evacuation opcode

The change is not backwards compatible, see the updated NEWS file.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

13 years agoChange “gnt-node evacuate” to use new opcode
Michael Hanselmann [Fri, 20 May 2011 14:31:54 +0000 (16:31 +0200)]
Change “gnt-node evacuate” to use new opcode

By default it'll now evacuate all instances from the node, not
just secondaries.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

13 years agoAdd new opcode to evacuate node
Michael Hanselmann [Fri, 20 May 2011 13:30:33 +0000 (15:30 +0200)]
Add new opcode to evacuate node

This new opcode will replace LUNodeEvacStrategy, which used to return a
list of instances and new secondary nodes. With the new opcode the
iallocator (if available) is tasked to generate the necessary operations
in the form of opcodes. This moves some logic from the client to the
master daemon.

At the same time support is added to evacuate primary instances, which
are also evacuated by default.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

13 years agoAlias gnt-job show to gnt-job info
Guido Trotter [Tue, 5 Jul 2011 16:35:25 +0000 (17:35 +0100)]
Alias gnt-job show to gnt-job info

Am I the only one to make that mistake 10 times a week?

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agoOne Haskell and integer sizes fix
Iustin Pop [Wed, 29 Jun 2011 13:06:12 +0000 (15:06 +0200)]
One Haskell and integer sizes fix

Haskell has two main integer types:

- Int, which is a native-type, and is guaranteed to have at least
  [-2²⁹, 2²⁹-1] range; on 64-bit platforms, it has much higher range
- Integer, which is a software type (implemented using libgmp), and
  thus unbounded

For performance reasons, the node/instance properties use Int for
their attributes (and Double for some, but that's another story). This
is all fine and doesn't cause problems. However, the CStats type which
holds the overall cluster resources starts to fail when we analyse
clusters with more than around 400 nodes and big memory/disk sizes on
32 bit platforms.

The simple fix would be to restrict cluster sizes, but that's no
nice. I've benchmarked and changing to Integer doesn't show a visible
slowdown on 64-bit platforms (as far as I can read on the internets,
GHC knows to optimise Integer and only use software types when the
values are large enough), and it also fixes the 32-bit problem. So
this patch changes the CStats types to Integer, except for the
instance count (which I don't expect to overflow 2²⁹ anytime soon).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

13 years agoFix cluster verify for empty node groups
Iustin Pop [Fri, 1 Jul 2011 10:25:26 +0000 (12:25 +0200)]
Fix cluster verify for empty node groups

There were some implicit assertions in the code that all node groups
have nodes, which is not necessarily true.

Additionally, the patch does a wrapping change.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

13 years agoFix a typo and punctuation in iallocator.rst
Iustin Pop [Thu, 30 Jun 2011 11:19:42 +0000 (13:19 +0200)]
Fix a typo and punctuation in iallocator.rst

Beside the 'dscription' typo, also make the punctuation more
consistent.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

13 years agoShorten some unbreakable lines in man pages
Iustin Pop [Thu, 30 Jun 2011 15:15:51 +0000 (17:15 +0200)]
Shorten some unbreakable lines in man pages

In order to make the display right on 80-columns terminals.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

13 years agoCorrect some spelling mistakes
Iustin Pop [Thu, 30 Jun 2011 15:07:34 +0000 (17:07 +0200)]
Correct some spelling mistakes

New lintian is even smarter:

- overriden → overridden
- allows to → allows one to

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

13 years agoFix htools, QuickCheck library detection and tests
Iustin Pop [Tue, 28 Jun 2011 16:12:54 +0000 (18:12 +0200)]
Fix htools, QuickCheck library detection and tests

Just saw this while testing the migration to QuickCheck v2: while
configure.ac detects that QuickCheck-2.x is not available, the test in
Makefile.am was against WANT_HTOOLS (overall htools compilation), not
on a more-specific WANT_HTOOLSTESTS.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

13 years agohtools: fix prop_Node_rMem corner case
Iustin Pop [Mon, 20 Jun 2011 13:29:52 +0000 (15:29 +0200)]
htools: fix prop_Node_rMem corner case

This patch fixes a bug in the test specification where we allowed nodes
with zero free memory (hence no instance can be added, at all) and adds
a simple labeling of the way this test can fail.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

13 years agohtools: fix corner case in prop_Text_Load_Instance
Iustin Pop [Mon, 20 Jun 2011 13:28:57 +0000 (15:28 +0200)]
htools: fix corner case in prop_Text_Load_Instance

This unittest had a corner case where it could fail if the same
primary/secondary node names were generated.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

13 years agohtools: allow unittest to be replayed
Iustin Pop [Mon, 20 Jun 2011 13:04:59 +0000 (16:04 +0300)]
htools: allow unittest to be replayed

This just adds glue to allow replaying of tests using a given RNG state
and test size (both are needed for exact replayability).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

13 years agohtools: improve more unittests
Iustin Pop [Sun, 19 Jun 2011 21:56:31 +0000 (00:56 +0300)]
htools: improve more unittests

Using new functionality in QuickCheck 2 (the suchThat function), we
generate now better test cases, such that (heh) we have no longer
incomplete tests.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

13 years agohtools: more fixes to unsatisfiable tests
Iustin Pop [Sun, 19 Jun 2011 21:43:42 +0000 (00:43 +0300)]
htools: more fixes to unsatisfiable tests

Currently the way we generate nodes in some cases is by creating a
totally random node, then restricting the test based on whether the node
'size' (as defined by multiples of base unit) satifies some high/low
rules. This results in hard-to-satisfy conditions, so we change this
model to be able to specify node sizes directly in the generation
process, thus no longer needed post-creation filters.

This fixes prop_ClusterAllocBalance which before had at most 1-2
satisfiable tests.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

13 years agohtools: Rework some unittests
Iustin Pop [Sun, 19 Jun 2011 21:11:51 +0000 (00:11 +0300)]
htools: Rework some unittests

The new scaffolding which replaced the batch driver of QuickCheck 1 now
shows how many passes we have for incomplete tests. Some tests show very
low pass counts, so we rework them to have more actually valid test
cases.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

13 years agohtools: Switch to QuickCheck 2.x
Iustin Pop [Sun, 19 Jun 2011 20:46:15 +0000 (23:46 +0300)]
htools: Switch to QuickCheck 2.x

Since current distros don't package anymore QuickCheck 1.x, let's move
to 2.x.

This requires also a few changes to the code:

- Test.QuickCheck.Batch doesn't exist anymore, so we need to write some
  scaffolding code to replace it
- the way test sizes are generated has changed, and we need to restrict
  (in some tests) the cluster size, as our code is not yet ready for
  hundreds of thousands of nodes in a cluster and we run out of stack
  (which could be a bug somewhere by itself, needs investigation)
- at least with GHC 7, floating point errors make a perfect cluster
  score even bigger, so we need to bump up the max. rounding error
  allowed

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

13 years agohtools: some lint fixes
Iustin Pop [Sun, 19 Jun 2011 10:38:32 +0000 (13:38 +0300)]
htools: some lint fixes

Removal of duplicate parantheses, removal of extra 'do', conversion from
nested if to guards, use hierarchical imports. All per hlint.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

13 years agohtools: rewrite Cluster.filterMGResults
Iustin Pop [Sun, 19 Jun 2011 02:46:58 +0000 (05:46 +0300)]
htools: rewrite Cluster.filterMGResults

filterMGResults was built using a sequence of map and filter calls;
while this was logically correct, it used some incomplete pattern
matching which with the new GHC 7 triggers a warning.

The patch rewrites it using a single foldl that does both the filtering
and the mapping, in a more type-safe way.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

13 years agohtools: use the new Group.isAllocable
Iustin Pop [Sun, 19 Jun 2011 02:48:05 +0000 (05:48 +0300)]
htools: use the new Group.isAllocable

… instead of the hardcoded test against AllocUnallocable.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

13 years agohtools: add a helper function
Iustin Pop [Sat, 18 Jun 2011 15:32:39 +0000 (17:32 +0200)]
htools: add a helper function

… that checks if a group is allocable.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

13 years agoFix bug in recreate-disks for DRBD instances
Iustin Pop [Tue, 28 Jun 2011 12:24:45 +0000 (14:24 +0200)]
Fix bug in recreate-disks for DRBD instances

The new functionality in 2.4.2 for recreate-disks to change nodes is
broken for DRBD instances: it simply changes the nodes without caring
for the DRBD minors mapping, which will lead to conflicts in non-empty
clusters.

This patch changes Exec() method of this LU significantly, to both fix
the DRBD minor usage and make sure that we don't have partial
modification to the instance objects:

- the first half of the method makes all the checks and computes the
  needed configuration changes
- the second half then performs the configuration changes and
  recreates the disks

This way, instances will either be fully modified or not at all;
whether the disks are successfully recreate is another point, but at
least we'll have the configuration sane.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

13 years agoFix a lint warning
Iustin Pop [Tue, 28 Jun 2011 12:41:28 +0000 (14:41 +0200)]
Fix a lint warning

Patch db8e5f1c removed the use of feedback_fn, hence pylint warn
now.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

13 years agoKVM: configure bridged NICs at migration start
Apollon Oikonomopoulos [Wed, 22 Jun 2011 09:03:41 +0000 (12:03 +0300)]
KVM: configure bridged NICs at migration start

Commit 5d9bfd870 moved tap interface handling from KVM to Ganeti, partly
to also solve the problem of routed interfaces getting configured too
early during live migrations, causing network anomalies. In that
direction, configuration of NICs of incoming instances was deferred to
FinalizeMigration time.

However, this causes minor issues with bridged interfaces; KVM sends out
an ARP-like packet upon migration finish, which is lost because the tap
interface is not yet configured. As a consequence, intermediate network
equipment (i.e. switches) does not get notified about the topology
change, until the instance transmits another packet after the bridge has
been configured, or the switch's ARP cache expires.

The proper solution to that is to support different phases in network
configuration (pre/post migration), which also requires separate ifup
scripts. Until then we fall back to configuring bridged interfaces on
incoming instances at migration start, instead of finish.

Signed-off-by: Apollon Oikonomopoulos <apollon@noc.grnet.gr>
Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

13 years agoFix RAPI documentation regarding master role
Iustin Pop [Mon, 27 Jun 2011 10:54:28 +0000 (12:54 +0200)]
Fix RAPI documentation regarding master role

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

13 years agoFix bug in drbd8 replace disks on current nodes
Iustin Pop [Fri, 10 Jun 2011 14:44:03 +0000 (16:44 +0200)]
Fix bug in drbd8 replace disks on current nodes

Currently the drbd8 replace-disks on the same node (i.e. -p or -s) has
a bug in that it does modify the instance disk temporarily before
changing it back to the same value. However, we don't need to, and
shouldn't do that: what this operation do is simply change the LVM
configuration on the node, but otherwise the instance disks keep the
same configuration as before.

In the current code, this change back-and-forth is fine *unless* we
fail during attaching the new LVs to DRBD; in which case, we're left
with a half-modified disk, which is entirely wrong.

So we change the code in two ways:

- use temporary copies of the disk children in the old_lvs var
- stop updating disk.children

Which means that the instance should not be modified anymore (except
maybe for SetDiskID, which is a legacy and unfortunate decision that
will have to cleaned up sometime).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

13 years agoEnable using ghc parallel version 3
Guido Trotter [Thu, 9 Jun 2011 09:28:08 +0000 (10:28 +0100)]
Enable using ghc parallel version 3

Currently htools cannot be compiled under sid because the parallel
haskell library is version 3. Using it issues a few warning, but
compiles and passes unit tests. Ship it?

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agoMerge branch 'devel-2.4'
Guido Trotter [Thu, 23 Jun 2011 13:56:00 +0000 (14:56 +0100)]
Merge branch 'devel-2.4'

* devel-2.4:
  LUInstanceCreate: use opcodes.RequireFileStorage
  Don't add ",boot=on" to disks on kvm >= 0.14
  KVM: fix per-instance stored UID value

Conflicts:
lib/cmdlib.py
          - use RequireSharedFileStorage there

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

13 years agoremove bootstrap._InitSharedFileStorage
Guido Trotter [Fri, 17 Jun 2011 14:27:36 +0000 (17:27 +0300)]
remove bootstrap._InitSharedFileStorage

This function is a copy of bootstrap._InitFileStorage with the following
differences:
  - check constants.ENABLE_SHARED_FILE_STORAGE and not
    constants.ENABLE_FILE_STORAGE
  - use different local variable names
  - one different error string

Thus:
  - move the constant check outside of the function call
  - change error string so it's clear where the error is
  - call the same function twice

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agoLUInstanceCreate: use opcodes.RequireFileStorage
Guido Trotter [Wed, 22 Jun 2011 13:14:27 +0000 (14:14 +0100)]
LUInstanceCreate: use opcodes.RequireFileStorage

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

13 years agoDon't add ",boot=on" to disks on kvm >= 0.14
Guido Trotter [Thu, 9 Jun 2011 09:01:30 +0000 (09:01 +0000)]
Don't add ",boot=on" to disks on kvm >= 0.14

Under newer kvm this prevents the vm from starting.
Ah, change!

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

13 years agoKVM: fix per-instance stored UID value
Apollon Oikonomopoulos [Wed, 22 Jun 2011 15:41:29 +0000 (18:41 +0300)]
KVM: fix per-instance stored UID value

When using the pool security model, _ExecuteKVMRuntime was storing the
instance's UID using str(uid), which would result in storing the
LockedUid.__repr__() result:

 $ cat /var/run/ganeti/kvm-hypervisor/uid/xxxxxxxxxxxxx
 <ganeti.uidpool.LockedUid object at 0x1f30610>

This patch restores the intended behaviour, by using LockedUid.AsStr().

Signed-off-by: Apollon Oikonomopoulos <apollon@noc.grnet.gr>
Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

13 years agoMerge branch 'devel-2.4'
Guido Trotter [Fri, 17 Jun 2011 12:57:41 +0000 (15:57 +0300)]
Merge branch 'devel-2.4'

* devel-2.4:
  Add one forgotten element to the file disk path

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

13 years agoAdd one forgotten element to the file disk path
Guido Trotter [Fri, 17 Jun 2011 11:44:55 +0000 (14:44 +0300)]
Add one forgotten element to the file disk path

This was left out during the fix/refactoring

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

13 years agoMerge branch 'devel-2.4'
Guido Trotter [Fri, 17 Jun 2011 11:30:51 +0000 (14:30 +0300)]
Merge branch 'devel-2.4'

* devel-2.4:
  LUInstanceCreate: fix file storage dir calculation
  Check that filestorage is enabled when requested
  Remove self.op.file_storage_dir isabs check

Conflicts:
lib/cmdlib.py
          - use constants.DTS_FILEBASED
          - handle DT_SHARED_FILE correctly

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

13 years agoAdd DTS_FILEBASED constant
Guido Trotter [Fri, 17 Jun 2011 09:19:44 +0000 (12:19 +0300)]
Add DTS_FILEBASED constant

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

13 years agoLUInstanceCreate: fix file storage dir calculation
Guido Trotter [Fri, 17 Jun 2011 09:39:43 +0000 (12:39 +0300)]
LUInstanceCreate: fix file storage dir calculation

- Move the calculation at the beginning of CheckPrereq, since it doesn't
  modify any state, but still keeps locks
- Only perform the calculation if the actual disk template is filebased
- Error out if there is no defined file storage dir
- Only join the optional --file-storage-dir extra-path if one is passed

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

13 years agoCheck that filestorage is enabled when requested
Guido Trotter [Fri, 17 Jun 2011 09:23:51 +0000 (12:23 +0300)]
Check that filestorage is enabled when requested

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

13 years agoRemove self.op.file_storage_dir isabs check
Guido Trotter [Fri, 17 Jun 2011 09:16:58 +0000 (09:16 +0000)]
Remove self.op.file_storage_dir isabs check

As the manpage says, and the code does, self.op.file_storage_dir is an
additional relative path under the cluster file storage dir. As such it
should not be absolute.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

13 years agohtools live test: test instance selection as well
Guido Trotter [Fri, 10 Jun 2011 13:24:49 +0000 (14:24 +0100)]
htools live test: test instance selection as well

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years ago--select-instances hbal manpage update
Guido Trotter [Fri, 10 Jun 2011 12:27:12 +0000 (12:27 +0000)]
--select-instances hbal manpage update

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agoCheck that the selected instances are known
Guido Trotter [Mon, 13 Jun 2011 12:01:08 +0000 (12:01 +0000)]
Check that the selected instances are known

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agoLoader.updateMovable: evaluate selected instances
Guido Trotter [Mon, 13 Jun 2011 11:44:58 +0000 (11:44 +0000)]
Loader.updateMovable: evaluate selected instances

This also adds docstrings for the function arguments and renames exinst
to exinsts, which is how it is called in other functions, since it's a
list.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agoAdd instance selection list to Loader.mergeData
Guido Trotter [Fri, 10 Jun 2011 13:45:09 +0000 (14:45 +0100)]
Add instance selection list to Loader.mergeData

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agoAdd --select-instances hbal flag
Guido Trotter [Fri, 10 Jun 2011 13:44:30 +0000 (14:44 +0100)]
Add --select-instances hbal flag

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agoRemove double whitespace in help string
Guido Trotter [Fri, 10 Jun 2011 13:30:10 +0000 (14:30 +0100)]
Remove double whitespace in help string

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agoAdd gnt-network design doc
Apollon Oikonomopoulos [Thu, 16 Jun 2011 12:15:30 +0000 (15:15 +0300)]
Add gnt-network design doc

This design covers high level network block definition and pool
management.

Signed-off-by: Apollon Oikonomopoulos <apollon@noc.grnet.gr>
Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agoReplace iallocator's mreloc w/ change-group and node-evac
Michael Hanselmann [Tue, 14 Jun 2011 16:27:06 +0000 (18:27 +0200)]
Replace iallocator's mreloc w/ change-group and node-evac

This patch removes all occurrences of the “multi-relocate” iallocator
mode. Commit 25ee7fd845 updated the design document and introduced
separate modes, “change-group” and “node-evacuate”. The constants aren't
removed yet as they're still used by htools.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

13 years agoFix a couple of typos
Stephen Shirley [Mon, 6 Jun 2011 08:59:46 +0000 (10:59 +0200)]
Fix a couple of typos

Signed-off-by: Stephen Shirley <diamond@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agoMakefile: Add version check for iallocator.rst
Michael Hanselmann [Mon, 6 Jun 2011 15:18:30 +0000 (17:18 +0200)]
Makefile: Add version check for iallocator.rst

iallocator.rst contains the Ganeti version at the top.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agoUpdate iallocator design for node group-aware operations
Michael Hanselmann [Mon, 6 Jun 2011 15:10:43 +0000 (17:10 +0200)]
Update iallocator design for node group-aware operations

A while ago a new ``multi-relocate`` mode was proposed and documented.
As it turned out, the interface had some deficiencies. With this patch
The relocation modes are reduced to two and split into separate
iallocator request modes: node-evacuate and change-group. Some request
and response requirements are clarified in the documentation.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agojqueue: Allow loading of archived jobs
Michael Hanselmann [Wed, 1 Jun 2011 15:44:56 +0000 (17:44 +0200)]
jqueue: Allow loading of archived jobs

Chained jobs need to look at previous jobs, including archived ones. A
nice side-effect of this change is the ability to look at archived jobs
using “gnt-job info <id>” as long as the ID is known.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agoAdding basic abstraction layer for caching
René Nussbaumer [Tue, 31 May 2011 09:54:23 +0000 (11:54 +0200)]
Adding basic abstraction layer for caching

This includes an own simple cache implementation and an
interface to a memcache instance.

Signed-off-by: René Nussbaumer <rn@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

13 years agoFix _checkRsaPrivateKey for newer key generation
Guido Trotter [Thu, 9 Jun 2011 10:03:39 +0000 (10:03 +0000)]
Fix _checkRsaPrivateKey for newer key generation

Keys generated under debian sid just read "BEGIN PRIVATE KEY" rather
than "BEGIN RSA PRIVATE KEY".

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

13 years agoFix locking issues in LUClusterVerifyGroup
Michael Hanselmann [Tue, 7 Jun 2011 06:48:55 +0000 (08:48 +0200)]
Fix locking issues in LUClusterVerifyGroup

- Use functions in ConfigWriter instead of custom loops
- Calculate nodes only once instances locks are acquired, removes one
  potential race condition
- Don't retrieve lists of all node/instance information without locks
- Additionally move the end of the node time check window after the
  first RPC call--the second call isn't involved in checking the
  node time at all

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

13 years agocmdlib: Acquire BGL for LUClusterVerifyConfig
Michael Hanselmann [Tue, 7 Jun 2011 05:17:09 +0000 (07:17 +0200)]
cmdlib: Acquire BGL for LUClusterVerifyConfig

LUClusterVerifyConfig verifies a number of configuration settings. For
doing so, it needs a consistent list of nodes, groups and instances. So
far no locks were acquired at all (except for the BGL in shared mode).
This is a race condition (e.g. if a node group is added in parallel) and
can be fixed by acquiring the BGL in exclusive mode. Since this LU
verifies the cluster-wide configuration, doing so instead of acquiring
individual locks is just.

Includes one typo fix and one docstring update.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

13 years agoExport/import instance tags
Michael Hanselmann [Tue, 7 Jun 2011 10:46:05 +0000 (12:46 +0200)]
Export/import instance tags

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

13 years agoFix issue with tags on instance creation
Michael Hanselmann [Tue, 7 Jun 2011 10:45:53 +0000 (12:45 +0200)]
Fix issue with tags on instance creation

Commit 720f56c85a added the ability to specify tags when creating an
instance. The “tags” attribute of an instance object needs to be a set,
but the patch's code saved it as a list, causing breakage in other parts
of Ganeti. This patch changes the code to use TaggableObject.AddTag,
which has a nice side-effect of doing some verification (including max.
number of tags). Instance import was also broken (no “tags” attribute in
options).

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

13 years agoFix incomplete merge
Iustin Pop [Fri, 3 Jun 2011 09:53:04 +0000 (11:53 +0200)]
Fix incomplete merge

Commit 66bd7445 changed the semantics of _JobProcessor on finished
jobs, and updated the related unittests in the 2.4 branch. It was then
merged to master, however on master there was an additional test for
this case, which was not updated.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

13 years agoExport instance tags to instance hooks
Apollon Oikonomopoulos [Tue, 31 May 2011 12:50:28 +0000 (15:50 +0300)]
Export instance tags to instance hooks

Instance hooks now get an INSTANCE_TAGS environment variable, which contains a
space-delimited list of the affected instance's tags.

Also update the documentation to reflect the change.

Signed-off-by: Apollon Oikonomopoulos <apollon@noc.grnet.gr>
Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agoAdd tagging option to gnt-instance create
Apollon Oikonomopoulos [Tue, 31 May 2011 12:49:58 +0000 (15:49 +0300)]
Add tagging option to gnt-instance create

Add TAG_ADD_OPT option to cli.py and use it in gnt-instance. Modify
cli.GenericInstanceCreate() accordingly.

Signed-off-by: Apollon Oikonomopoulos <apollon@noc.grnet.gr>
Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agoAdd tag handling to {Op,LU}InstanceCreate
Apollon Oikonomopoulos [Tue, 31 May 2011 12:49:28 +0000 (15:49 +0300)]
Add tag handling to {Op,LU}InstanceCreate

Add a tag slot to opcodes.OpInstanceCreate. We do not reuse _PTags, as this is
intended for OpTagsSet and thus:

  a) is not documented
  b) does not carry a default value, making it mandatory

Also pass the tags to the iallocator during instance creation.

Signed-off-by: Apollon Oikonomopoulos <apollon@noc.grnet.gr>
Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agohttp.client: Make debug log less noisy
Michael Hanselmann [Thu, 26 May 2011 14:40:50 +0000 (16:40 +0200)]
http.client: Make debug log less noisy

The HTTP client code generates quite a lot of debug log messages. With
this patch they're hidden unless explicitely enabled in the code.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agoMerge branch 'devel-2.4'
Michael Hanselmann [Wed, 1 Jun 2011 16:10:06 +0000 (18:10 +0200)]
Merge branch 'devel-2.4'

* devel-2.4:
  jqueue: Fix potential race condition when cancelling queued jobs
  Fix argument order in ReserveLV and ReserveMAC

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agohtools: introduce a type alias for JSON objects
Iustin Pop [Wed, 1 Jun 2011 14:51:39 +0000 (16:51 +0200)]
htools: introduce a type alias for JSON objects

This makes the type definitions a bit more readable/simpler.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

13 years agohail: stop using old-style 'nodes' key
Iustin Pop [Mon, 30 May 2011 12:13:13 +0000 (14:13 +0200)]
hail: stop using old-style 'nodes' key

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

13 years agohail: add parsing of multi-relocate request
Iustin Pop [Mon, 30 May 2011 11:50:49 +0000 (13:50 +0200)]
hail: add parsing of multi-relocate request

This is not handled yet, this patch just adds parsing of the incoming
request.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

13 years agohail: add option for displaying the parsed request
Iustin Pop [Mon, 30 May 2011 08:43:50 +0000 (10:43 +0200)]
hail: add option for displaying the parsed request

This can be used for debugging.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

13 years agohail: add new data types for the multi-reloc mode
Iustin Pop [Thu, 26 May 2011 13:24:36 +0000 (15:24 +0200)]
hail: add new data types for the multi-reloc mode

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

13 years agoAdd --no-instance-moves to the htools live tests
Guido Trotter [Tue, 31 May 2011 11:14:26 +0000 (13:14 +0200)]
Add --no-instance-moves to the htools live tests

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agoUpdate hbal manpage for --no-instance-moves
Guido Trotter [Tue, 31 May 2011 10:38:50 +0000 (12:38 +0200)]
Update hbal manpage for --no-instance-moves

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agoImplement balancing with no instance moves
Guido Trotter [Tue, 31 May 2011 14:57:51 +0000 (16:57 +0200)]
Implement balancing with no instance moves

Note that --no-disk-moves and --no-instance-moves are not incompatible,
but if both are used no solution can possibly exist.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agoPass the instance moves option in hbal
Guido Trotter [Tue, 31 May 2011 10:34:19 +0000 (10:34 +0000)]
Pass the instance moves option in hbal

While still being ignored, now it gets passed down to the iteration
function.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

13 years agoAdd --no-instance-moves cli htools option
Guido Trotter [Mon, 30 May 2011 14:10:13 +0000 (16:10 +0200)]
Add --no-instance-moves cli htools option

This option doesn't currently do anything.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>