Skip to content
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

#391 Update pipeline step messaging to be compatible with Java 17 #407

Merged
merged 1 commit into from
Oct 10, 2024
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
2 changes: 2 additions & 0 deletions DRAFT_RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ To reduce burden of upgrading aiSSEMBLE, the Baton project is used to automate t
| upgrade-v2-chart-files-aissemble-version-migration | Updates the Helm chart dependencies within your project's deployment resources (`<YOUR_PROJECT>-deploy/src/main/resources/apps/`) to use the latest version of the aiSSEMBLE |
| upgrade-v1-chart-files-aissemble-version-migration | Updates the docker image tags within your project's deployment resources (`<YOUR_PROJECT>-deploy/src/main/resources/apps/`) to use the latest version of the aiSSEMBLE |
| spark-version-upgrade-migration | Updates the Spark Application executor failure parameters to their new key name to ensure compatibility with spark `3.5` |
| spark-pipeline-messaging-pom-migration | Updates a Spark pipeline module `pom.xml` with the new CDI classes dependency to ensure messaging compatibility with Java 17 |
| spark-pipeline-messaging-cdi-factory-migration | Updates a Spark pipeline module `CdiContainerFactory.java` with the new CDI classes to ensure messaging compatibility with Java 17 |
| it-infrastructure-java-upgrade-migration | Updates the Java docker image version in the integration test docker module to JDK 17 |
| log4j-maven-shade-plugin-migration | Updates the Maven Shade Plugin with the new Log4j dependency information |

Expand Down
2 changes: 1 addition & 1 deletion build-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<version.plexus.component>2.1.1</version.plexus.component>
<version.postgresql>42.5.1</version.postgresql>
<version.resteasy>4.7.7.Final</version.resteasy>
<version.vertx>4.4.6</version.vertx>
<version.vertx>4.5.9</version.vertx>
<version.urllib3>^1.26.18</version.urllib3>
<version.fastapi>&gt;=0.95.0</version.fastapi>
<version.uvicorn>&gt;=0.18.0</version.uvicorn>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import io.smallrye.reactive.messaging.kafka.KafkaCDIEvents;
import io.smallrye.reactive.messaging.kafka.KafkaConnector;
import io.smallrye.reactive.messaging.kafka.commit.KafkaThrottledLatestProcessedCommit;
import io.smallrye.reactive.messaging.kafka.fault.KafkaFailStop;

