Skip to content

Commit 28f6873

Browse files
Merge pull request #126 from boozallen/111-image-names-baton-migration
#111 Baton Script to Update Image Names
2 parents 3047c97 + dfb7cf8 commit 28f6873

File tree

18 files changed

+277
-20
lines changed

18 files changed

+277
-20
lines changed

DRAFT_RELEASE_NOTES.md

+16-15
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,22 @@ The following steps will upgrade your project to 1.7. These instructions consist
9090
## Automatic Upgrades
9191
To reduce burden of upgrading aiSSEMBLE, the Baton project is used to automate the migration of some files to the new version. These migrations run automatically when you build your project, and are included by default when you update the `build-parent` version in your root POM. Below is a description of all of the Baton migrations that are included with this version of aiSSEMBLE.
9292

93-
| Migration Name | Description |
94-
|-------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
95-
| upgrade-tiltfile-aissemble-version-migration | Updates the aiSSEMBLE version within your project's Tiltfile |
96-
| 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 |
97-
| 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 |
98-
| upgrade-mlflow-v2-external-s3-migration | Update the mlflow V2 deployment (if present) in your project to utilize Localstack for local development and SealedSecrets for remote deployments |
99-
| upgrade-spark-application-s3-migration | Update the pipeline SparkApplication(s) (if present) in your project to utilize Localstack for local development and SealedSecrets for remote deployments |
100-
| upgrade-foundation-extension-python-package-migration | Updates the pyproject.toml files within your projects pipelines folder (<YOUR_PROJECT>-pipelines) to use the updated aiSSEMBLE foundation and extension Python packages with the latest naming convention |
101-
| upgrade-helm-chart-names-migration | Updates the Chart.yaml and values*.yaml files within your project's deploy folder (<YOUR_PROJECT>-deploy) to use the new Helm chart naming convention (`aissemble-<chart-name>-chart`). |
102-
| upgrade-helm-module-names-migration | Updates the Chart.yaml and values*.yaml files within your project's deploy folder (<YOUR_PROJECT>-deploy) to use the new Helm module naming convention (`aissemble-<chart-name>-chart`) |
103-
| upgrade-helm-chart-repository-url-migration | Updates the Helm repository URL within your project's deploy Chart.yaml file to point to ghcr.io. Only runs if the previous Helm chart repository URL is passed in through the `oldHelmRepositoryUrl` system property (using `-DoldHelmRepositoryUrl`) |
104-
| upgrade-dockerfile-pip-install-migration | Updates dockerfiles such that python dependency installations fail during the build, rather than at runtime |
105-
| enable-habushu-build-cache-migration | Updates the `pom.xml` file for any Habushu-managed modules to ensure that the build directory is specified. |
106-
| data-lineage-package-import-migration | Updates the package imports for all java files that are referencing `com.boozallen.aissemble.data.lineage`. |
107-
| upgrade-spark-application-exec-migration. | Fixes the exec-maven-plugin executions in pipeline POMs to use the new ghcr.io aissemble-spark-application-chart package |
93+
| Migration Name | Description |
94+
|------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
95+
| upgrade-tiltfile-aissemble-version-migration | Updates the aiSSEMBLE version within your project's Tiltfile |
96+
| 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 |
97+
| 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 |
98+
| upgrade-mlflow-v2-external-s3-migration | Update the mlflow V2 deployment (if present) in your project to utilize Localstack for local development and SealedSecrets for remote deployments |
99+
| upgrade-spark-application-s3-migration | Update the pipeline SparkApplication(s) (if present) in your project to utilize Localstack for local development and SealedSecrets for remote deployments |
100+
| upgrade-foundation-extension-python-package-migration | Updates the pyproject.toml files within your projects pipelines folder (<YOUR_PROJECT>-pipelines) to use the updated aiSSEMBLE foundation and extension Python packages with the latest naming convention |
101+
| upgrade-helm-chart-names-migration | Updates the Chart.yaml and values*.yaml files within your project's deploy folder (<YOUR_PROJECT>-deploy) to use the new Helm chart naming convention (`aissemble-<chart-name>-chart`). |
102+
| upgrade-helm-module-names-migration | Updates the Chart.yaml and values*.yaml files within your project's deploy folder (<YOUR_PROJECT>-deploy) to use the new Helm module naming convention (`aissemble-<chart-name>-chart`) |
103+
| upgrade-helm-chart-repository-url-migration | Updates the Helm repository URL within your project's deploy Chart.yaml file to point to ghcr.io. Only runs if the previous Helm chart repository URL is passed in through the `oldHelmRepositoryUrl` system property (using `-DoldHelmRepositoryUrl`) |
104+
| upgrade-dockerfile-pip-install-migration | Updates dockerfiles such that python dependency installations fail during the build, rather than at runtime |
105+
| enable-habushu-build-cache-migration | Updates the `pom.xml` file for any Habushu-managed modules to ensure that the build directory is specified. |
106+
| data-lineage-package-import-migration | Updates the package imports for all java files that are referencing `com.boozallen.aissemble.data.lineage`. |
107+
| upgrade-spark-application-exec-migration. | Fixes the exec-maven-plugin executions in pipeline POMs to use the new ghcr.io aissemble-spark-application-chart package |
108+
| upgrade-project-specific-image-naming-convention-migration | Updates the project specific aiSSEMBLE generated image names by removing the `boozallen/` prefix |
108109

