def _doReconfigureEvent(self, event): # This is called in the scheduler loop after another thread submits # a request self.layout_lock.acquire() self.config = event.config try: self.log.info("Full reconfiguration beginning") loader = configloader.ConfigLoader(self.connections, self, self.merger) self.unparsed_abide = loader.readConfig( self.config.get('scheduler', 'tenant_config')) abide = loader.loadConfig(self.unparsed_abide, self._get_project_key_dir()) for tenant in abide.tenants.values(): self._reconfigureTenant(tenant) self.abide = abide finally: self.layout_lock.release() self.log.info("Full reconfiguration complete")
def validate(self): from zuul import scheduler from zuul import configloader sched = scheduler.Scheduler(self.config, testonly=True) self.configure_connections(source_only=True) sched.registerConnections(self.connections, load=False) loader = configloader.ConfigLoader(sched.connections, sched, None) tenant_config, script = sched._checkTenantSourceConf(self.config) unparsed_abide = loader.readConfig(tenant_config, from_script=script) try: for conf_tenant in unparsed_abide.tenants: loader.tenant_parser.getSchema()(conf_tenant) print("Tenants config validated with success") err_code = 0 except Exception as e: print("Error when validating tenants config") print(e) err_code = 1 finally: sys.exit(err_code)
def _doTenantReconfigureEvent(self, event): # This is called in the scheduler loop after another thread submits # a request self.layout_lock.acquire() try: self.log.info("Tenant reconfiguration beginning") # If a change landed to a project, clear out the cached # config before reconfiguring. for project in event.projects: project.unparsed_branch_config = {} old_tenant = self.abide.tenants[event.tenant_name] loader = configloader.ConfigLoader(self.connections, self, self.merger) abide = loader.reloadTenant( self.config.get('scheduler', 'tenant_config'), self._get_project_key_dir(), self.abide, old_tenant) tenant = abide.tenants[event.tenant_name] self._reconfigureTenant(tenant) self.abide = abide finally: self.layout_lock.release() self.log.info("Tenant reconfiguration complete")
def _doTenantReconfigureEvent(self, event): # This is called in the scheduler loop after another thread submits # a request self.layout_lock.acquire() try: self.log.info( "Tenant reconfiguration beginning for %s due to " "projects %s", event.tenant_name, event.projects) # If a change landed to a project, clear out the cached # config before reconfiguring. # TODO(jeblair): this could probably clear only the specific branch for project in event.projects: self.abide.clearUnparsedConfigCache(project.canonical_name) old_tenant = self.abide.tenants[event.tenant_name] loader = configloader.ConfigLoader(self.connections, self, self.merger) abide = loader.reloadTenant(self._get_project_key_dir(), self.abide, old_tenant) tenant = abide.tenants[event.tenant_name] self._reconfigureTenant(tenant) self.abide = abide finally: self.layout_lock.release() self.log.info("Tenant reconfiguration complete")