Add and remove instance/node locks
Whenever we add an instance or node to the cluster (i.e. to the configand whenever we remove them we should add/remove locks as well). In thefuture we may want to optimize this so that the configwriter does it, orit's handled at the context level, but till we're adding/removing...
Pass context to LUs
Rather than passing a ConfigWriter to the LUs we'll pass the wholecontext, from which a ConfigWriter can be extracted, but we can alsoaccess the GanetiLockManager. This also fixes the places where a FakeLUis created.
Reviewed-by: iustinp
Fix a typo in LUTestDelay docstring
Locking: remove LEVEL_CONFIG lockset
Since the ConfigWriter now handles its own locking it's not necessary tohave a specific level for the config in the Locking Manager anymore.This patch thus removes it, and all the unittest calls that used it, ordepended on it being present....
ConfigWriter: synchronize access
Since we share the ConfigWriter we need somehow to make sure thataccessing it is properly synchronized. We'll do it using thelocking.ssynchronized decorator and a module-private shared lock.
This patch also renames a few functions, which were called inside the...
Locking: add ssynchronized decorator
This patch creates a new decorator function ssynchronized in the lockinglibrary, which takes as input a SharedLock, and synchronizes access tothe decorated functions using it. The usual SharedLock semantics apply,so it's possible to call more than one synchronized function at the same...
ConfigWriter: remove _ReleaseLock
Remove empty function _ReleaseLock and all its calls. Since we onlyhave one configwriter per cluster the locking needs to cover all thedata in the object, and not just the file contents. Locking inConfigWriter will be handled using the ganeti locking library....
Add generic worker pool implementation
Reviewed-by: ultrotter
Reuse the luxi client in cli.SubmitOpCode
By a mistake, we don't reuse the luxi client. As such, we open and closethe connection at each poll cycle and spam the server logs.
Add custom logging setup for daemons
It's better for daemons if: - they log only to one log file - the log level is included - for debug runs, the filename/line number is included
This patch moves the custom formatter from the watcher to the logging...
Context: s/GLM/glm/
Make the GanetiLockManager instance of GanetiContext lowercase
Reviewed-by: imsnah
Add a FirstFree function to utils.py
This function will return the first unused integer based on a list ofused integers (e.g. [0, 1, 3] will return 2).
Processor: acquire the BGL for LUs requiring it
If a LU required the BGL (all LUs do, right now, by default) we'llacquire it in the Processor before starting them. For LUs that don'twe'll still acquire it, but in a shared fashion, so that they cannot run...
Processor: pass context in and use it.
The processor used to create a new ConfigWriter when it was initialized.We now have one in the context, so we'll just recycle it. First of allwe'll pass the context in when creating a new Processor object, thenwe'll just use context.cfg, which is granted to be initialized, wherever...
Add REQ_BGL LogicalUnit run requirement
When logical units have REQ_BGL set (it is currently the default) theyneed to be the only ganeti operation run on the cluster, and we'llguarantee it at the master daemon level. Currently only one thread isrunning at a time, so this requirement is never broken....
Fix sstore handling in Processor
- no need to keep the sstore as an object member, remove it- don't reinitialize sstore only if self.cfg is None This is not an issue, as the Processor is recycled for every opcode, but in general we know that (a) we might need a different type of...
AddNode: move the initial setup to boostrap
From the master node we can't start ssh and connect to the remote node,nor we can do it from ganeti-noded as this ssh section will possibly askfor key confirmation and password. So the code to copy the ganeti-noded...
LUAddNode: use node-verify to check node hostname
As we can't use ssh.VerifyNodeHostname directly, we'll set up a mininode-verify to do checking between the master and the new node. In thefuture networking checks, or more nodes, can be added as well.
LUAddNode: use self.sstore, not a local ss
Since we're inside a LU we have access to self.sstore.No need to use ss, which separate instantiation will disappear in a fewpatches! ;)
LUAddNode: upload files via rpc, not scp
We used to scp all the ssconf files, and the vnc password file to thenew node. With this patch we use the upload_file rpc, specifying justthe new node as a destination. All the files previously copied by scpare already allowed by the backend....
Allow VNC_PASSWORD_FILE to be rpc-uploaded
What could possibly go wrong?
Change fping to TcpPing in two LUs
Two LUs are using RunCmd to call fping, in order to check for an IPpresence on the network. Substituting it with TcpPing will get rid ofit, which makes it not break in the new world order, where the mastercannot fork....
raise QuitGanetiException in LeaveCluster
Simplify QuitGanetiException instantiation
Rather than packing all the arguments in a tuple, let's pass themplainly. The superclass won't complain.
logger: Set formatter for stderr
Having a timestamp on log messages is very useful. The defaultformat string doesn't include a timestamp.
When removing a node don't ssh to it
Even in 1.2 this behaviour is broken, as the rpc call will remove thessh keys before we get a chance to log in. Now the rpc takes care ofshutting down the node daemon as well, so we definitely can avoid this.
This makes the LURemoveNode operation work again with the threaded...
Add errors.QuitGanetiException
This exception does not signal an error but serves the purpose of makingthe ganeti daemon shut down after handling a request. Currently it willbe used by ganeti-noded but in the future ganeti-masterd might make useof it as well. Its usage is documented in the docstring....
Add missing empty line in SshKeyError's docstring
Remove spurious check during LUAddNode
There is no point in checking whether the cluster VNC password fileexists as a prerequisite for AddNode, considering the check happens onthe master node, not the target one. Removing this check.
Improve LURemoveNode BuildHooksEnv docstring
Cleanup old DRBD 0.7.x code
Apparently there were still some leftovers. While removing an instance,I got the message "unhandled exception 'module' object has no attribute'LD_MD_R1'".
Cleanup LV status computation
Currently, when seeing if a LV is degraded or not (i.e. virtual volume),we first attach to the device (which does an lvdisplay), then do a lvsin order to display the lv_attr. This generates two external commands todo (almost) the same thing....
Remove lib/Makefile.libcommon
Fix gnt-cluster “command” and “copyfile”
Since the disabling of forking in the master daemon, the two ssh-basedsubcommands were not working anymore. However, there is no need at allfor the commands to be run from the master daemon (permissions to readthe cluster private ssh key notwithstanding), they can be run directly...
objects: Remove config_version from cluster configuration
Add functions to calculate version number to constants.py
In cfgupgrade, we need to extract parts of and build new version numbers.
utils.WriteFile: Remove optional check_abspath parameter
cfgupgrade will not work with relative paths at all, but rather get themfrom constants.py.
Add a ‘tags’ field to instance and node listing
Currently there isn't any easy way to list all nodes or instance andtheir tags; you have to query each node in turn, or list all the tagsvia something like “gnt-cluster search-tags '.*'”. Of course, this is...
Implement handling of luxi errors in cli.py
Currently the generic handling of ganeti errors in cli.py (GenericMainand FormatError) only handles the core ganeti errors, and not the clientprotocol errors (which live in a separate hierarchy).
This patch adds handling of luxi errors too, and also adds another luxi...
Add a rpc call for BlockDev.Close()
This patch adds rpc layer calls (in rpc.py and the equivalent inganeti-noded) to close a list of block devices, and the wrapper inbackend.py that takes a list of Disk objects, identifies them andreturns correctly formatted results....
Use a single Makefile.am instead of many
This change allows us to use cleaner dependencies betweendirectories. The build system is basically rewritten in large partsand may contain bugs.
Rework the DRBD8 device status computation
Currently, compute the status of a drbd8 device in GetSyncStatus andreturn only the values that we need (and fit in the framework ofGetSyncStatus). However, the full status details are useful (and needed)in other places, so the patch attempts to improve this situation....
ganeti-watcher: Replace custom exceptions with ganeti.error.*
Add more parameters to utils.WriteFile
- Make closing file optional: Required by ganeti-watcher to keep file open after writing it. Changes return value of utils.WriteFile if "close" parameter evaluates to True.- Pre- and post-write functions: Can be used to lock files. This...
Replace custom logging code in watcher with logging module
- Log timestamp for all messages- Write everything to logfile and optionally to stderr- Log messages are no longer buffered, allowing a user to see progress
Make sure serialized data ends with EOL character
Also fix the regular expression to not remove newlines. The simplejsonmodule puts whitespace at line endings when using indentation. Removeunnecessary import of ConfigParser module.
Allow disk object to set their own physical ID
Currently, the way to customize a DRBD disk from (node name 1, node name2, port) to (ip1, port, ip2, port) is to use the ConfigWriter methodSetDiskID. However, since this needs a ConfigWriter object, it can be...
Fix an error-handling case
There is a mistake in handling grow-disk for an invalid disk. This patchfixes it.
Implement disk grow at LU level
This patch adds a new opcode and LU for growing an instance's disk.
The opcode allows growing only one disk at time, and will throw an errorif the operation fails midway (e.g. on the primary node after it hasbeen increased on the secondary node). As such, it might actually leave...
Add method to update a disk object size
This patch adds a method that implements updating of a disk(object.Disk) size, together with its children.
While this will not track the exact disk size, it allows at least anapproximate size to be recorded in the configuration (and queried)....
Implement block device grow at the rpc layer
This simple patch exposes the block device grow operation at the rpclayer. It does not increase the protocol version as it has been recentlychanged by the live failover rpc call.
Expose block device grow in backend.py
This patch adds a wrapper over the block device grow operation thatconverts the input and output parameters as needed for the rpc layer.
bdev: implement disk resize for lvm/drbd8
This patch implements disk resize at the bdev level for the LVM andDRBD8 disk types. It is not implemented for DRBD7 and MD since the wayMD works with its underlaying devices makes it harder and thiscombination is also deprecated....
Move SetKey to WritableSimpleStore and use it
Before we used to be able to update SimpleStore by just calling SetKey, thisfeature is now moved to an external class, which inherits from it. In thispatch the new WritableSimpleStore class is also put to use, in the LUs that...
Add migration support at the rpc layer
This patch adds the migration rpc call and its implementation in thebackend. The patch does not deal with the correct activation of disks.
Because of the new RPC, the protocol version is increased.
hypervisor: add live migration support
This is just the hypervisor-level migration (e.g. “xm migrate”) not thewhole node coordination work.
Activate down instances' disks on replace-disks
When replacing disks or evacuating nodes with instances administrativelydown ganeti fails because the instance disks are not active. This patchactivates them, performs the replacement, and shuts them down again....
FailoverInstance: change AddInstance with Update
We're not adding a new instance, just making configuration changes tothe one we're working on.
Fix an error message in instance add
There is a mistake in the error message generated when we can't reach anode for checking for available disk space. Without it, the errormessage is:Failure: prerequisites not met for this operation:Cannot get current information from node '{u'gnte2.lab.k1024.org':...
Replace logging functions with calls to logging module
- Shorter code- Reorder arguments to logger.SetupLogging calls to make more sense
Fix a typo in jqueue.py
s/result/op_result/ (this code was never used, so this wasn't caught)
Move InitCluster opcode into a single function
This allows us to initialize a new cluster. The code certainly containsbugs and hooks aren't implemented yet.
Move cmdlib._HasValidVG to utils.CheckVolumeGroupSize
This is required for splitting the cluster initialization code.
Move {Set,Remove}EtcHostsEntry wrappers to utils.py
This is required for the split of the cluster initialization code.
Reviewed-by: iustinp, ultrotter
Remove REQ_CLUSTER from opcode handling code
It's not needed anymore now that all opcodes require a cluster. Clusterinitialization was the only exception.
Remove unreachable code from cli.SubmitOpCode
Rename master socket to ganeti-master.sock
…/run/master.sock is not specific enough.
Remove SimpleStore cache
SimpleStore is instantiated anew most of the times it's used, so havinga cache inside it serves no purpose. Removing it.
Forward-port: Alias Dump/Load functions in ganeti.serializer to DumpJson/LoadJson
The remote API will use JSON for the foreseable future, so it's betterto put the serialization format in the function name. We can stilluse another serialization format for Ganeti's core....
Add check for node memory in instance creation
Currently the check for enough memory is done only on instance startcommand and failover command. But we also start an instance in instancecreate, therefore we need to check this instead of failing to start in...
Show cluster hypervisor for gnt-cluster info
Author: schreiberalReviewed-by: iustinp
Forward-port: make gnt-modify work with new HVM parameters
This fixes gnt-instance modify so it actually works with thenew HVM parameters for Ganeti 1.2
Forward-port: show only parameters relevant to the instance
This patch modifies the code for "gnt-instance info .." to only displayinstance parameters that actually apply to that instance, i.e. for PVMinstances no HVM parameters are shown and vice versa....
Forward-port: patch 3/4 extended HVM features for 1.2
This patch adds hypervisor support for the extended HVM features.
Forward-port: patch 2/4 extended HVM features for 1.2
This patch adds the commandline extensions and the code to storeand display the extended HVM features.
Complete removal of md/drbd 0.7 code
This patch removes the last of the md and drbd 0.7 code. Cluster whichhave the old device types will be broken if they have this applied.
LURemoveInstance: fix op.ignore_failures usage
Currently: the LURemoveInstance.Exec() method uses the ignore_failuresattribute of the OpRemoveInstance opcode, but it doesn't check for itsexistence. The patch adds this attribute to _OP_REQP and to all the...
Fix drbd show parser to handle valueless keywords
It turns out in some cases there can exist keywords without anassociated value exported by drbdsetup show. This patch makes the valuepart optional in our parser, so that if it's not present the parsingresult will contain an array with just the keyword in it. This is not a...
Split drbd command creation and execution
Make _AssembleDisk more similar to _AssembleNet by splitting thegeneration of the drbdsetup command and its execution. While notchanging anything this makes it easier to manipulate the command just incertain cases, which in the future we'll need to do....
Implement node daemon conectivity tests
This patch adds in gnt-cluster verify checks for inter-node tcpcommunication checks on the node daemon port for both the primary and(if defined) secondary networks.
The output looks like (4-node cluster, one with the secondary interface...
Forward-port changes made to readd in 1.2
qa_node.py: Fix typo in messagecmdlib.py: Don't add readded node to node listganeti-qa.py: Make sure readd isn't done for master node
CLI: retry: remove command opts/args in "gnt-X"
This new version of the patch removes only the listing of the usage inthe "gnt-X" list, but keeps the strings in since we'll want to enhanceand use them in "gnt-X $cmd --help".
Revert "CLI: remove command opts/args in "gnt-X""
This reverts commit 976.
CLI: remove command opts/args in "gnt-X"
[Forward-port of the 1.2 branch patch]
This patch removes all the parameters and options from the output"gnt-X" (i.e. the subcommand list for command). This is done in order touniformize the output, currently only some parameters are shown and they...
Reduce chance of ssh failures in verify cluster
The cluster verify builds a sorted list of nodes and passes that to allthe nodes (in parallel) for ssh checks. This means that for a clusterwith N nodes, there will be approximately N simultaneous connections to...
bdev: always log command output if it failed
Currently many error handling code paths in bdev.py log onlyresult.fail_reason (i.e. exit code or signal that killed the command)but not its output. This makes debugging very hard.
The patch changes all places where we only log fail_reason to also log...
DRBD: Fix another bug in diskless activation
DRBD8 requires that we pass ‘--create-device’ to the first command thatwants to activate a new DRBD minor. We do this currently when we run the“drbdsetup ... disk” command which we run before the network setup....
Remove utils.CheckDaemonAlive and use “xm info” instead
There are a couple of reasons for doing so:- /proc is not OS independent, it's only supported by Linux (there are emulations on other systems, but those might differ from the way Linux represents data)....
Improve DRBD8.Open's docstring a bit more
Fix comment typo in bdev.py
Fix DRBD8 diskless assembling
The algorithm for attaching to existing DRBD devices is not trivial. Ithas four alternatives, and there is a bug in the last one when we havediskless devices.
The last case (local disk info matches but remote/network configuration...
Use new ssconf function to check configuration version
Upgrades will be handled in future patches.
Use dict instead of if/elif map for hypervisor classes
Rename hypervisor code to lowercase filenames
Export the number of cpus to iallocator scripts
Now that we have the number of cpus available from the hypervisors, wecan export this to the iallocator scripts.
Add node cpu count to gnt-node list
This patch adds the backend and frontend changes needed for being ableto list the cpu count.
Wrap exception in _DistributeConfig code
nodelist.remove(X) could potentially raise a ValueError (even if the chancethat the current node is not in the list are pretty scarce, and its absenceshould raise a red flag anyway). If this happens let things go on, as that's...
Simplify target generation in DistributeConfig
Currently we get the list of nodes, and for each one extract all its info, andjust to exclude it if the name matches ours. Since the list of nodes is a listof names just use .remove() to exclude ourself from it, and use that list...
ssconf: update the SetKey docstring
SetKey is used, other than for adding new nodes, in another few cases. Updatethe docstring to reflect this, so we don't mislead people reading it.
Delete hypervisor.py
This completes the changes in r898 by actually getting rid of the old unusedhypervisor.py code which was left in the code tree.