Add a design document for removal of the config lock

This design document describes how the negative effect of the config
lock can be removed in an incremental way.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>
The config lock still exists

...so update the daemons-refactoring design document accordingly
to fit with implementation. The mentioned design document already
exists on the master branch.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>
Merge branch 'stable-2.12' into master

* stable-2.12
  The config lock still exists

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Hrvoje Ribicic <riba@google.com>
Link to the config-lock design document

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>
Fix broken haskell dependencies

Fixes issues 758 and 912.
Since ghc -M does not generate inter object dependency rule for object
files, dependencies from a target executable seed object
(e.g. src/hluxid.o) to objects which finally will be linked to the
target object (e.g. src/Ganeti/Daemon.o) are missing in Makefile.ghc.
For instance, following commands will not rebuild src/hluxid inspite of
its dependent object src/Ganeti/Daemon.o has been updated.

    $ make # rebuild all once
    $ touch src/Ganeti/Daemon.hs
    $ make # this will rebuild src/Ganeti/Daemon.o, not src/hluxid.o

This patch adds simple substitution code after the Makefile.ghc
generation to add additional inter object dependency for all object
files to force relink related objects when a linked object has been
updated.

Signed-off-by: Yuto KAWAMURA(kawamuray) <kawamuray.dadada@gmail.com>
Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>
Really run wconfd as masterd and metad as root

Commits 9decc439eb4 and 4ddce51deb were incomplete, missing the relevant
group specifications. Since the decision was made to run wconfd as
masterd and metad as root, we use the respective existing groups.

Signed-off-by: Apollon Oikonomopoulos <apoikos@gmail.com>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Merge branch 'stable-2.11' into stable-2.12

* stable-2.11
  Fix broken haskell dependencies

No conflicts.

Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Merge branch 'stable-2.12' into master

* stable-2.12
  Really run wconfd as masterd and metad as root

* stable-2.11
  Fix broken haskell dependencies

No conflicts.

Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>
Prepare master branch for 2.14 devel cycle

Bump versions in various places to 2.14 and remove the downgrade code
from cfgupgrade.

Signed-off-by: Hrvoje Ribicic <riba@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Allow unlocked reading of the config

As all writes to the config bring in all changes in an atomic
fashion, we can allow reading the configuration without owning
the ConfigLock.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>
Read the configuration without locking it

As reads to the config are consistent anyway (changes go in
by a single change to WConfD), do not acquire the config lock
for read-only operations. To keep the transition smooth, this
read without locking is built into the config manager as the
new "shared" synchronisation.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>
Add nodes field in class Disk

Add a field called "nodes" in the Disk class. This field will be a list
of Ganeti node UUIDs from which this disk is accessible. Also, update
the Haskell tests in order to adjust to this change.
Populate disk nodes when creating disks

When creating a Disk using the GenerateDiskTemplate function, fill the
nodes field depending on the disk template. There are three cases:

1) Internally mirrored disks (DRBD):
   These disks are accessible from two nodes, so the nodes field will
   include these. Their children (data, meta) are also accessible from
   two nodes, therefore they will inherit the nodes of the parent.
2) Externally mirrored disks (Blockdev, Ext, Gluster, RBD, Shared File):
   These disks should be accessible from any node in the cluster,
   therefore the nodes field will be empty.
3) Single-node disks (Plain, File):
   These disks are accessible from one node only, therefore the nodes
   field will consist only of the primary instance node.
Maintain consistency of nodes field

There are four scenarios in which the nodes field can change after the
disk's creation; when moving, replacing, converting or recreating disks.
For each scenario, update the nodes field accordingly.
Update cfgupgrade tool

Create an upgrade function that adds a nodes field to each disk that is
attached to an instance. Also, add a downgrade function that removes the
nodes field and brings the config to the default state for 2.12.
Update various tests regarding disk creation

Update the tests that deal with disk creation and check if the nodes
field is populated correctly when creating a disk.