-
Notifications
You must be signed in to change notification settings - Fork 20
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
Added post checks to check if object are available in etcd post create #297
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
tendrl/gluster_integration/objects/volume/atoms/check_volume_available/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import etcd | ||
import gevent | ||
|
||
from tendrl.commons.event import Event | ||
from tendrl.commons.message import Message | ||
from tendrl.commons import objects | ||
from tendrl.commons.objects import AtomExecutionFailedError | ||
from tendrl.gluster_integration.objects.volume import Volume | ||
|
||
|
||
class CheckVolumeAvailable(objects.BaseAtom): | ||
def __init__(self, *args, **kwargs): | ||
super(CheckVolumeAvailable, self).__init__(*args, **kwargs) | ||
|
||
def run(self): | ||
retry_count = 0 | ||
while True: | ||
try: | ||
volumes = NS._int.client.read( | ||
"clusters/%s/Volumes" % NS.tendrl_context.integration_id | ||
) | ||
except etcd.EtcdKeyNotFound: | ||
# ignore as no volumes available till now | ||
pass | ||
|
||
if volumes: | ||
for entry in volumes.leaves: | ||
volume = Volume(vol_id=entry.key.split("Volumes/")[-1]).load() | ||
if volume.name == self.parameters['Volume.volname']: | ||
return True | ||
|
||
retry_count += 1 | ||
gevent.sleep(1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Increase the timeout to 10 mins, we are going to allow configurable sds/node sync intervals in near future There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
if retry_count == 600: | ||
Event( | ||
Message( | ||
priority="error", | ||
publisher=NS.publisher_id, | ||
payload={ | ||
"message": "Volume %s not reflected in tendrl yet. Timing out" % | ||
self.parameters['Volume.volname'] | ||
}, | ||
job_id=self.parameters['job_id'], | ||
flow_id=self.parameters['flow_id'], | ||
cluster_id=NS.tendrl_context.integration_id, | ||
) | ||
) | ||
raise AtomExecutionFailedError( | ||
"Volume %s not reflected in tendrl yet. Timing out" % | ||
self.parameters['Volume.volname'] | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
use object.load() , we need to ensure all attributes inside the object are also present as provided by user
Because a Volume is only really fully available when you can load() it
Also, just load the actual volume instead of iterating over every volume
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.
As discussed earlier, while volume creation we have volume name only available. This post run atom is for create volume flow. To load a specific volume we need volume uuid which is not available here.