ganeti-local
15 years agoRelease 2.0 beta 1 v2.0.0beta1
Iustin Pop [Mon, 26 Jan 2009 15:08:02 +0000 (15:08 +0000)]
Release 2.0 beta 1

Even though alpha started at 0, we release beta 1 first as we did for
1.2.

Reviewed-by: imsnah, ultrotter

15 years agoUpdate the NEWS documents for beta1
Iustin Pop [Mon, 26 Jan 2009 12:34:59 +0000 (12:34 +0000)]
Update the NEWS documents for beta1

Also import the NEWS entries from the 1.2 branch which were added since
we created it.

Reviewed-by: ultrotter

15 years agoXen and KVM: correct a typo when checking args
Guido Trotter [Fri, 23 Jan 2009 17:02:26 +0000 (17:02 +0000)]
Xen and KVM: correct a typo when checking args

A missing 'be' was present in the error string for both xen and kvm,
when the kernel or initrd path was not absolute.

Reviewed-by: imsnah

15 years agoSort the instance names in batcher
Iustin Pop [Fri, 23 Jan 2009 13:33:41 +0000 (13:33 +0000)]
Sort the instance names in batcher

In case we submit multiple instances via batcher, it's nicer to have the
sorted nicely.

Reviewed-by: imsnah

15 years agoFix batcher for 2.0-style disks and nics
Iustin Pop [Fri, 23 Jan 2009 13:33:32 +0000 (13:33 +0000)]
Fix batcher for 2.0-style disks and nics

This patch fixes the gnt-instance batch-create command, and in doing so
also slightly changes two other functions:
  - we change utils.ParseUnit so that it accepts integer values also
    (both ParseUnit(5) and ParseUnit("5") return the same value)
  - a bridge 'None' in LUCreateInstance will be converted to the default
    bridge; currently only missing bridges will be accepted to mean the
    default one

The main changes to batcher were the change to variable number of disks
and NICs.

The patch also adds a batcher-instances.json example file copied from
the 1.2 branch and properly modified.

Reviewed-by: imsnah, killerfoxi

15 years agoMake iallocator work with offline nodes
Iustin Pop [Fri, 23 Jan 2009 12:36:44 +0000 (12:36 +0000)]
Make iallocator work with offline nodes

This patch changes the iallocator framework to work with and properly
export to plugins offline nodes. It does this by only exporting the
static configuration data for those nodes, and not attempting to parse
the runtime data.

The patch also fixes bugs in iallocator related to the RpcResult
conversion, changes the should_run to admin_up attribute name (as per
the internals change), and adds “-I” as a short option for
“--iallocator” in gnt-instance, gnt-backup and burnin.

Reviewed-by: ultrotter

15 years agoRemove checking of DRBD metadata for validity
Iustin Pop [Fri, 23 Jan 2009 12:36:28 +0000 (12:36 +0000)]
Remove checking of DRBD metadata for validity

Currently the DRBD code checks that the metadata devices are valid
before creation, initial disk attachment and add children.

However, the process for checking validity requires a free DRBD minor,
and this conflict with parallel checking.

There are at least three possible solutions:
  - serialize all checks, which means we reduce parallelism and need
    extra locks
  - don't pass a valid minor number, but one like “/dev/drbd256” (which
    is invalid); this works for current version of DRBD, but since it's
    not guaranteed to remain so it doesn't look nice
  - don't do the checking at all, and rely on “drbdsetup ... disk ...”
    to fail by itself

The reason for checking metadata was that in 1.2, this was much cheaper
than trying to activate devices (and the subsequent iteration over the
minors). However, in 2.0, they have the same cost, so we can choose
option 3: just remove the explicit checking and rely on drbdsetup and
the kernel to fail.

Since DRBD8._InitMeta still requires a minor number, the two places
where this is run are handled as follows:
  - Create: we just use our own (unused currently) minor number
  - AddChildren: we keep using FindUnusedMinor, with the caveat that
    this function (used by replace-disks -n ...) cannot be yet
    parallelized

Reviewed-by: ultrotter

15 years agoRework the execution model in burnin
Iustin Pop [Fri, 23 Jan 2009 12:36:18 +0000 (12:36 +0000)]
Rework the execution model in burnin

This patch changes (significantly) the execution model in burnin:
  - for all runs, (almost) all instance mods in a single Burn* procedure
    are done as part of a job; so for example add disk, stop, remove
    disk, start are no longer done as separate jobs but as a single job
    consisting of four opcodes
  - for parallel runs, all Burn* procedures except the rename (which
    uses a single target name) run in parallel; before, only the
    creation was done in parallel
  - due to the single-job execution and also parallel execution, the
    logging messages are no longer happening synchronously with the
    execution, so they are more informative than an actual execution log

The end result is that burnin now tests properly multi-opcode jobs and
also tests all opcodes (except rename) for parallel execution.

Note: On a test cluster, parallelization reduces burnin time from 23m to
15m.

Reviewed-by: ultrotter

15 years agoRelax the restrictions on temporary DRBD minors
Iustin Pop [Fri, 23 Jan 2009 12:36:09 +0000 (12:36 +0000)]
Relax the restrictions on temporary DRBD minors

Currently the restrictions are too harsh: there is a time interval
between an instance gets a new disk and before it is added to the
configuration in which the restriction is not met. We solve this by
allowing temporary DRBD minors to match existing minors (for the same
instance), such that parallel creations/minor allocations are OK.

The change is done by moving the add of temporary minors to the
minor map after the instance minors are computed, and only considering
them as duplicate if the instance name doesn't match.

Reviewed-by: ultrotter

15 years agoIntroduce more configuration consistency checks
Iustin Pop [Fri, 23 Jan 2009 12:36:00 +0000 (12:36 +0000)]
Introduce more configuration consistency checks

This patch enhances the duplicate DRBD minors checks (currently just a
few) and adds automatic checks of configuration consistency at
configuration file writing time.

In order to do so and show meaningful error messages, the
_UnlockedComputeDRBDMap function is changed to not raise errors in case
of duplicates, but instead return both the minors map and the duplicate
list, and its callers now raise the error. This allows the VerifyConfig
function to return a complete list of duplicates.

The new checks required some small updates to the unittests for the
config module.

Reviewed-by: ultrotter

15 years agoFill the 'call' attribute of offline rpc results
Iustin Pop [Fri, 23 Jan 2009 10:15:55 +0000 (10:15 +0000)]
Fill the 'call' attribute of offline rpc results

When creating ‘fake’ results for offline nodes, we currently don't pass
the call attribute. This complicates debugging, so even though this
should not matter in practice, it's better to fix it.

Reviewed-by: imsnah

15 years agoA couple of small fixes to iallocator
Iustin Pop [Fri, 23 Jan 2009 09:13:44 +0000 (09:13 +0000)]
A couple of small fixes to iallocator

This removes some constraints:
  - only two disks supported, this is no longer true as the underlying
    functions can now compute size for a variable number of disks
  - error when the hypervisor was not being passed
  - typo error

Reviewed-by: imsnah

15 years agoluxi: close and reopen the socket on errors
Iustin Pop [Thu, 22 Jan 2009 16:39:40 +0000 (16:39 +0000)]
luxi: close and reopen the socket on errors

This is less of an actual issue for regular gnt-* clients, but it's
easily reproducible with burnin and possible with RAPI (depending on how
the program uses luxi.Client(s)).

In case of burnin, if we interrupt the client (^C) while it polls the
job, it will abort and raise an error. After that, burnin issues a
remove instance job, and at this point, we send the submit job (remove)
call but the first thing we read from the socket will be the response to
the previous poll job request, since that was queued already from the
master.

To solve this, whenever we detect an error in Transport.Call(), we close
that transport and re-create a new one, to start anew. The other
alternative would be to introduce a sequence to the protocol, but this
is something that would be design-level change and it's not recommended
at this stage.

Reviewed-by: imsnah

15 years agoShutdownInstance: log instance name, not object
Guido Trotter [Wed, 21 Jan 2009 18:23:59 +0000 (18:23 +0000)]
ShutdownInstance: log instance name, not object

When an instance fails to shut down we currently log its whole object,
rather than just the instance name.

Reviewed-by: iustinp

15 years agoKVM live migration: handle failure
Guido Trotter [Wed, 21 Jan 2009 18:23:44 +0000 (18:23 +0000)]
KVM live migration: handle failure

If the KVM live migration ends up in a 'failed' state it has been
aborted at the kvm level, and the machine is still running locally.
We support also the 'cancelled' state even though there should be no way
of reaching it, without manual intervention.

Reviewed-by: iustinp

15 years agoKVM: change a few IOError with EnvironmentError
Guido Trotter [Wed, 21 Jan 2009 18:23:29 +0000 (18:23 +0000)]
KVM: change a few IOError with EnvironmentError

Reviewed-by: iustinp

15 years agoKVM: instance migration
Guido Trotter [Wed, 21 Jan 2009 18:23:13 +0000 (18:23 +0000)]
KVM: instance migration

The tcp port used for migrating KVM instances is selectable at
./configure time. We use a single port as nodes are locked anyway during
a migration, so no two migrations can happen at the same time to the
same node.

Reviewed-by: iustinp

15 years agoKVM: add the _InstancePidAlive function
Guido Trotter [Wed, 21 Jan 2009 18:22:54 +0000 (18:22 +0000)]
KVM: add the _InstancePidAlive function

Throughout the kvm code we very often look for the instance pidfile
name, read it, and check if the process is alive. Abstract this into a
private function and use that one instead.

This patch also changes RebootInstance to check whether the instance is
alive before trying to reboot it.

Reviewed-by: iustinp

15 years agoKVM: fix RebootInstance
Guido Trotter [Wed, 21 Jan 2009 18:22:35 +0000 (18:22 +0000)]
KVM: fix RebootInstance

RebootInstance was broken, because it just used to call StartInstance
with wrong parameters. With this patch we still stop the instance, but
use the saved kvm runtime to start it again.

Reviewed-by: iustinp

15 years agoKVM: retry the instance shutdown command
Guido Trotter [Wed, 21 Jan 2009 18:22:17 +0000 (18:22 +0000)]
KVM: retry the instance shutdown command

When we ask the instance to shutdown sometimes the command won't work,
especially if the instance isn't fully booted up. We'll wait for a bit,
and give it a few chances before giving up.

Reviewed-by: iustinp

15 years agoXen: implement auxiliary migration functions
Guido Trotter [Wed, 21 Jan 2009 18:20:46 +0000 (18:20 +0000)]
Xen: implement auxiliary migration functions

These are used, for the xen hypervisor, to copy the xen config file to
the remote node. This breaks migration for instances which have been
migrated, but not restarted, with the old code, for which the config
file was just lost.

Reviewed-by: iustinp

15 years agoAutomatically release DRBD minors on success
Iustin Pop [Wed, 21 Jan 2009 14:15:39 +0000 (14:15 +0000)]
Automatically release DRBD minors on success

This patch converts the DRBD minors reservation protocol from explicit
release to automatic release on the success paths. On the errors paths,
it's still needed to manual release.

The patch doesn't bring much by itself, but is needed for a future patch
which enhances the automatic verification of configuration consistency.

Reviewed-by: ultrotter

15 years agoFix some more pylint errors
Iustin Pop [Wed, 21 Jan 2009 14:12:35 +0000 (14:12 +0000)]
Fix some more pylint errors

Two are real errors (invalid names) and one is style error (overriding
name from outer scope).

Reviewed-by: ultrotter

15 years agoOne more gitignore rule
Iustin Pop [Wed, 21 Jan 2009 10:48:23 +0000 (10:48 +0000)]
One more gitignore rule

This was forgotten in the recent “switch to explicit ignore rules”.

Reviewed-by: imsnah

15 years agoLog the rpc call name in the RPC errors message
Iustin Pop [Wed, 21 Jan 2009 10:48:15 +0000 (10:48 +0000)]
Log the rpc call name in the RPC errors message

Currently the rpc module logs the error description and target node in
rpc calls logging, as such:

  2009-01-21 00:50:01,456:  pid=1051/Thread-21 ERROR RPC error from node
    node1.example.com: Connection failed (111: Connection
    refused)

but this doesn't help to understand which call caused this (here it's an
offline node which should not be contacted at all).

This patch adds the logging of the call too, so cases like the above can
be debugged easier.

Reviewed-by: imsnah, ultrotter

15 years agoChange the instance status attribute to boolean
Iustin Pop [Wed, 21 Jan 2009 10:30:24 +0000 (10:30 +0000)]
Change the instance status attribute to boolean

Due to historic reasons, the “should run or not” attribute of an
instance was denoted by its “status” attribute having a string value of
either ‘up’ or ‘down’. Checking this is in code was done via hardcoding
of the strings.

This was long done for a redo, and this patch changes this attribute to
“admin_up” having a boolean value. The patch is in fact shorter than I
expected, and passes burnin.

The patch also fixes an error in BuildInstanceHookEnvByObject where the
instance.os was passed as the status value.

Reviewed-by: ultrotter

15 years agoImplement the new live migration backend functions
Guido Trotter [Wed, 21 Jan 2009 10:03:01 +0000 (10:03 +0000)]
Implement the new live migration backend functions

MigrationInfo, AcceptInstance and AbortMigration are implemented as
hypervisor specific functions, and by default they do nothing (as
they're not always necessary).

This patch also converts hv_base.MigrateInstance docstring to epydoc,
adds a missing @type to the GetInstanceInfo docstring, and removes an
unneeded empty line.

Reviewed-by: iustinp

15 years agoKVM: save and remove the KVM runtime
Guido Trotter [Wed, 21 Jan 2009 09:55:22 +0000 (09:55 +0000)]
KVM: save and remove the KVM runtime

At instance startup time we save the kvm runtime, and at stop time we
delete it. This patch also includes a function to load the kvm runtime,
which is unused yet.

Reviewed-by: iustinp

15 years agoKVM: split KVM runtime generation and startup
Guido Trotter [Wed, 21 Jan 2009 09:55:08 +0000 (09:55 +0000)]
KVM: split KVM runtime generation and startup

Before we used to generate the kvm command line and then just run it.
With this patch we split the generation from the time it is run,
allowing us to save it and replay it at reboot.

We must take special care about instance nics:
  - We can't include them in the saved command line, as they point to
    temporary files
  - We can't just generate them at exec time, because we would apply
    those changes, but not all the other ones, to a running instance,
    thus making it inconsistent (for example if an instance had a memory
    increased and one more nic, in a soft reboot we would add the nic, but
    not the memory)
So we'll just save the instance nic data at the time the kvm runtime
data is generated, and transform it into actual parameters at execution
time.

Reviewed-by: iustinp

15 years agoAdd calls in the intra-node migration protocol
Guido Trotter [Wed, 21 Jan 2009 09:54:11 +0000 (09:54 +0000)]
Add calls in the intra-node migration protocol

Currently the hypervisor is expected to do all the migration from the
source side. With this patch we also add the option of passing some
information to the target side, and starting some operation there.

As a bonus, a function to cleanup any started operation is included.

Reviewed-by: iustinp

15 years agoUpdate the objects.Disk formatting method
Iustin Pop [Wed, 21 Jan 2009 08:33:01 +0000 (08:33 +0000)]
Update the objects.Disk formatting method

With the addition of minors, this needs to show them too.

Reviewed-by: ultrotter

15 years agoKVM: add a _CONF_DIR
Guido Trotter [Tue, 20 Jan 2009 18:12:21 +0000 (18:12 +0000)]
KVM: add a _CONF_DIR

Currently we keep pid files and control files. In the conf dir we'll
also keep the data to start the instance anew, and the network
interface scripts. These will then be copied to a separate area (since
_CONF_DIR could be mounted 'noexec') and used to start the instance.

This patch also adds comments to state what the various directories are
used for.

Reviewed-by: iustinp

15 years agoKVM: Remove sockets after shutdown
Guido Trotter [Tue, 20 Jan 2009 18:12:01 +0000 (18:12 +0000)]
KVM: Remove sockets after shutdown

Abstract the monitor and serial socket naming in two functions, and
reuse them to cleanup the files after shutdown.

Reviewed-by: iustinp

15 years agoKVM: fix class docstring
Guido Trotter [Tue, 20 Jan 2009 18:11:48 +0000 (18:11 +0000)]
KVM: fix class docstring

Reviewed-by: iustinp

15 years agoXen: use epydoc in MigrateInstance docstring
Guido Trotter [Tue, 20 Jan 2009 18:11:35 +0000 (18:11 +0000)]
Xen: use epydoc in MigrateInstance docstring

Reviewed-by: iustinp

15 years agoShutdownInstance: report hypervisor error
Guido Trotter [Tue, 20 Jan 2009 17:50:42 +0000 (17:50 +0000)]
ShutdownInstance: report hypervisor error

When StopInstance raises an HypervisorError, report it in the logged
message to ease with debugging.

Reviewed-by: iustinp

15 years agoConfigObject docstring, close an open parenthesis
Guido Trotter [Tue, 20 Jan 2009 17:50:27 +0000 (17:50 +0000)]
ConfigObject docstring, close an open parenthesis

Reviewed-by: iustinp

15 years agoFix a typo in luxi's docstring
Guido Trotter [Tue, 20 Jan 2009 17:50:08 +0000 (17:50 +0000)]
Fix a typo in luxi's docstring

Reviewed-by: iustinp

15 years agoUpdate the logging output of job processing
Iustin Pop [Tue, 20 Jan 2009 17:19:58 +0000 (17:19 +0000)]
Update the logging output of job processing

(this is related to the master daemon log)

Currently it's not possible to follow (in the non-debug runs) the
logical execution thread of jobs. This is due to the fact that we don't
log the thread name (so we lose the association of log messages to jobs)
and we don't log the start/stop of job and opcode execution.

This patch adds a new parameter to utils.SetupLogging that enables
thread name logging, and promotes some log entries from debug to info.
With this applied, it's easier to understand which log messages relate
to which jobs/opcodes.

The patch also moves the "INFO client closed connection" entry to debug
level, since it's not a very informative log entry.

Reviewed-by: ultrotter

15 years ago.gitignore: Don't exclude whole /autotools/ dir, but only files
Michael Hanselmann [Tue, 20 Jan 2009 16:47:25 +0000 (16:47 +0000)]
.gitignore: Don't exclude whole /autotools/ dir, but only files

This way newly added files will be not be excluded by default. Fixes
also a small whitespace error in utils.py.

Reviewed-by: iustinp

15 years agoConvert RenameInstance to (status, data)
Iustin Pop [Tue, 20 Jan 2009 16:26:57 +0000 (16:26 +0000)]
Convert RenameInstance to (status, data)

This allows the rename failures to show the ouput of OS scripts.

Reviewed-by: ultrotter

15 years agoUpdate gitignore rules
Iustin Pop [Tue, 20 Jan 2009 16:26:46 +0000 (16:26 +0000)]
Update gitignore rules

As per Michael's comment, gitignore should not ignore a couple of real
files from the autotools/ directory.

Reviewed-by: ultrotter

15 years agoFix adding of disks to an instance
Iustin Pop [Tue, 20 Jan 2009 14:20:35 +0000 (14:20 +0000)]
Fix adding of disks to an instance

The ConfigWriter.AllocateDRBDMinor requires the instance name, not the
instance object. The LUSetInstanceParms is passing wrongly the instance
object, which can cause breakage.

The patch also adds asserts to check for this mismatch in ConfigWriter.

Reviewed-by: ultrotter

15 years agoFix burnin problems when using http checks
Iustin Pop [Tue, 20 Jan 2009 14:20:24 +0000 (14:20 +0000)]
Fix burnin problems when using http checks

The urllib2 module has very bad error handling. This patch changes to urllib
which is simpler, and we derive a custom class from the FancyURLopener. Burning
is no longer keeping sockets in CLOSE_WAIT state with this patch.

Reviewed-by: ultrotter

15 years agoMake cluster-verify check the drbd minors space
Iustin Pop [Tue, 20 Jan 2009 14:20:15 +0000 (14:20 +0000)]
Make cluster-verify check the drbd minors space

This patch adds support for verification of drbd minors space in cluster
verify: minors which belong to running instances and should be online
but are not, and minors which do not belong to any instace but are in
use.

The patch requires exposing some methods from bdev.DRBD8 and
config.ConfigWriter which were until now private methods.

Reviewed-by: ultrotter

15 years agoFix a couple of epydoc warnings
Iustin Pop [Tue, 20 Jan 2009 14:20:03 +0000 (14:20 +0000)]
Fix a couple of epydoc warnings

Reviewed-by: ultrotter

15 years agoDRBD: check for in-use minor during Create
Iustin Pop [Tue, 20 Jan 2009 11:18:31 +0000 (11:18 +0000)]
DRBD: check for in-use minor during Create

In order to prevent errors with old, in-use DRBD minors, we check and
abort at create time if our minor is already in use. For this we need to
also modify DRBD8Status to be able to parse cs:Unconfigured devices.

Reviewed-by: ultrotter

15 years agoAdd a TailFile function
Iustin Pop [Tue, 20 Jan 2009 11:18:20 +0000 (11:18 +0000)]
Add a TailFile function

This patch adds a tail file function, to be used for parsing and returning in
the job log OS installation failures.

Reviewed-by: ultrotter

15 years agoUnify some unittest functions
Iustin Pop [Tue, 20 Jan 2009 11:18:10 +0000 (11:18 +0000)]
Unify some unittest functions

This patch adds unified temporary file handling to the
testutils.GanetiTestCase class, which adds easy creation and automated
cleanup of temporary files.

The patch allows a simpler handling in a couple of test cases but
requires all child classes to call the parent setUp and tearDown
methods.

Reviewed-by: ultrotter

15 years agoSome small fixes in cmdlib
Iustin Pop [Tue, 20 Jan 2009 10:12:00 +0000 (10:12 +0000)]
Some small fixes in cmdlib

Reviewed-by: ultrotter

15 years agoConvert AddOSToInstance to (status, data)
Iustin Pop [Tue, 20 Jan 2009 10:11:48 +0000 (10:11 +0000)]
Convert AddOSToInstance to (status, data)

This allows the install and reinstall instance to return (hopefully)
relevant log files from the OS create scripts.

Reviewed-by: ultrotter

15 years agoConvert the start instance rpc to (status, data)
Iustin Pop [Tue, 20 Jan 2009 10:11:36 +0000 (10:11 +0000)]
Convert the start instance rpc to (status, data)

This will record the failure cause in starting up the instance in the
job log (and thus to the user).

Reviewed-by: ultrotter

15 years agoFix handling of failures in create instance disks
Iustin Pop [Mon, 19 Jan 2009 17:22:32 +0000 (17:22 +0000)]
Fix handling of failures in create instance disks

Commit 2302 only modified _CreateBlockDevOnPrimary to the new style
result, but _CreateBlockDevOnSecondary was forgotten. After the merger
of the two functions, _CreateBlockDevOnSecondary was taken as template
so we checked against old-style values, thus completely breaking error
handling.

Reviewed-by: imsnah

15 years agoMove the default MAC prefix to the constants file
Iustin Pop [Mon, 19 Jan 2009 14:35:03 +0000 (14:35 +0000)]
Move the default MAC prefix to the constants file

Instead of having the default live in the gnt-cluster script, we move it
to the constants file. The patch also fixes a typo on constants.py.

Reviewed-by: ultrotter

15 years agoUse instance.all_nodes instead of hand-building it
Iustin Pop [Mon, 19 Jan 2009 14:33:13 +0000 (14:33 +0000)]
Use instance.all_nodes instead of hand-building it

This patch replaces a few obvious uses of [instance.primary_node] +
list(instance.secondary_nodes) (or similar usage) with the new
instance.all_nodes.

Reviewed-by: ultrotter

15 years agoFix non-drbd instance creation
Iustin Pop [Mon, 19 Jan 2009 14:32:21 +0000 (14:32 +0000)]
Fix non-drbd instance creation

Commit 2294 introduced a new instance.all_nodes property, which
unfortunately is working incorrectly for non-drbd instances.

This patch fixes it by making sure the primary node is always added to
the set, even before recursing over (any potential) children.

Reviewed-by: imsnah

15 years agoSmall simplification in MapLVsByNode
Iustin Pop [Mon, 19 Jan 2009 11:10:52 +0000 (11:10 +0000)]
Small simplification in MapLVsByNode

We don't need to pre-create the node entries in lvmap, since they will
be created at recursion time.

Reviewed-by: ultrotter

15 years agoSplit the block device creation in two parts
Iustin Pop [Mon, 19 Jan 2009 11:10:42 +0000 (11:10 +0000)]
Split the block device creation in two parts

Some callers of _CreateBlockDev need recursive behaviour, but not all.
The replace secondary first creates (manually) new LVs to ensure storage
is there, and then it creates the new DRBD. At this point, we need a
non-recursive call so that the LVs are not needlessly re-created.

This patch splits the single device creation into a separate function,
so that LUReplaceDisks can use it.

Reviewed-by: ultrotter

15 years agoCombine the two _CreateBlockDevOnXXX functions
Iustin Pop [Mon, 19 Jan 2009 11:10:29 +0000 (11:10 +0000)]
Combine the two _CreateBlockDevOnXXX functions

Since only two boolean parameters differ between these two functions, we
combine them as to have less code duplication. This will be needed in
the future as we will need to split off the recursive part off.

Reviewed-by: ultrotter

15 years agoSwitch call_blockdev_create call to (status, data)
Iustin Pop [Mon, 19 Jan 2009 11:10:19 +0000 (11:10 +0000)]
Switch call_blockdev_create call to (status, data)

This allows errors to be visible at the user level instead of just node
daemon logs.

Reviewed-by: ultrotter

15 years agoSmall change in the instance disk creation path
Iustin Pop [Mon, 19 Jan 2009 11:10:10 +0000 (11:10 +0000)]
Small change in the instance disk creation path

For future propagation of error messages from backend to cmdlib and to
the job log, just having True/False return from the disk creation
function is not enough.

This patch converts these functions (_CreateDisks, _CreateBlockDevOnXXX)
to raise exception on errors, and otherwise the return value is None.

Reviewed-by: ultrotter

15 years agoBlock device creation cleanup
Iustin Pop [Mon, 19 Jan 2009 11:10:01 +0000 (11:10 +0000)]
Block device creation cleanup

Currently when creation LVM-based instances, we always get the
extremely-confusing message "ERROR Can't find LV /dev/xenvg/..." which
is actually expected. This behaviour was introduced before we had
UUID-style LV names, since at that point it was not a unexpected to have
such volumes laying around after a failed creation.

Today, it's much more of an error to see existing volumes, and it's
better to abort with a failure. Since bdev.LogicalVolume.Create() method
will raise an error in case it exists, we can remove this check in
backend before creating the device.

The Create methods for DRBD and FileStorage currently don't raise
exception, as behaviour is not very well defined here.

We also change some exception types raised in bdev so that all
exceptions raised by device creation are a subclass of GenericError.

Reviewed-by: ultrotter

15 years agoUse the same root for both _data and _meta LVs
Iustin Pop [Mon, 19 Jan 2009 10:43:11 +0000 (10:43 +0000)]
Use the same root for both _data and _meta LVs

Currently we use a different UUID for the _data and _meta volumes of a
DRBD disk. This is confusing as it's hard to associate the two in the
output of “lvs” or “gnt-node volumes”.

The patch changes so that they use the same prefix.

Reviewed-by: ultrotter

15 years agoFix LUExportInstance
Iustin Pop [Fri, 16 Jan 2009 16:24:26 +0000 (16:24 +0000)]
Fix LUExportInstance

Due to deficiencies in our block device implementation, it is a must to
call SetDiskID on disks before passing them to remote nodes. Since in
export/import, we don't touch the disks themselves, this was not needed
before in this function.

However, since having instance symlinks, the correct ID is needed here
too, and with static minors it's a "must need". This reflects into
failed instance starts after migration and/or failover.

Reviewed-by: ultrotter

15 years agoburnin: only call self.GrowDisks() if needed
Iustin Pop [Fri, 16 Jan 2009 13:09:43 +0000 (13:09 +0000)]
burnin: only call self.GrowDisks() if needed

In case we pass --disk-grow 0[,0..] then we should not call GrowDisks as it
prints confusing log lines.

Reviewed-by: imsnah

15 years agoInstance: add a new all_nodes property
Iustin Pop [Fri, 16 Jan 2009 11:02:57 +0000 (11:02 +0000)]
Instance: add a new all_nodes property

Since we often need the list of all nodes of an instance, we add a new
"all_nodes" property that returns all nodes of the instance, and we
switch secondary_nodes to a simpler implementation based on this new
function.

Reviewed-by: ultrotter

15 years agoFix gnt-backup export with short names
Iustin Pop [Fri, 16 Jan 2009 10:43:09 +0000 (10:43 +0000)]
Fix gnt-backup export with short names

We need to pass the fully-qualified node to _CheckNodeOnline, not the short
one.

Reviewed-by: imsnah

15 years agoburnin: add option to not remove instances
Iustin Pop [Fri, 16 Jan 2009 10:41:17 +0000 (10:41 +0000)]
burnin: add option to not remove instances

This patch adds a burnin option to keep instances at the end, so that
debugging after a burnin failure is easier.

Also, we reorder the command line parsing and client query so that one
can use ./tools/burnin --help even on non-ganeti machines.

Reviewed-by: ultrotter

15 years agoSome docstring updates
Iustin Pop [Thu, 15 Jan 2009 10:00:23 +0000 (10:00 +0000)]
Some docstring updates

This patch rewraps some comments to shorter lengths, changes
double-quotes to single-quotes inside triple-quoted docstrings for
better editor handling.

It also fixes some epydoc errors, namely invalid crossreferences (after
method rename), documentation for inexistent (removed) parameters, etc.

Reviewed-by: ultrotter

15 years agoganeti-noded: reduce log noise
Iustin Pop [Thu, 15 Jan 2009 10:00:12 +0000 (10:00 +0000)]
ganeti-noded: reduce log noise

The source port/addr is currently logged three times for each
connection, and this is unnecessary. We change two log entries to debug,
since they are useful for precise timing, and we keep only one at INFO
level.

Reviewed-by: imsnah

15 years agoburnin: update migration to latest log formatting
Iustin Pop [Wed, 14 Jan 2009 09:57:06 +0000 (09:57 +0000)]
burnin: update migration to latest log formatting

Reviewed-by: ultrotter

15 years agoForward port of the burnin migration
Iustin Pop [Tue, 13 Jan 2009 15:21:35 +0000 (15:21 +0000)]
Forward port of the burnin migration

This is again a copy of the latest 1.2 burnin code related to migration.

Reviewed-by: ultrotter

15 years agoForward port the live migration from 1.2 branch
Iustin Pop [Tue, 13 Jan 2009 15:21:22 +0000 (15:21 +0000)]
Forward port the live migration from 1.2 branch

This is forward port via copy (and not individual patches cherry-pick)
of the latest code on the 1.2 branch related to the migration.

The changes compared to 1.2 are the fact that we don't need the
IdentifyDisks step anymore (the drbd rpc calls are independent now), and
the rpc module improvements.

Reviewed-by: ultrotter

15 years agoPort replace disk/change node to the new DRBD RPCs
Iustin Pop [Tue, 13 Jan 2009 15:20:56 +0000 (15:20 +0000)]
Port replace disk/change node to the new DRBD RPCs

In replace disks to new secondary, since Attach (and therefore
call_blockdev_find) is not modifying the devices anymore, we need to
switch this LU to the new call_drbd_disconnect_net and
call_drbd_attach_net functions.

Due to the authentication needed in 2.0, we need to be more careful with
the activation order. In 1.2, we have the case that the new node was
directly activated with networking information, and could connect to the
primary while it was still connected or WFConnect to the old secondary.

In the new scheme, we:
  - create the new drbd in StandAlone mode
  - shutdown old secondary (primary becomes WFConnection)
  - disconnect primary (and thus it goes into StandAlone)
  - connect both primary and new secondary to network using the
    call_drbd_attach_net rpc

This should be safer, and is cleaner. This passes burnin.

Reviewed-by: ultrotter

15 years agoForward-port DrbdNetReconfig
Iustin Pop [Tue, 13 Jan 2009 15:20:44 +0000 (15:20 +0000)]
Forward-port DrbdNetReconfig

This is a modified forward-port of DrbdNetReconfig and their associated
RPCs. In Ganeti 2.0, these functions will be used for two things:
  - live migration (as in 1.2)
  - and for other network reconfiguration tasks, since DRBD8.Attach()
    doesn't do them anymore

Because of the Attach() changes, we can now implement the
AttachNet/DisconnectNet functions as independent entities, and we don't
need the cache anymore.

Note these functions are copies of the latest 1.2 code, and not
cherry-picks of the (many) patches that went into 1.2.

Reviewed-by: ultrotter

15 years agobackend: rename AttachOrAssemble to Assemble
Iustin Pop [Tue, 13 Jan 2009 15:20:25 +0000 (15:20 +0000)]
backend: rename AttachOrAssemble to Assemble

Since now the Assemble function is different than Attach, we rename this
backend function to show that the intent is to fully assemble the device
(and it's always allowed to modify the device).

Reviewed-by: ultrotter

15 years agodrbd: change the semantics of Attach vs. Assemble
Iustin Pop [Tue, 13 Jan 2009 15:20:12 +0000 (15:20 +0000)]
drbd: change the semantics of Attach vs. Assemble

Currently, both the Attach and Assemble methods for DRBD8 devices will use and
alter the device state. This is suboptimal, and it has been worked
around in 1.2 via a special cache in the node daemon so that we don't
need to call Attach() again in migration, for example.

Since in 2.0 we have static minors, we can change these functions so
that:
  - Attach() does not affect the device in any way, and only checks if
    the minor is already in use or not
  - Assemble() has two logic paths, one for startup from unused minor
    (the old Assemble, now renamed _FastAssemble) and one for
    re-checking/fixing an in-use minor (the old Attach, now renamed
    _SlowAttach)

Basically Attach was renamed to _SlowAttach, Assemble to _FastAssemble,
and we have a new, simple Assemble that calls one or the other based on
the result of the new Attach.

The LUReplaceDisks (with new secondary) is relying on the special
semantics of Attach modifying the device and is broken until the end of
the patch series.

Reviewed-by: ultrotter

15 years agobdev: Do not call Assemble() on children
Iustin Pop [Tue, 13 Jan 2009 15:20:00 +0000 (15:20 +0000)]
bdev: Do not call Assemble() on children

The caller of dev.Assemble() (backend._RecursiveAssembleBD) is doing an
explicit recursion over all the children of the device, with better
error reporting. As such, we don't need this repeated assembly inside
the base BlockDev class.

Reviewed-by: ultrotter

15 years agoFix modification of instance memory
Iustin Pop [Tue, 13 Jan 2009 14:43:12 +0000 (14:43 +0000)]
Fix modification of instance memory

... as found by the QA script - bug was introduced by me in commit 2117.

Reviwed-by: imsnah

15 years agoburnin: redo the output formatting
Iustin Pop [Tue, 13 Jan 2009 14:14:18 +0000 (14:14 +0000)]
burnin: redo the output formatting

Since we added many more tests in burnin, the output became almost
unreadable. This patch changes the output to an indented one, so that
the different phases and operations of burnin are more easily
understood.

Reviwed-by: ultrotter

15 years agoburnin: move start_stop at the end
Iustin Pop [Tue, 13 Jan 2009 13:25:58 +0000 (13:25 +0000)]
burnin: move start_stop at the end

Traditionally the start/stop test was the last, so move it back to there
(added as last option in commit 854).

Reviewed-by: amishchenko

15 years agoQA: add burnin parameters (parallel, http-check)
Iustin Pop [Tue, 13 Jan 2009 13:25:48 +0000 (13:25 +0000)]
QA: add burnin parameters (parallel, http-check)

This patch adds burnin parameters for --parallel and --http-check
options to the burnin script.

Reviewed-by: ultrotter

15 years agoIncrease resync speed to 60MB/s
Iustin Pop [Tue, 13 Jan 2009 13:16:41 +0000 (13:16 +0000)]
Increase resync speed to 60MB/s

This is a forward-port of commit 2219 on the 1.2 branch.

Reviewed-by: ultrotter

15 years agoburnin: introduce instance alive checks
Iustin Pop [Tue, 13 Jan 2009 13:03:44 +0000 (13:03 +0000)]
burnin: introduce instance alive checks

This patch adds instance alive checks after most start operations. The
check is done in a custom way:
  - the instance is expected to have an http server up and running
  - and it should server the '/hostname.txt' resource containing the
    hostname of the instance

This allows checking that:
  - creation is working OK
  - start after failover (and in the future migrate) is ok
  - rename works correctly

By default, the check is disabled since one needs a custom OS for this
check.

The patch also fixes a wrong variable name from a previous burnin patch.

Reviewed-by: ultrotter

15 years agoSmall typo in ganeti-watcher
Iustin Pop [Tue, 13 Jan 2009 08:04:40 +0000 (08:04 +0000)]
Small typo in ganeti-watcher

Reviewed-by: imsnah

15 years agoSkip offline nodes in gnt-cluster commands
Iustin Pop [Mon, 12 Jan 2009 16:06:14 +0000 (16:06 +0000)]
Skip offline nodes in gnt-cluster commands

This patch makes gnt-cluster copyfile and command skip the offline
nodes.

Reviwed-by: ultrotter, imsnah

15 years agoburnin: Add tests for add/remove disks and NICs
Iustin Pop [Mon, 12 Jan 2009 13:25:27 +0000 (13:25 +0000)]
burnin: Add tests for add/remove disks and NICs

This patch adds testing of add/remove disks and NICs to the burnin.

Reviewed-by: imsnah

15 years agoHeavy redo of gnt-instance info output
Iustin Pop [Mon, 12 Jan 2009 12:42:22 +0000 (12:42 +0000)]
Heavy redo of gnt-instance info output

In 2.0, we have more parameters in drbd's logical_id, and passing the
results over json makes them unicode which looks worse with the default
formatting. As such, a redo of the output is needed.

This patch:
  - adds a separate function to format the logical_id of devices
  - moves the actual indentation format out of _FormatBlockDevInfo,
    which now just generates a list of items
  - adds a function _FormatList that recursively formats the list
  - formats specially key,value tuples

The result is that the output is nicer, and the code in
_FormatBlockDevInfo somewhat cleaner (as it doesn't deal with spacing
and such issues).

Reviewed-by: ultrotter

15 years agoFix some errors in instance modify --disk remove
Iustin Pop [Mon, 12 Jan 2009 12:42:13 +0000 (12:42 +0000)]
Fix some errors in instance modify --disk remove

The RpcResult introduction still left some bugs (after multiple patches):
  - we don't correctly check the result type
  - rename a variable to prevent a conflict

Reviewed-by: imsnah

15 years agoFix an error handling case in instance info
Iustin Pop [Mon, 12 Jan 2009 10:27:02 +0000 (10:27 +0000)]
Fix an error handling case in instance info

The checking for invalid instance names in LUQueryInstanceData is broken
since commit 1642.

Reviewed-by: imsnah

15 years agoIntroduce a very simple LU to force config updates
Iustin Pop [Mon, 12 Jan 2009 09:14:50 +0000 (09:14 +0000)]
Introduce a very simple LU to force config updates

This LU can be used to force a push of the config in case it's needed,
for example after an upgrade to update the ssconf_release_version file.

Reviewed-by: imsnah

15 years agoAdd a new ssconf file with the ganeti version
Iustin Pop [Fri, 9 Jan 2009 16:24:05 +0000 (16:24 +0000)]
Add a new ssconf file with the ganeti version

The patch adds a new ssconf file containing the ganeti version.

Reviewed-by: imsnah

15 years agoWork around a DRBD sync speed race condition
Iustin Pop [Fri, 9 Jan 2009 15:34:25 +0000 (15:34 +0000)]
Work around a DRBD sync speed race condition

This is modified forward-port of commit 1544 on the 1.2 branch:

  When DRBD is doing its dance to establish a connection with its
  peer, it also sends the synchronization speed over the wire. In
  some cases setting the sync speed only after setting up both
  sides can race with DRBD connecting, hence we set it here before
  telling DRBD anything about its peer.

  Reviewed-by: iustinp

The modification we make is that we split SetSyncSpeed in two so that we
don't need to modify our minor temporarily, and the fact that we call
this function from within _AssembleNet (right before enabling network),
instead of Assemble()/Attach().

Original-Author: imsnah

15 years agoburnin: Add activate/deactivate disks
Iustin Pop [Fri, 9 Jan 2009 14:58:29 +0000 (14:58 +0000)]
burnin: Add activate/deactivate disks

Reviewed-by: imsnah

15 years agoburnin: use the new replace_disks constants
Iustin Pop [Fri, 9 Jan 2009 14:58:19 +0000 (14:58 +0000)]
burnin: use the new replace_disks constants

This patch updates burnin to the latest replace disks constant, and
changes the constants' values to be more accurate.

Reviewed-by: imsnah

15 years agoburnin: do not use offline nodes
Iustin Pop [Fri, 9 Jan 2009 14:26:53 +0000 (14:26 +0000)]
burnin: do not use offline nodes

This patch makes burnin skip the offline nodes in it's builtin node
selection. It also removes an extra line.

Reviewed-by: imsnah

15 years agoFix gnt-os for offline nodes
Iustin Pop [Fri, 9 Jan 2009 14:26:37 +0000 (14:26 +0000)]
Fix gnt-os for offline nodes

We shouldn't query offline nodes in gnt-os. This patch adds an utility
function to ConfigWriter that returns the names of online nodes and uses
it in LUDiagnoseOS to query only the good nodes.

Reviewed-by: imsnah

15 years agoSilence warning on node list for offline nodes
Iustin Pop [Fri, 9 Jan 2009 12:52:28 +0000 (12:52 +0000)]
Silence warning on node list for offline nodes

The warning in node list is meant for nodes that return wrong
information, but for offline nodes this case is normal.

Reviewed-by: imsnah

15 years agoRework the daemonization sequence
Iustin Pop [Fri, 9 Jan 2009 12:52:17 +0000 (12:52 +0000)]
Rework the daemonization sequence

The current fork+close fds sequence has deficiencies which are hard to
work around:
  - logging can start logging before we fork (e.g. if we need to emit
    messages related to master checking), and thus use FDs which we
    can't track nicely
  - the queue locks the queue file, and again this fd needs to be kept
    open which is hard from the main loop (and this error is currently
    hidden by the fact that we don't log it)

Given the above, it's much simpler, in case we will fork later, to close
file descriptors right at the beginning of the program, and in Daemonize
only close/reopen the stdin/out/err fds.

In addition, we also close() the handlers we remove in SetupLogging so
that the cleanup is more thorough.

Reviewed-by: imsnah

15 years agoCleanup replace-disks modes and options
Iustin Pop [Fri, 9 Jan 2009 12:22:51 +0000 (12:22 +0000)]
Cleanup replace-disks modes and options

In 1.2, due to the md+drbd7 legacy, we had a complex choice of replace
modes, and the new drbd8 modes where forced into this syntax, with some
complicated rules of transition from one mode to another (if REPLACE_ALL
but not new node passed, switch to REPLACE_SEC, etc.).

This patch cleans this situation by making a clear separation between
the two main modes:
  - replace on current nodes (with the two sub-cases on primary and on
    secondary)
  - change to a new node (either via manually specified node or via
    iallocator)

Reviewed-by: imsnah