fixed setup for kuberneetes

This commit is contained in:
anhefti 2021-07-12 17:00:19 +02:00
parent ce270f3057
commit ef72400656
5 changed files with 34 additions and 7 deletions

View file

@ -41,21 +41,27 @@ public class SEBServerMigrationStrategy implements FlywayMigrationStrategy {
@Override
public void migrate(final Flyway flyway) {
try {
// If we are in a distributed setup only apply migration task if this is the master service
if (this.webserviceInfo.isDistributed()
&& !this.webserviceInfoDAO.isMaster(this.webserviceInfo.getWebserviceUUID())) {
// or if there was no data base initialization yet at all.
if (this.webserviceInfo.isDistributed()) {
if (this.webserviceInfoDAO.isInitialized()) {
final boolean isMaster = this.webserviceInfoDAO.isMaster(this.webserviceInfo.getWebserviceUUID());
if (!isMaster) {
log.info(
"Skip migration task since this is not a master instance: {}",
this.webserviceInfo.getWebserviceUUID());
log.info(
"Skip migration task since this is not a master instance: {}",
this.webserviceInfo.getWebserviceUUID());
return;
return;
}
}
}
if (this.cleanDBOnStartup) {
flyway.clean();
}
flyway.migrate();
} catch (final Exception e) {
log.error("Failed to apply migration task: ", e);
}

View file

@ -14,6 +14,8 @@ package ch.ethz.seb.sebserver.webservice.servicelayer.dao;
* the persistent data table. */
public interface WebserviceInfoDAO {
boolean isInitialized();
/** Register a SEB webservice within the persistent storage
*
* @param uuid A unique identifier that was generated by the webservice on startup

View file

@ -47,6 +47,20 @@ public class WebserviceInfoDAOImpl implements WebserviceInfoDAO {
this.forceMaster = forceMaster;
}
@Override
@Transactional
public boolean isInitialized() {
try {
this.webserviceServerInfoRecordMapper
.selectByExample()
.build()
.execute();
return true;
} catch (final Exception e) {
return false;
}
}
@Transactional
@Override
public boolean register(final String uuid, final String address) {

View file

@ -269,6 +269,10 @@ public class ExamAPI_V1_Controller {
final String pingNumString = request.getParameter(API.EXAM_API_PING_NUMBER);
final String instructionConfirm = request.getParameter(API.EXAM_API_PING_INSTRUCTION_CONFIRM);
if (log.isTraceEnabled()) {
log.trace("****************** SEB client connection: {}", connectionToken);
}
if (instructionConfirm != null) {
this.sebClientConnectionService.confirmInstructionDone(connectionToken, instructionConfirm);
}

View file

@ -11,6 +11,7 @@ logging.level.ch=INFO
logging.level.org.springframework.cache=INFO
logging.level.ch.ethz.seb.sebserver.webservice.servicelayer.lms.impl=DEBUG
logging.level.ch.ethz.seb.sebserver.webservice.servicelayer.session=DEBUG
logging.level.ch.ethz.seb.sebserver.webservice.weblayer.api.ExamAPI_V1_Controller=TRACE
sebserver.http.client.connect-timeout=150000
sebserver.http.client.connection-request-timeout=100000