Skip to content

Development: Add Helios push based lifecycle monitoring with manual DB migration status events #10873

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

Merged
merged 21 commits into from
Jul 11, 2025
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
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,9 @@ dependencies {
implementation "org.springframework.security:spring-security-messaging:${spring_security_version}"
implementation "org.springframework.security:spring-security-ldap:${spring_security_version}"

// Helios push-based status updates
implementation "de.tum.cit.aet:helios-status-spring-starter:${helios_status_version}"

implementation "org.opensaml:opensaml-saml-api:${opensaml_version}"
implementation "org.opensaml:opensaml-saml-impl:${opensaml_version}"

Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ netty_version=4.1.118.Final
mysql_version=9.3.0
micrometer_version=1.15.1
snakeyaml_version=2.4
helios_status_version=1.1.0

# testing
# make sure both versions are compatible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static tech.jhipster.config.JHipsterConstants.SPRING_PROFILE_TEST;

import java.sql.SQLException;
import java.util.Optional;

import javax.sql.DataSource;

Expand All @@ -24,6 +25,7 @@
import org.springframework.core.env.Profiles;

import de.tum.cit.aet.artemis.core.config.migration.DatabaseMigration;
import de.tum.cit.aet.helios.HeliosClient;
import liquibase.Scope;
import liquibase.SingletonScopeManager;
import liquibase.integration.spring.SpringLiquibase;
Expand All @@ -41,15 +43,18 @@ public class LiquibaseConfiguration {

private final BuildProperties buildProperties;

private final Optional<HeliosClient> optionalHeliosClient;

private DataSource dataSource;

private DatabaseMigration databaseMigration;

private String currentVersionString;

public LiquibaseConfiguration(Environment env, BuildProperties buildProperties) {
public LiquibaseConfiguration(Environment env, BuildProperties buildProperties, Optional<HeliosClient> optionalHeliosClient) {
this.env = env;
this.buildProperties = buildProperties;
this.optionalHeliosClient = optionalHeliosClient;
}

/**
Expand All @@ -69,7 +74,7 @@ public SpringLiquibase liquibase(@LiquibaseDataSource ObjectProvider<DataSource>
this.currentVersionString = buildProperties.getVersion();

if (!env.acceptsProfiles(Profiles.of(SPRING_PROFILE_TEST))) {
this.databaseMigration = new DatabaseMigration(currentVersionString, dataSource);
this.databaseMigration = new DatabaseMigration(currentVersionString, dataSource, optionalHeliosClient);
databaseMigration.checkMigrationPath();
}

Expand Down Expand Up @@ -133,9 +138,11 @@ public void storeCurrentVersionToDatabase(ApplicationReadyEvent event) {

preparedStatement.executeUpdate();
connection.commit(); // Ensure the transaction is committed.
optionalHeliosClient.ifPresent(HeliosClient::pushDbMigrationFinished);
}
catch (SQLException e) {
log.error("Failed to store the current version to the database", e);
optionalHeliosClient.ifPresent(HeliosClient::pushDbMigrationFailed);
throw new RuntimeException("Error updating the application version in the database", e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import javax.sql.DataSource;

Expand All @@ -13,6 +14,8 @@

import com.vdurmont.semver4j.Semver;

import de.tum.cit.aet.helios.HeliosClient;

/**
* Represents a migration path that defines the necessary steps for database migration before
* updating to a new major version. This class is pivotal in ensuring that administrators install
Expand Down Expand Up @@ -93,9 +96,12 @@ public class DatabaseMigration {

private String previousVersionString;

public DatabaseMigration(String currentVersionString, DataSource dataSource) {
private final Optional<HeliosClient> optionalHeliosClient;

public DatabaseMigration(String currentVersionString, DataSource dataSource, Optional<HeliosClient> optionalHeliosClient) {
this.currentVersionString = currentVersionString;
this.dataSource = dataSource;
this.optionalHeliosClient = optionalHeliosClient;

// Initialize migration paths here in the correct order
migrationPaths.add(new MigrationPath("5.12.9")); // required for migration to 6.0.0 until 7.0.0
Expand All @@ -120,6 +126,7 @@ public void checkMigrationPath() {

if (previousVersionString == null) {
log.info("Migration path check: Not necessary");
optionalHeliosClient.ifPresent(HeliosClient::pushDbMigrationStarted);
return;
}

Expand All @@ -129,6 +136,7 @@ public void checkMigrationPath() {
if (currentVersion.isGreaterThanOrEqualTo(path.upgradeVersion) && currentVersion.isLowerThan(path.nextUpgradeVersion)) {
if (previousVersion.isLowerThan(path.requiredVersion)) {
log.error(path.errorMessage);
optionalHeliosClient.ifPresent(HeliosClient::pushDbMigrationFailed);
System.exit(15);
}
else if (previousVersion.isEqualTo(path.requiredVersion)) {
Expand All @@ -138,6 +146,8 @@ else if (previousVersion.isEqualTo(path.requiredVersion)) {
}
}
}

optionalHeliosClient.ifPresent(HeliosClient::pushDbMigrationStarted);
}

/**
Expand Down Expand Up @@ -234,6 +244,7 @@ private void updateInitialChecksum(String newVersion) {
}
catch (SQLException e) {
log.error("Cannot update checksum for initial schema migration: {}", e.getMessage());
optionalHeliosClient.ifPresent(HeliosClient::pushDbMigrationFailed);
System.exit(11);
}
}
Expand Down Expand Up @@ -262,6 +273,7 @@ private Statement createStatement() throws SQLException {
}
catch (Exception e) {
log.error("Cannot connect to the database {} (This typically indicates that the database is not running or there are permission issues", e.getMessage());
optionalHeliosClient.ifPresent(HeliosClient::pushDbMigrationFailed);
System.exit(10);
}
return null;
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/config/application-buildagent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,7 @@ management:
eureka:
client:
enabled: true

helios:
status:
enabled: false
4 changes: 4 additions & 0 deletions src/main/resources/config/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,7 @@ artemis:
enabled: false # Disable sending any telemetry information to the telemetry service by setting this to false
sendAdminDetails: false # Include the admins email and name in the telemetry data. Set to false to disable
destination: https://telemetry.artemis.cit.tum.de

helios:
status:
enabled: false
7 changes: 7 additions & 0 deletions src/main/resources/config/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -370,3 +370,10 @@ eureka:
git-version: ${git.commit.id.describe:}
git-commit: ${git.commit.id.abbrev:}
git-branch: ${git.branch:}

# Helios configuration
# It is enabled and all the values are set by the ansible
# Refer to the ansible repository https://github.com/ls1intum/artemis-ansible
helios:
status:
enabled: false
Loading