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

Added post checks to check if object are available in etcd post create #297

Merged
merged 2 commits into from
Jun 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tendrl/gluster_integration/objects/definition/gluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ namespace.gluster:
- Volume.tuned_profile
pre_run:
- gluster.objects.Volume.atoms.NamedVolumeNotExists
post_run:
- gluster.objects.Volume.atoms.CheckVolumeAvailable
run: gluster.flows.CreateVolume
type: Create
uuid: 1951e821-7aa9-4a91-8183-e73bc8275b8e
Expand Down Expand Up @@ -440,6 +442,16 @@ namespace.gluster:
run: gluster.objects.Volume.atoms.StopRebalance
type: Start
uuid: 242f6190-9b37-11e6-950d-a24fc0d96567
CheckVolumeAvailable:
enabled: true
help: check if volume is available
inputs:
mandatory:
- Volume.volname
name: volume available
run: gluster.objects.Volume.atoms.CheckVolumeAvailable
type: Start
uuid: 242f6190-9b37-11e6-950d-a24fc0d96765
flows:
DeleteVolume:
tags:
Expand Down
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(
Copy link
Contributor

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

Copy link
Member Author

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.

"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)
Copy link
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Member Author

Choose a reason for hiding this comment

The 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']
)