/**
* {@link KafkaConnectorCdiContext} contains the classes needed by CDI when
Expand All @@ -34,6 +36,8 @@ public List<Class<?>> getCdiClasses() {
List<Class<?>> classes = new ArrayList<>();
classes.add(KafkaConnector.class);
classes.add(KafkaCDIEvents.class);
classes.add(KafkaThrottledLatestProcessedCommit.Factory.class);
classes.add(KafkaFailStop.Factory.class);
return classes;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
<artifactId>foundation-messaging-java</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<version>${version.jakarta.cdi}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client-jackson</artifactId>
Expand All @@ -37,10 +42,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.jboss.weld.environment.se.WeldContainer;
import com.boozallen.aissemble.core.cdi.CdiContainer;
import com.boozallen.aissemble.core.cdi.CdiContext;
import com.boozallen.aissemble.messaging.core.cdi.MessagingCdiContext;
import com.boozallen.aissemble.kafka.context.KafkaConnectorCdiContext;
#if ($pipeline.isAlertingSupportNeeded())
import com.boozallen.aissemble.alerting.core.cdi.AlertingCdiContext;
#end
Expand Down Expand Up @@ -58,9 +59,10 @@ public final class CdiContainerFactory {
protected static List<CdiContext> getContexts() {
List<CdiContext> contexts = new ArrayList<>();
contexts.add(new PipelinesCdiContext());
## TODO: would be nice to only include if we need messaging, but right now we assume messaging everywhere
## TODO: would be nice to only include if we need messaging, but right now we assume kafka messaging everywhere
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I: Space before ## TODO was being rendered in downstream template, resulting in the spacing being off in the following line.

contexts.add(new MessagingCdiContext());
## TODO: pull generated functionality into an overwritable template so we can adapt to MDA model changes
contexts.add(new KafkaConnectorCdiContext());
## TODO: pull generated functionality into an overwritable template so we can adapt to MDA model changes
#if ($pipeline.isAlertingSupportNeeded())
contexts.add(new AlertingCdiContext());
#end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,70 +1,70 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>main-chart</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>helm</executable>
<arguments>
<argument>template</argument>
<argument>${aissemble.helm.repo.protocol}://${aissemble.helm.repo}/aissemble-spark-application-chart</argument>
<argument>--version</argument>
<argument>${version.aissemble}</argument>
<argument>--values</argument>
<argument>${mainValuesPath}/${moduleArtifactId}-base-values.yaml,${mainValuesPath}/${moduleArtifactId}-dev-values.yaml</argument>
<argument>-s</argument>
<argument>templates/deployment.yaml</argument>
</arguments>
<outputFile>target/apps/${moduleArtifactId}-dev-chart.yaml</outputFile>
</configuration>
</execution>
<execution>
<id>test-chart</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>helm</executable>
<arguments>
<argument>template</argument>
<argument>${aissemble.helm.repo.protocol}://${aissemble.helm.repo}/aissemble-spark-application-chart</argument>
<argument>--version</argument>
<argument>${version.aissemble}</argument>
<argument>--values</argument>
<argument>${mainValuesPath}/${moduleArtifactId}-base-values.yaml,${testValuesPath}/${moduleArtifactId}-test-values.yaml</argument>
<argument>-s</argument>
<argument>templates/deployment.yaml</argument>
</arguments>
<outputFile>target/apps/${moduleArtifactId}-test-chart.yaml</outputFile>
</configuration>
</execution>
<execution>
<id>ci-chart</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>helm</executable>
<arguments>
<argument>template</argument>
<argument>${aissemble.helm.repo.protocol}://${aissemble.helm.repo}/aissemble-spark-application-chart</argument>
<argument>--version</argument>
<argument>${version.aissemble}</argument>
<argument>--values</argument>
<argument>${mainValuesPath}/${moduleArtifactId}-base-values.yaml,${mainValuesPath}/${moduleArtifactId}-ci-values.yaml</argument>
<argument>-s</argument>
<argument>templates/deployment.yaml</argument>
</arguments>
<outputFile>target/apps/${moduleArtifactId}-ci-chart.yaml</outputFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
Copy link
Contributor Author

@carter-cundiff carter-cundiff Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I: Fixed tabbing issue in downstream project poms where this whole block was not being indented

<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>main-chart</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>helm</executable>
<arguments>
<argument>template</argument>
<argument>${aissemble.helm.repo.protocol}://${aissemble.helm.repo}/aissemble-spark-application-chart</argument>
<argument>--version</argument>
<argument>${version.aissemble}</argument>
<argument>--values</argument>
<argument>${mainValuesPath}/${moduleArtifactId}-base-values.yaml,${mainValuesPath}/${moduleArtifactId}-dev-values.yaml</argument>
<argument>-s</argument>
<argument>templates/deployment.yaml</argument>
</arguments>
<outputFile>target/apps/${moduleArtifactId}-dev-chart.yaml</outputFile>
</configuration>
</execution>
<execution>
<id>test-chart</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>helm</executable>
<arguments>
<argument>template</argument>
<argument>${aissemble.helm.repo.protocol}://${aissemble.helm.repo}/aissemble-spark-application-chart</argument>
<argument>--version</argument>
<argument>${version.aissemble}</argument>
<argument>--values</argument>
<argument>${mainValuesPath}/${moduleArtifactId}-base-values.yaml,${testValuesPath}/${moduleArtifactId}-test-values.yaml</argument>
<argument>-s</argument>
<argument>templates/deployment.yaml</argument>
</arguments>
<outputFile>target/apps/${moduleArtifactId}-test-chart.yaml</outputFile>
</configuration>
</execution>
<execution>
<id>ci-chart</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>helm</executable>
<arguments>
<argument>template</argument>
<argument>${aissemble.helm.repo.protocol}://${aissemble.helm.repo}/aissemble-spark-application-chart</argument>
<argument>--version</argument>
<argument>${version.aissemble}</argument>
<argument>--values</argument>
<argument>${mainValuesPath}/${moduleArtifactId}-base-values.yaml,${mainValuesPath}/${moduleArtifactId}-ci-values.yaml</argument>
<argument>-s</argument>
<argument>templates/deployment.yaml</argument>
</arguments>
<outputFile>target/apps/${moduleArtifactId}-ci-chart.yaml</outputFile>
</configuration>
</execution>
</executions>
</plugin>
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@
<groupId>com.boozallen.aissemble</groupId>
<artifactId>foundation-metadata-producer</artifactId>
</dependency>
<dependency>
<groupId>com.boozallen.aissemble</groupId>
<artifactId>extensions-messaging-kafka</artifactId>
</dependency>
Copy link
Contributor

@csun-cpointe csun-cpointe Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: should this be a default inclusion for all spark pipeline?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Unfortunately all our pipelines include:

<dependency>
    <groupId>io.smallrye.reactive</groupId>
    <artifactId>smallrye-reactive-messaging-in-memory</artifactId>
    <version>${version.smallrye.reactive.messaging}</version>
    <scope>test</scope>
</dependency>

by default. So in order to remain compatible with that, we must include the new extensions-messaging-kafka by default.

<dependency>
<groupId>com.boozallen.aissemble</groupId>
<artifactId>extensions-data-delivery-spark</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ import ${basePackage}.${step.capitalizedName};
#foreach ($store in $pipeline.fileStores)
import ${basePackage}.filestore.${store.fullName};
#end
import com.boozallen.aissemble.core.cdi.CdiContext;

import io.smallrye.config.inject.ConfigExtension;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I: Removed unused import

import com.boozallen.aissemble.core.cdi.CdiContext;
import com.boozallen.aiops.data.delivery.messaging.PipelineMessagingConfig;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ package ${basePackage}.cdi;
import java.util.List;

import jakarta.enterprise.inject.spi.Extension;
import com.boozallen.aissemble.core.filestore.EnvironmentVariableFileStoreConfig;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I: Removed unused import


import com.boozallen.aissemble.core.metadata.producer.MetadataProducer;
import io.smallrye.reactive.messaging.kafka.KafkaCDIEvents;
import io.smallrye.reactive.messaging.kafka.KafkaConnector;

/**
* Configures the CDI context for this application.
Expand All @@ -26,8 +23,6 @@ public class PipelinesCdiContext extends PipelinesCdiContextBase {
List<Class<?>> customBeans = super.getCdiClasses();

// Add any custom CDI classes here
customBeans.add(KafkaConnector.class);
customBeans.add(KafkaCDIEvents.class);
customBeans.add(MetadataProducer.class);

return customBeans;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.boozallen.aissemble.upgrade.migration;
/*-
* #%L
* aiSSEMBLE::Foundation::Upgrade
* %%
* Copyright (C) 2021 Booz Allen
* %%
* This software package is licensed under the Booz Allen Public License. All Rights Reserved.
* #L%
*/
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.technologybrewery.baton.BatonException;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.stream.Stream;

public abstract class AbstractPomMigration extends AbstractAissembleMigration {
protected static final Logger logger = LoggerFactory.getLogger(AbstractPomMigration.class);

public static final String POM = "pom";
public static final String GUARANTEED_TAG = "<modelVersion>";

protected String indent;

protected void detectAndSetIndent(File file) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A: Probably a candidate for Baton's PomHelper. Do I recognize this from one of the patch release branches? If so, I might already have a branch locally to add this to Baton.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I copied this from an old branch. Guess it never got added to dev after a patch release.

try (Stream<String> lines = Files.lines(file.toPath())) {
indent = lines.filter(line -> line.contains(GUARANTEED_TAG))
.findFirst()
.map(artifact -> artifact.substring(0, artifact.indexOf(GUARANTEED_TAG)))
.orElse(null);
if (StringUtils.isEmpty(indent)) {
logger.info("Failed to detect indent for POM. Using default. {}", file);
indent = " ";
}
} catch (IOException e) {
throw new BatonException("Failed to get indent from POM:" + file, e);
}
}
}
Loading