Skip to content

Commit

Permalink
Remove hard coded items and revert db feature
Browse files Browse the repository at this point in the history
Seems there are folks out there using this for their own
CI deployment which is AWESOME!!  There's lots of room for
imporovement here so don't be shy with your pull requests.

At the same time, there seems to be a couple of folks that
aren't really "looking" at the code and submitting comments
to gerrit using my CI name (my fault since it's hardcoded in there).

This patch removes all of my system specific things like names and
IP's.  It also modifies the sample conf file to have pure
nonsense entries so one will be forced to update.

In addition, my db integration seems to have some issues, for now
I'm just reverting that and I'll come back to it at some point
in the future as a nice to have.
  • Loading branch information
John Griffith committed Mar 5, 2015
1 parent a387c19 commit 70526dc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 87 deletions.
19 changes: 10 additions & 9 deletions sos-ci.conf.sample
@@ -1,20 +1,21 @@
[AccountInfo]
gerrit_ssh_key = /home/jgriffith/.ssh/sfci_rsa
gerrit_ssh_key = /home/user/.ssh/sfci_rsa
gerrit_host = review.openstack.org
gerrit_port = 29418
project_name = openstack/cinder
ci_name = SolidFire-dsvm-full
ci_account = sfci
ci_name = sos-changeme-dsvm-full
ci_account = my-ci-account

[Ansible]
ansible_dir = /home/jgriffith/sos-ci/sos-ci/ansible
ansible_dir = /path/to/my/ansible/playbooks

[Data]
debug = True
data_dir = /home/jgriffith/sos-ci/data
log_dir = /home/jgriffith/sos-ci/data/sos-logs

data_dir = /path/to/my/sos-ci/data/dir
[Email]
enable_notifications = true
from_address = sfci@bdr76.solidfire.com
to_address = john.griffith@solidfire.com
from_address = me@email.com
to_address = you@email.com

[Logs]
log_dir = http://your/web/server/log/dir
2 changes: 1 addition & 1 deletion sos-ci/ansible/create.yml
Expand Up @@ -4,7 +4,7 @@
tasks:
- name: create instances
nova_compute:
image_id: "5203b96c-94a9-4dce-a7a6-e960ea87e8df"
image_id: "62238bf1-62a0-4151-8c09-1adea61e5a9c"
key_name: "cloudkey"
wait_for: 200
flavor_id: 1
Expand Down
90 changes: 13 additions & 77 deletions sos-ci/os_ci.py
Expand Up @@ -13,8 +13,6 @@

from iniparse import INIConfig

from db.model.db_engine import reviews
from db.model.db_engine import revisions
import executor
import log

Expand Down Expand Up @@ -82,28 +80,25 @@ def _post_results_to_gerrit(self, log_location, passed, commit_id):
subject = ''
msg = ''
logger.debug('Building gerrit review message...')
msg = 'Commit: %s\nLogs: %s\n' % (log_location, commit_id)
msg = 'Commit: %s\nLogs: %s\n' % (commit_id, log_location)
if passed:
subject += " sf-dsvm SUCCESS"
subject += " %s SUCCESS" % cfg.ci_name
msg += "Result: SUCCESS"
cmd += """"* solidfire-dsvm-volume %s : SUCCESS " %s""" % \
(log_location, commit_id)
cmd += """"* %s %s : SUCCESS " %s""" % \
(cfg.ci_name, log_location, commit_id)
logger.debug("Created success cmd: %s", cmd)
else:
subject += " sf-dsvm FAILED"
msg += "Result: FAILED"
cmd += """"* solidfire-dsvm-volume %s : FAILURE " %s""" % \
(log_location, commit_id)
cmd += """"* %s %s : FAILURE " %s""" % \
(cfg.ci_name, log_location, commit_id)
logger.debug("Created failed cmd: %s", cmd)

msg += "\nLOGS: log_location"
logger.debug('Issue notification email, '
'Subject: %(subject)s, %(msg)s',
{'subject': subject, 'msg': msg})

_send_notification_email(subject, msg)
with open('/home/jgriffith/sos_ci_results.dat', 'a') as f:
f.write('%s\n' % cmd)

logger.debug('Connecting to gerrit for voting '
'%(user)s@%(host)s:%(port)d '
Expand All @@ -128,30 +123,15 @@ def _post_results_to_gerrit(self, log_location, passed, commit_id):
self.stdin, self.stdout, self.stderr =\
self.ssh.exec_command(cmd)

def _post_results_to_db(self, event, log_location, passed, commit_id):
""" Post our CI system results to DB. """

patchset_ref = event['patchSet']['ref']
logger.debug('Updating DB table with results for patchset: %s',
patchset_ref)

try:
q = revisions.update(
sos_success=passed,
log_location=log_location).where(
patchset_ref == patchset_ref)
q.execute()
except Exception as ex:
logger.warning('Error encountered when adding review to '
'database, ignoring: %s', ex)
pass

def run(self):
counter = 60
while True:
counter -= 1
event_queue
if not event_queue:
logger.debug('queue is empty, sleep for 60 '
'seconds and check again...')
if counter <= 1:
logger.debug('Queue is empty, checking every 60 seconds...')
counter = 60
time.sleep(60)
else:
event = event_queue.popleft()
Expand Down Expand Up @@ -191,8 +171,7 @@ def run(self):

logger.info("Completed %s", cfg.AccountInfo.ci_name)
url_name = patchset_ref.replace('/', '-')
log_location = ('http://54.164.167.86/solidfire-ci-logs/%s' %
url_name)
log_location = cfg.log_dir + '/' + url_name
self._post_results_to_gerrit(log_location, success, commit_id)
self._post_results_to_db(event,
log_location,
Expand Down Expand Up @@ -252,49 +231,6 @@ def process_options():
return options


def create_review_entry(event):
""" Creates the review record in the DB
This just creates the 'I picked up an event from the queue'
entry. We update later with our results.
"""

url = event['patchSet']['change']['url']
project = event['patchSet']['change']['project']
branch = event['patchSet']['change']['branch']
patchset_number = event['patchSet']['number']
review_number = event['patchSet']['change']['number']
topic = event['patchSet']['change']['topic']
patchset_ref = event['patchSet']['ref']

logger.debug('Creating DB record for patchset: %s',
patchset_ref)

try:
q = reviews.insert(gerrit_url=url,
project=project,
branch=branch,
id=review_number,
topic=topic)
q.execute()
except Exception as ex:
# Make sure we pass here, we likely already have an
# entry in the parent table
logger.warning('Error encountered when adding review to '
'database, ignoring: %s', ex)
pass

# Create the base revision entry, we'll update after our run
try:
q = revisions.insert(review_id=review_number,
patchset_number=patchset_number,
patchset_ref=patchset_ref)
q.execute()
except Exception as ex:
logger.warning('Error encountered when adding review to '
'database, ignoring: %s', ex)
pass

if __name__ == '__main__':
event_queue = deque()
options = process_options()
Expand All @@ -313,7 +249,7 @@ def create_review_entry(event):
break
valid_event = _filter_cinder_events(event)
if valid_event:
logger.debug('Identified valid event, sending to queue...')
if not options.event_monitor_only:
logger.debug("Adding event to queue:%s\n", valid_event)
event_queue.append(valid_event)
create_review_entry(valid_event)

0 comments on commit 70526dc

Please sign in to comment.