Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CP-49720 Move LOCK_TYPE_RUNNING from cleanup.py to lock.py #691

Merged
merged 3 commits into from
Jun 13, 2024

Conversation

TimSmithCtx
Copy link
Contributor

In the process, rename LOCK_TYPE_RUNNING to LOCK_TYPE_GC_RUNNING to describe what is running when it's running. This matches LOCK_TYPE_GC_ACTIVE which remains in cleanup.py because it is only used there.

Rename the global variables in cleanup.py to describe what is Active/Running.

@TimSmithCtx TimSmithCtx requested review from MarkSymsCtx and rdn32 June 6, 2024 13:31
@@ -54,7 +53,7 @@ def doexec_locked(cmd):
"""Executes via util.doexec the command specified whilst holding lock"""
_lock = None
if os.path.basename(cmd[0]) == 'iscsiadm':
_lock = lock.Lock(LOCK_TYPE_RUNNING, 'iscsiadm')
_lock = lock.Lock(lock.LOCK_TYPE_GC_RUNNING, 'iscsiadm')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now incorrect. IN this case the lock should be a unique LOCK_TYPE_ISCSIADM_RUNNING as it is a lock around usage of iscsiadm and nothing to do with the GC.

@@ -31,7 +31,7 @@
import time
import glob
from uuid import uuid4
from lock import Lock
from lock import Lock, LOCK_TYPE_GC_RUNNING
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still needed? I suspect not.

@@ -36,7 +36,8 @@
import cleanup
import blktap2
from journaler import Journaler
from lock import Lock
from lock import Lock, LOCK_TYPE_GC_RUNNING
import cleanup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surely it must already have had cleanup imported as it was calling cleanup.start_gc? And the LOCK_TYPE_GC_RUNNING is no longer required

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, yes, on line 36

drivers/lock.py Outdated
@@ -23,6 +23,8 @@

VERBOSE = True

LOCK_TYPE_GC_RUNNING = "gc_running"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we risk having a clash with a pre-existing runing process during an upgrade where the running GC process already has the running lock and then a new process tries, and succeeds, in acquiring the gc_running lock and assumes it has free reign over the GC process? That probably results in data corruption unless we ensure the upgrade aborts any in progress GC operations, which it does not by default do.

Tim Smith added 3 commits June 7, 2024 15:52
In the process, rename LOCK_TYPE_RUNNING to LOCK_TYPE_GC_RUNNING to
describe *what* is running when it's running. This matches
LOCK_TYPE_GC_ACTIVE which remains in cleanup.py because it is only used
there.

Rename the global variables in cleanup.py to describe *what* is
Active/Running.

Signed-off-by: Tim Smith <tim.smith@cloud.com>
Separate the lock for iscsiadm from the GC lock

Signed-off-by: Tim Smith <tim.smith@cloud.com>
Both LVHDSR and FileSR in their _kickGC() method would check to see if a
GC was already in progress and avoid starting one if so. This code was
duplicated and can be moved into the cleanup.start_gc() method.

Signed-off-by: Tim Smith <tim.smith@cloud.com>
@TimSmithCtx TimSmithCtx force-pushed the private/timsmi/CP-49720 branch from 201a1a8 to 78faa7d Compare June 10, 2024 08:18
@TimSmithCtx TimSmithCtx requested a review from MarkSymsCtx June 10, 2024 13:26
@@ -23,6 +23,9 @@

VERBOSE = True

# Still just called "running" for backwards compatibility
LOCK_TYPE_GC_RUNNING = "running"
LOCK_TYPE_ISCSIADM_RUNNING = "isciadm_running"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine but we will get a slightly odd lock name of iscsiadm.iscsiadm_running as a result.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with that. If in the future we encounter a lock named newthing.iscsiadm_running we'll know where to look for the cut & paste error...

@TimSmithCtx TimSmithCtx requested a review from KevinLCtx June 13, 2024 08:59
@TimSmithCtx TimSmithCtx merged commit 2b6bac9 into xapi-project:master Jun 13, 2024
2 checks passed
@TimSmithCtx TimSmithCtx deleted the private/timsmi/CP-49720 branch June 13, 2024 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants