-
Notifications
You must be signed in to change notification settings - Fork 354
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
Add sync status #146
Add sync status #146
Conversation
Codecov Report
@@ Coverage Diff @@
## master #146 +/- ##
==========================================
+ Coverage 28.54% 29.14% +0.60%
==========================================
Files 61 61
Lines 3714 3785 +71
Branches 420 425 +5
==========================================
+ Hits 1060 1103 +43
- Misses 2640 2668 +28
Partials 14 14
|
dolphin/task_manager/tasks/task.py
Outdated
def sync_task(resource_type): | ||
|
||
@decorator.decorator | ||
def _sync_task(f, *a, **k): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest to set bits for all resources from the producer side. Producer set all bits at once, and consumer for a specific resource just reset the bit for it's own.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, please check again
dolphin/common/constants.py
Outdated
VOLUME = 2 | ||
ACCESS_INFO = 3 | ||
DISK = 4 | ||
ALERT_SOURCE = 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACCESS_INFO and ALERT_SOURCE are not part of task manager .How do we check if there is some activty happening for these resources like ( update access-info , or remove alert source ) ??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed all of the rest except STORAGE_DEVICE, POOL and VOLUME.
dolphin/api/v1/storages.py
Outdated
0, | ||
len(constants.ResourceType) - 1, | ||
constants.SyncStatus.SYNCING) | ||
db.storage_update(ctxt, storage['id'], storage) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think about the scenario that two sync_all rquest arived at the same time, let's say request_A and request_B, handle steps as below:
- request_A get storage info first, and then request_B get storage info too,
- request_A check sync_status is not syncing so update it to be syncing,
- request_B check sync_status is not syncing so it will update the sync status again, which is not correct.
So read and update sync_status need lock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@ThisIsClark , we also need to think about the dead lock scenario, say one consumer crashed and the coresponding bit will neber be reset. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to covert sync_status to a friendly status before return in GET /v1/storages and GET /v1/storages/id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Raised a issue: #165 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What this PR does / why we need it:
Add sync status to avoid two sync tasks for the same device are running at the same time.
For a storage device, add a int(named sync_status) to indicate the sync status, each bit of this int indicates a resource.
When a sync task for a resource is running for a device, set the special bit of sync_status of this device to 1, and when sync is done, set the special bit back to 0.
When received request to sync resource of a device, check if all the bit of sync_status is 0(means no sync task is running for this device), if not, this request would not be handled.
Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close that issue when PR gets merged): fixes #Special notes for your reviewer:
Release note:
Test case: