Skip to content
Snippets Groups Projects
Commit 4e070776 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Add new lock level for node resource modifications


This is in preparation for implementing a new resource model.

Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 5d3c30df
No related branches found
No related tags found
No related merge requests found
...@@ -1389,20 +1389,30 @@ LEVEL_CLUSTER = 0 ...@@ -1389,20 +1389,30 @@ LEVEL_CLUSTER = 0
LEVEL_INSTANCE = 1 LEVEL_INSTANCE = 1
LEVEL_NODEGROUP = 2 LEVEL_NODEGROUP = 2
LEVEL_NODE = 3 LEVEL_NODE = 3
LEVEL_NODE_RES = 4
LEVELS = [LEVEL_CLUSTER, LEVELS = [
LEVEL_INSTANCE, LEVEL_CLUSTER,
LEVEL_NODEGROUP, LEVEL_INSTANCE,
LEVEL_NODE] LEVEL_NODEGROUP,
LEVEL_NODE,
LEVEL_NODE_RES,
]
# Lock levels which are modifiable # Lock levels which are modifiable
LEVELS_MOD = [LEVEL_NODE, LEVEL_NODEGROUP, LEVEL_INSTANCE] LEVELS_MOD = frozenset([
LEVEL_NODE_RES,
LEVEL_NODE,
LEVEL_NODEGROUP,
LEVEL_INSTANCE,
])
LEVEL_NAMES = { LEVEL_NAMES = {
LEVEL_CLUSTER: "cluster", LEVEL_CLUSTER: "cluster",
LEVEL_INSTANCE: "instance", LEVEL_INSTANCE: "instance",
LEVEL_NODEGROUP: "nodegroup", LEVEL_NODEGROUP: "nodegroup",
LEVEL_NODE: "node", LEVEL_NODE: "node",
LEVEL_NODE_RES: "nodes-res",
} }
# Constant for the big ganeti lock # Constant for the big ganeti lock
...@@ -1443,6 +1453,7 @@ class GanetiLockManager: ...@@ -1443,6 +1453,7 @@ class GanetiLockManager:
self.__keyring = { self.__keyring = {
LEVEL_CLUSTER: LockSet([BGL], "BGL", monitor=self._monitor), LEVEL_CLUSTER: LockSet([BGL], "BGL", monitor=self._monitor),
LEVEL_NODE: LockSet(nodes, "nodes", monitor=self._monitor), LEVEL_NODE: LockSet(nodes, "nodes", monitor=self._monitor),
LEVEL_NODE_RES: LockSet(nodes, "nodes-res", monitor=self._monitor),
LEVEL_NODEGROUP: LockSet(nodegroups, "nodegroups", monitor=self._monitor), LEVEL_NODEGROUP: LockSet(nodegroups, "nodegroups", monitor=self._monitor),
LEVEL_INSTANCE: LockSet(instances, "instances", LEVEL_INSTANCE: LockSet(instances, "instances",
monitor=self._monitor), monitor=self._monitor),
......
...@@ -429,6 +429,7 @@ class GanetiContext(object): ...@@ -429,6 +429,7 @@ class GanetiContext(object):
# Add the new node to the Ganeti Lock Manager # Add the new node to the Ganeti Lock Manager
self.glm.add(locking.LEVEL_NODE, node.name) self.glm.add(locking.LEVEL_NODE, node.name)
self.glm.add(locking.LEVEL_NODE_RES, node.name)
def ReaddNode(self, node): def ReaddNode(self, node):
"""Updates a node that's already in the configuration """Updates a node that's already in the configuration
...@@ -449,6 +450,7 @@ class GanetiContext(object): ...@@ -449,6 +450,7 @@ class GanetiContext(object):
# Remove the node from the Ganeti Lock Manager # Remove the node from the Ganeti Lock Manager
self.glm.remove(locking.LEVEL_NODE, name) self.glm.remove(locking.LEVEL_NODE, name)
self.glm.remove(locking.LEVEL_NODE_RES, name)
def _SetWatcherPause(until): def _SetWatcherPause(until):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment