First connect to AMQP then fetch initial state
This way we don't miss anything - we just have to make sure we're done within heartbeart interval, or the server will close the connection. But that's 60 seconds, so we're safe for this bot (and if we fail once, we have to reconnect)
This commit is contained in:
parent
d5947f5c19
commit
8b6b498a0f
@ -24,15 +24,19 @@ from PubSubConsumer import PubSubConsumer
|
||||
|
||||
class Project(object):
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
Config(apiurl, name)
|
||||
self.api = StagingAPI(apiurl, name)
|
||||
self.staging_projects = dict()
|
||||
self.listener = None
|
||||
self.replace_string = self.api.attribute_value_load('OpenQAMapping')
|
||||
|
||||
def init(self):
|
||||
for p in self.api.get_staging_projects():
|
||||
if self.api.is_adi_project(p):
|
||||
continue
|
||||
self.staging_projects[p] = self.initial_staging_state(p)
|
||||
self.update_staging_status(p)
|
||||
|
||||
def staging_letter(self, name):
|
||||
return name.split(':')[-1]
|
||||
@ -67,12 +71,6 @@ class Project(object):
|
||||
return {'isos': self.gather_isos(name, 'images'),
|
||||
'id': self.gather_buildid(name, 'images')}
|
||||
|
||||
# once the project is added to a listener, it's calling back
|
||||
def fetch_initial_openqa(self, listener):
|
||||
self.listener = listener
|
||||
for project in self.staging_projects:
|
||||
self.update_staging_status(project)
|
||||
|
||||
def fetch_openqa_jobs(self, staging, iso):
|
||||
buildid = self.staging_projects[staging].get('id')
|
||||
if not buildid:
|
||||
@ -171,9 +169,18 @@ class Listener(PubSubConsumer):
|
||||
return ret
|
||||
|
||||
def add(self, project):
|
||||
project.fetch_initial_openqa(self)
|
||||
project.listener = self
|
||||
self.projects.append(project)
|
||||
|
||||
def start_consuming(self):
|
||||
# now we are (re-)connected to the bus and need to fetch the
|
||||
# initial state
|
||||
for project in self.projects:
|
||||
self.logger.info('Fetching ISOs of %s', project.name)
|
||||
project.init()
|
||||
self.logger.info('Finished fetching initial ISOs, listening')
|
||||
super(Listener, self).start_consuming()
|
||||
|
||||
def jobs_for_iso(self, iso):
|
||||
values = {
|
||||
'iso': iso,
|
||||
@ -236,11 +243,11 @@ if __name__ == '__main__':
|
||||
|
||||
if apiurl.endswith('suse.de'):
|
||||
amqp_prefix = 'suse'
|
||||
amqp_url = "amqps://suse:suse@rabbit.suse.de?heartbeat_interval=15"
|
||||
amqp_url = "amqps://suse:suse@rabbit.suse.de"
|
||||
openqa_url = 'https://openqa.suse.de'
|
||||
else:
|
||||
amqp_prefix = 'opensuse'
|
||||
amqp_url = "amqps://opensuse:opensuse@rabbit.opensuse.org?heartbeat_interval=15"
|
||||
amqp_url = "amqps://opensuse:opensuse@rabbit.opensuse.org"
|
||||
openqa_url = 'https://openqa.opensuse.org'
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
Loading…
x
Reference in New Issue
Block a user