Skip to content

Commit

Permalink
migrate configserver to spring boot 3.1.6 and Java 17 (#1627)
Browse files Browse the repository at this point in the history
  • Loading branch information
TitusLabs authored Dec 5, 2023
1 parent d3a9f36 commit 7352128
Show file tree
Hide file tree
Showing 100 changed files with 475 additions and 525 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/configuration_ui_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
test:
name: Test
runs-on: ubuntu-latest
container: openjdk:8-jdk
container: eclipse-temurin:17
env:
working-directory: ./components/inspectit-ocelot-configurationserver-ui
steps:
Expand All @@ -27,7 +27,7 @@ jobs:
runs-on: ubuntu-latest
env:
working-directory: ./components/inspectit-ocelot-configurationserver-ui
container: openjdk:8-jdk
container: eclipse-temurin:17
steps:
- uses: actions/checkout@v3
- name: Grant execute permission for gradlew
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/configurationserver_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
env:
working-directory: ./components/inspectit-ocelot-configurationserver
container: openjdk:8-jdk
container: eclipse-temurin:17
steps:
- uses: actions/checkout@v2
- name: Grant execute permission for gradlew
Expand All @@ -38,7 +38,7 @@ jobs:
runs-on: ubuntu-latest
env:
working-directory: ./components/inspectit-ocelot-configurationserver
container: openjdk:8-jdk
container: eclipse-temurin:17
steps:
- uses: actions/checkout@v2
- name: Grant execute permission for gradlew
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
/nbdist/
/.nb-gradle/

/working_directory/
*working_directory/
/gradle/*.versions.updates.toml
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ If you need additional or in-depth information on the actual implementation of i

Important tasks to check first are `dependencyUpdates` or `dependencyUpdates[Major|Minor]` for newer (patch, minor, major)
versions, the `outdated` task for node modules and `dependencyCheckAnalyze` or `dependencyCheckAggregate` for security issues in the used dependencies (including node modules).
All dependency versions are maintained in one [catalog](gradle/libs.version.toml) file. The task `versionCatalogUpdate[ConfigServerLibs] --interactive` creates a copy of the catalog file with all version
updates. This file can also be edited manually and be applied with `versionCatalogApplyUpdates[ConfigServerLibs]`.

## FAQ

Expand Down
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ versionCatalogUpdate {
// keep all plugins that aren't used in the project
keepUnusedPlugins = true
}

versionCatalogs {
configServerLibs {
catalogFile = file("gradle/configserverlibs.versions.toml")
}
}
}

tasks.withType(DependencyUpdatesTask).configureEach {
Expand Down
70 changes: 33 additions & 37 deletions components/inspectit-ocelot-configurationserver/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import org.springframework.boot.gradle.tasks.bundling.BootJar

plugins {
alias(libs.plugins.comPalantirDocker)
alias(libs.plugins.orgSpringframeworkBoot)
alias(configServerLibs.plugins.orgSpringframeworkBoot)
alias(libs.plugins.orgCyclonedxBom)
alias(libs.plugins.ioSpringDependencyManagement)
alias(configServerLibs.plugins.ioSpringDependencyManagement)
}

apply plugin: 'idea'
Expand All @@ -31,6 +31,7 @@ tasks.register('bootJarWithFrontend', BootJar) {
into('static/ui')
}

getTargetJavaVersion().set(JavaVersion.current())
mainClass = "${serverMainClass}"

with bootJar
Expand All @@ -48,9 +49,12 @@ cyclonedxBom {
repositories {
mavenCentral()
}
//to guarantee that the Configuration Server is compatible with Java 8 runtime environments
sourceCompatibility = 1.8 // Java version compatibility to use when compiling Java source.
targetCompatibility = 1.8 // Java version to generate classes for.

java {
sourceCompatibility = 17
targetCompatibility = 17
}

test {
useJUnitPlatform()

Expand All @@ -59,6 +63,7 @@ test {
}
}


dependencies {
compileOnly libs.orgProjectlombokLombok
annotationProcessor libs.orgProjectlombokLombok
Expand All @@ -71,52 +76,43 @@ dependencies {
// only use a compile-only (see details over there)
libs.ioOpentelemetryOpentelemetrySdkMetrics,
project(':inspectit-ocelot-configdocsgenerator'),
configServerLibs.orgSpringframeworkBootSpringBootStarterWeb,
configServerLibs.orgSpringframeworkBootSpringBootStarterDataJpa,
configServerLibs.orgSpringframeworkBootSpringBootStartervalidation,
configServerLibs.orgSpringframeworkSecuritySpringSecurityWeb,
configServerLibs.orgSpringframeworksecuritySpringSecurityConfig,
configServerLibs.orgSpringframeworkLdapSpringLdapCore,
configServerLibs.orgSpringframeworkSecuritySpringSecurityLdap,
configServerLibs.orgSpringframeworkBootSpringBootStarterActuator,

libs.orgSpringframeworkBootSpringBootStarterWeb,
libs.orgSpringframeworkBootSpringBootStarterDataJpa,
libs.orgSpringframeworkBootSpringBootStartervalidation,
libs.orgSpringframeworkSecuritySpringSecurityWeb,
libs.orgSpringframeworksecuritySpringSecurityConfig,
libs.orgSpringframeworkLdapSpringLdapCore,
libs.orgSpringframeworkSecuritySpringSecurityLdap,
libs.orgSpringframeworkBootSpringBootStarterActuator,

libs.orgYamlSnakeyaml,
configServerLibs.orgYamlSnakeyaml,

libs.orgApacheHttpcomponentsHttpclient, //Required for PATCH-Requests

libs.orgXerialSqliteJdbc,
libs.comGithubGwennSqliteDialect,
libs.bundles.jsonwebtoken,
libs.commonsIo,
libs.orgApacheCommonsCommonsLang3,
libs.orgFlywaydbFlywayCore,
libs.bundles.jgit,
libs.comGoogleCodeGson,
configServerLibs.orgXerialSqliteJdbc,
configServerLibs.orgHibernateOrmHibernateCommunityDialects,
configServerLibs.bundles.jsonwebtoken,
configServerLibs.commonsIo,
configServerLibs.orgApacheCommonsCommonsLang3,
configServerLibs.orgFlywaydbFlywayCore,
configServerLibs.bundles.jgit,
configServerLibs.comGoogleCodeGson,

// swagger
libs.orgSpringdocSpringdocOpenapiUi,

libs.comGoogleGuavaConfigServer
configServerLibs.comGoogleGuava
)
testImplementation(
libs.orgSpringframeworkBootSpringBootStarterTest,
libs.orgSpringframeworkSecuritySpringSecurityTest,
configServerLibs.orgSpringframeworkBootSpringBootStarterTest,
configServerLibs.orgSpringframeworkSecuritySpringSecurityTest,
configServerLibs.orgMockitoMockitoJunitJupiter,
configServerLibs.comH2databaseH2,
libs.orgJunitJupiterJunitJupiter,
libs.orgJunitJupiterJunitJupiterApi,
libs.orgMockitoMockitoJunitJupiter,
libs.comH2databaseH2,
libs.orgAwaitility
)
testRuntimeOnly libs.orgJunitJupiterJunitJupiterEngine

constraints {
implementation(libs.orgYamlSnakeyaml) {
because 'spring related'
}
testImplementation(libs.comH2databaseH2) {
because 'If we stick to the version provided by Spring Boot Bom database initialization scripts will fail'
}
}
}

tasks.register('copyServerJar', Copy) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openjdk:11-jre-slim
FROM eclipse-temurin:17

ADD ./ /
ENTRYPOINT ["sh", "/entrypoint.sh"]
ENTRYPOINT ["sh", "/entrypoint.sh"]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
Expand All @@ -16,9 +15,8 @@
/**
* The application class of the configuration server.
*/
@SpringBootApplication
@SpringBootApplication(exclude = {ErrorMvcAutoConfiguration.class})
@Slf4j
@EnableAutoConfiguration(exclude = {ErrorMvcAutoConfiguration.class})
public class ConfigurationServer {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.RemovalListener;
import com.google.common.cache.RemovalNotification;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
Expand All @@ -13,7 +14,6 @@
import rocks.inspectit.ocelot.commons.models.command.CommandResponse;
import rocks.inspectit.ocelot.config.model.InspectitServerSettings;

import javax.annotation.PostConstruct;
import java.time.Duration;
import java.util.List;
import java.util.UUID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import rocks.inspectit.ocelot.commons.models.command.Command;
import rocks.inspectit.ocelot.config.model.AgentCommandSettings;
import rocks.inspectit.ocelot.config.model.InspectitServerSettings;

import javax.annotation.PostConstruct;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.LinkedBlockingQueue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import org.springframework.web.context.request.async.DeferredResult;
import rocks.inspectit.ocelot.agentcommunication.handlers.CommandHandler;
import rocks.inspectit.ocelot.commons.models.command.Command;
import rocks.inspectit.ocelot.commons.models.command.impl.ListClassesCommand;
import rocks.inspectit.ocelot.commons.models.command.CommandResponse;
import rocks.inspectit.ocelot.commons.models.command.impl.ListClassesCommand;
import rocks.inspectit.ocelot.config.model.InspectitServerSettings;

import java.time.Duration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import org.springframework.web.context.request.async.DeferredResult;
import rocks.inspectit.ocelot.agentcommunication.handlers.CommandHandler;
import rocks.inspectit.ocelot.commons.models.command.Command;
import rocks.inspectit.ocelot.commons.models.command.impl.PingCommand;
import rocks.inspectit.ocelot.commons.models.command.CommandResponse;
import rocks.inspectit.ocelot.commons.models.command.impl.PingCommand;
import rocks.inspectit.ocelot.config.model.InspectitServerSettings;

import java.time.Duration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
Expand All @@ -16,7 +17,6 @@
import rocks.inspectit.ocelot.mappings.AgentMappingSerializer;
import rocks.inspectit.ocelot.mappings.model.AgentMapping;

import javax.annotation.PostConstruct;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void run() {
.build();
newConfigurations.add(agentConfiguration);
} catch (Exception e) {
log.error("Could not load agent mapping '{}'.", mapping.getName(), e);
log.error("Could not load agent mapping '{}'.", mapping.name(), e);
}
}
onTaskSuccess(newConfigurations);
Expand All @@ -97,7 +97,7 @@ String loadConfigForMapping(AgentMapping mapping) {
AbstractFileAccessor fileAccessor = getFileAccessorForMapping(mapping);

LinkedHashSet<String> allYamlFiles = new LinkedHashSet<>();
for (String path : mapping.getSources()) {
for (String path : mapping.sources()) {
if (isCanceled()) {
return null;
}
Expand All @@ -115,18 +115,11 @@ String loadConfigForMapping(AgentMapping mapping) {
}

private AbstractFileAccessor getFileAccessorForMapping(AgentMapping mapping) {
AbstractFileAccessor fileAccessor;
switch (mapping.getSourceBranch()) {
case LIVE:
fileAccessor = fileManager.getLiveRevision();
break;
case WORKSPACE:
fileAccessor = fileManager.getWorkspaceRevision();
break;
default:
throw new UnsupportedOperationException("Unhandled branch: " + mapping.getSourceBranch());
}
return fileAccessor;
return switch (mapping.sourceBranch()) {
case LIVE -> fileManager.getLiveRevision();
case WORKSPACE -> fileManager.getWorkspaceRevision();
default -> throw new UnsupportedOperationException("Unhandled branch: " + mapping.sourceBranch());
};
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package rocks.inspectit.ocelot.agentstatus;

import com.google.common.base.Preconditions;
import jakarta.validation.constraints.NotBlank;
import lombok.EqualsAndHashCode;
import lombok.Value;
import org.apache.commons.lang3.StringUtils;

import javax.validation.constraints.NotBlank;
import java.util.Map;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import rocks.inspectit.ocelot.agentconfiguration.AgentConfiguration;
import rocks.inspectit.ocelot.commons.models.health.AgentHealth;
import rocks.inspectit.ocelot.config.model.InspectitServerSettings;

import javax.annotation.PostConstruct;
import java.util.Collection;
import java.util.Date;
import java.util.Map;
Expand Down Expand Up @@ -65,9 +65,9 @@ public void notifyAgentConfigurationFetched(Map<String, String> agentAttributes,
.metaInformation(metaInformation)
.attributes(agentAttributes)
.lastConfigFetch(new Date())
.mappingName(resultConfiguration == null ? null : resultConfiguration.getMapping().getName())
.mappingName(resultConfiguration == null ? null : resultConfiguration.getMapping().name())
.sourceBranch(resultConfiguration == null ? null : resultConfiguration.getMapping()
.getSourceBranch()
.sourceBranch()
.getBranchName())
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public class ModelAutoCompleter implements AutoCompleter {

@Override
public List<String> getSuggestions(List<String> path) {
if (CollectionUtils.isEmpty(path) || (path.size() == 1 && path.get(0).equals(""))) {
if (CollectionUtils.isEmpty(path) || (path.size() == 1 && path.get(0).isEmpty())) {
return Collections.singletonList(INSPECTIT);
} else if (!path.isEmpty() && !path.get(0).equals(INSPECTIT)) {
} else if (!path.get(0).equals(INSPECTIT)) {
return Collections.emptyList();
}
return collectProperties(path.subList(1, path.size()));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package rocks.inspectit.ocelot.autocomplete.util;

import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
Expand All @@ -8,7 +9,6 @@
import rocks.inspectit.ocelot.file.FileManager;
import rocks.inspectit.ocelot.file.accessor.git.RevisionAccess;

import javax.annotation.PostConstruct;
import java.util.Collection;
import java.util.Collections;
import java.util.concurrent.ExecutorService;
Expand Down
Loading

0 comments on commit 7352128

Please sign in to comment.