109110
To deactivate any of these migrations, add the following configuration to the `baton-maven-plugin` within your root `pom.xml`:
110111

docs/modules/ROOT/pages/containers.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Example:
100100
Example:
101101
# airflow
102102
docker_build(
103-
ref='boozallen/example-airflow-docker',
103+
ref='example-airflow-docker',
104104
context='example-docker/example-airflow-docker',
105105
build_args=build_args,
106106
dockerfile='example-docker/example-airflow-docker/src/main/resources/docker/Dockerfile'

docs/modules/ROOT/pages/guides/guides-efficient-debugging.adoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ sync_properties = sync(
193193
194194
# project-name-quick-inference-docker
195195
docker_build_with_restart(
196-
ref='boozallen/project-name-quick-inference-docker',
196+
ref='project-name-quick-inference-docker',
197197
context='project-name-docker/project-name-quick-inference-docker',
198198
live_update=[sync_properties,
199199
run('cd /modules/quick-inference; for x in *.whl; do pip install $x --no-cache-dir --no-deps --force-reinstall; done')
@@ -223,7 +223,7 @@ tests a module called `quick inference` and copies the resulting `dist` director
223223
remote_path='/modules/quick-inference')`: This specifies the locations that need to be synchronized. It ensures that
224224
the `dist` directory from the previous step is kept in sync with a specific directory on the remote target.
225225
* `docker_build_with_restart(
226-
ref='boozallen/project-name-quick-inference-docker',
226+
ref='project-name-quick-inference-docker',
227227
context='project-name-docker/project-name-quick-inference-docker',...)`: This section is referenced earlier in the
228228
code in `load('ext://restart_process', 'docker_build_with_restart')`. The configuration includes the image reference,
229229
file location, and additional options and defines the setup of a Docker container with live update functionality.

extensions/extensions-helm/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ to leverage the new Helm pattern for the aiSSEMBLE module at hand:
3333
* `local('helm dependency build <project-name>-deploy/src/main/resources/apps/<module-name>') `
3434
* Below the module's corresponding `k8s_resource()` call, add the following line to manually build the docker image
3535
for the migrated module:
36-
* `local('docker build -f <project-name>-docker/<project-name>-<module-name>-docker/target/Dockerfile -t boozallen/<project-name>-<module-name>:latest <project-name>-docker/<project-name>-<module-name>-docker/ --build-arg VERSION_AISSEMBLE=<current aiSSEMBLE version>') `
36+
* `local('docker build -f <project-name>-docker/<project-name>-<module-name>-docker/target/Dockerfile -t <project-name>-<module-name>:latest <project-name>-docker/<project-name>-<module-name>-docker/ --build-arg VERSION_AISSEMBLE=<current aiSSEMBLE version>') `
3737
* Note: this step is not always necessary, and only needed when the chart is dependent on an image being built in
3838
a downstream project
3939

foundation/foundation-mda/src/main/java/com/boozallen/aiops/mda/generator/InferenceDockerResourcesGenerator.java

+3
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ public class InferenceDockerResourcesGenerator extends AbstractResourcesGenerato
3434

3535

3636
private static final Logger logger = LoggerFactory.getLogger(InferenceDockerResourcesGenerator.class);
37+
protected static final String DOCKER_PROJECT_REPOSITORY_URL = "dockerProjectRepositoryUrl";
3738

3839
@Override
3940
public void generate(GenerationContext context) {
4041
String rootModuleName = context.getRootArtifactId();
42+
String dockerProjectRepositoryUrl = context.getPropertyVariables().get(DOCKER_PROJECT_REPOSITORY_URL);
4143

4244
if (rootModuleName == null || rootModuleName.isEmpty()) {
4345
logger.error("Root module could not be determined!");
@@ -49,6 +51,7 @@ public void generate(GenerationContext context) {
4951
VelocityContext vc = getNewVelocityContext(context);
5052
vc.put(VelocityProperty.INFERENCE_MODULE, inferenceModule);
5153
vc.put(VelocityProperty.INFERENCE_MODULE_SNAKE_CASE, PythonGeneratorUtils.normalizeToPythonCase(inferenceModule));
54+
vc.put(VelocityProperty.DOCKER_PROJECT_REPOSITORY_URL, dockerProjectRepositoryUrl);
5255

5356
generateFile(context, vc);
5457
}

foundation/foundation-mda/src/main/java/com/boozallen/aiops/mda/generator/SparkApplicationGenerator.java

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public class SparkApplicationGenerator extends AbstractResourcesGenerator {
4646
protected ManualActionNotificationService manualActionNotificationService = new ManualActionNotificationService();
4747

4848
private final SparkDependencyConfiguration config = SparkDependencyConfiguration.getInstance();
49+
protected static final String DOCKER_PROJECT_REPOSITORY_URL = "dockerProjectRepositoryUrl";
4950

5051
private void handlePySpark(VelocityContext vc, GenerationContext context) {
5152
Pipeline pipeline = PipelineUtils.getTargetedPipeline(context, metadataContext);
@@ -134,10 +135,12 @@ public void generate(GenerationContext context) {
134135
}
135136

136137
final String projectName = context.getRootArtifactId();
138+
String dockerProjectRepositoryUrl = context.getPropertyVariables().get(DOCKER_PROJECT_REPOSITORY_URL);
137139

138140
vc.put(VelocityProperty.SPARK_APPLICATION_NAME, context.getArtifactId());
139141
vc.put(VelocityProperty.PROJECT_NAME, projectName);
140142
vc.put(VelocityProperty.PIPELINE, pipeline.getName());
143+
vc.put(VelocityProperty.DOCKER_PROJECT_REPOSITORY_URL, dockerProjectRepositoryUrl);
141144

142145
if (!"test".equalsIgnoreCase(context.getArtifactType()) && SparkStorageEnum.S3LOCAL == metamodelRepository.getDeploymentConfigurationManager().getSparkDeploymentConfiguration().getStorageType()) {
143146
vc.put(VelocityProperty.USE_S3_LOCAL, true);

foundation/foundation-mda/src/main/resources/templates/data-delivery-pyspark/pipeline.pom.xml.vm

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<targetPipeline>${pipeline.name}</targetPipeline>
3030
<behaveFeature>data_delivery</behaveFeature>
3131
<aissembleVersion>${version.aissemble}</aissembleVersion>
32+
<dockerProjectRepositoryUrl>${docker.project.repository.url}</dockerProjectRepositoryUrl>
3233
</propertyVariables>
3334
<!-- see ${parentArtifactId} for base configuration settings -->
3435
</configuration>

foundation/foundation-mda/src/main/resources/templates/data-delivery-spark/pipeline.pom.xml.vm

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<propertyVariables>
2828
<targetPipeline>${pipeline.name}</targetPipeline>
2929
<aissembleVersion>${version.aissemble}</aissembleVersion>
30+
<dockerProjectRepositoryUrl>${docker.project.repository.url}</dockerProjectRepositoryUrl>
3031
</propertyVariables>
3132
<!-- see ${parentArtifactId} for base configuration settings -->
3233
</configuration>

foundation/foundation-mda/src/main/resources/templates/general-docker/inference.docker.pom.xml.vm

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
<configuration>
2626
<basePackage>${basePackage}</basePackage>
2727
<profile>aissemble-inference-docker</profile>
28+
<propertyVariables>
29+
<dockerProjectRepositoryUrl>${docker.project.repository.url}</dockerProjectRepositoryUrl>
30+
</propertyVariables>
2831
</configuration>
2932
</plugin>
3033
<plugin>

foundation/foundation-mda/src/main/resources/templates/inference/inference.perceptor.yaml.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ wrapper: prime
44
language: python
55

66
name: "${artifactId}"
7-
repository: "ghcr.io/boozallen/${artifactId}"
7+
repository: "${dockerProjectRepositoryUrl}${artifactId}"
88
tag: "${version}"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package com.boozallen.aissemble.upgrade.migration.v1_7_0;
2+
3+
/*-
4+
* #%L
5+
* aiSSEMBLE::Foundation::Upgrade
6+
* %%
7+
* Copyright (C) 2021 Booz Allen
8+
* %%
9+
* This software package is licensed under the Booz Allen Public License. All Rights Reserved.
10+
* #L%
11+
*/
12+
13+
import com.boozallen.aissemble.upgrade.migration.AbstractAissembleMigration;
14+
import org.slf4j.Logger;
15+
import org.slf4j.LoggerFactory;
16+
import org.technologybrewery.baton.BatonException;
17+
18+
import java.io.File;
19+
import java.io.IOException;
20+
21+
import static com.boozallen.aissemble.upgrade.util.FileUtils.*;
22+
23+
/**
24+
* Baton migration used to update the naming convention of project specific aiSSEMBLE generated images.
25+
*/
26+
public class ProjectSpecificImageNameMigration extends AbstractAissembleMigration {
27+
28+
public static final Logger logger = LoggerFactory.getLogger(ProjectSpecificImageNameMigration.class);
29+
30+
public static final String ORGANIZATION_PRE_1_7_0 = "boozallen/";
31+
private String projectName;
32+
33+
/**
34+
* Function to check whether the migration is necessary.
35+
* @param file file to check
36+
* @return shouldExecute - whether the migration is necessary.
37+
*/
38+
@Override
39+
protected boolean shouldExecuteOnFile(File file) {
40+
boolean shouldExecute;
41+
try {
42+
projectName = getProjectPrefix();
43+
shouldExecute = hasRegExMatch(ORGANIZATION_PRE_1_7_0 + projectName, file);
44+
} catch (IOException e){
45+
throw new BatonException("Unable to determine if project specific image name migration must be executed", e);
46+
}
47+
return shouldExecute;
48+
}
49+
50+
/**
51+
* Performs the migration if the shouldExecuteOnFile() returns true.
52+
* @param file file to migrate
53+
* @return isMigrated - Whether the file was migrated successfully.
54+
*/
55+
@Override
56+
protected boolean performMigration(File file) {
57+
boolean isMigrated;
58+
59+
try {
60+
isMigrated = replaceLiteralInFile(file, ORGANIZATION_PRE_1_7_0 + projectName, projectName);
61+
} catch (Exception e) {
62+
logger.error("Error in migrating project specific image names.");
63+
throw new BatonException(e);
64+
}
65+
return isMigrated;
66+
}
67+
}

foundation/foundation-upgrade/src/main/resources/migrations.json

+15
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,21 @@
109109
"includes": ["src/**/*.java", "src/**/*.properties"]
110110
}
111111
]
112+
},
113+
{
114+
"name": "upgrade-project-specific-image-naming-convention-migration",
115+
"implementation": "com.boozallen.aissemble.upgrade.migration.v1_7_0.ProjectSpecificImageNameMigration",
116+
"fileSets": [
117+
{
118+
"includes": [
119+
"*-deploy/src/main/resources/apps/*/values*.yaml",
120+
"*-deploy/src/main/resources/apps/spark-worker-image/spark-worker-image.yaml",
121+
"*-deploy/src/main/resources/apps/aissemble-machine-learning-training-image/aissemble-machine-learning-training-image.yaml",
122+
"*-pipelines/*/src/**/resources/apps/*values.yaml",
123+
"Tiltfile"
124+
]
125+
}
126+
]
112127
}
113128
]
114129
},

0 commit comments

Comments
 (0)