Skip to content

Commit 60646ca

Browse files
committed
Remove Amazon AWS S3 code
1 parent f244990 commit 60646ca

File tree

36 files changed

+47
-951
lines changed

36 files changed

+47
-951
lines changed

.github/renovate.json

-8
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,6 @@
1717
"matchCurrentValue": "/-SNAPSHOT$/",
1818
"enabled": false
1919
},
20-
{
21-
"description": "Set noisy package updates to only get PRs once a month",
22-
"matchPackageNames": [
23-
"github.com/aws/aws-sdk-go",
24-
"com.amazonaws:aws-java-sdk-codeartifact"
25-
],
26-
"schedule": ["before 4am on the first day of the month"]
27-
}
2820
],
2921
"enabledManagers": [
3022
]

README.adoc

-4
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ This is currently using link:https://docs.openshift.com/pipelines/1.15/about/op-
2727
The following environment variables are configurable and may be set by the user prior to deploying this depending upon which features are to be enabled.
2828

2929
|=======================
30-
| AWS_ACCESS_KEY_ID | AWS Access Key used for S3 and CodeArtfact Access
31-
| AWS_PROFILE | AWS Region used for CodeArtifact deployment
32-
| AWS_SECRET_ACCESS_KEY | AWS Secret Access Key used for S3 and CodeArtfact Access
3330
| GIT_DEPLOY_IDENTITY | Username/organisation name for the Git service
3431
| GIT_DEPLOY_TOKEN | Authentication token
3532
| GIT_DEPLOY_URL | The URL for the Git service (GitHub/GitLab are supported) to archive the sources
@@ -41,7 +38,6 @@ The following environment variables are configurable and may be set by the user
4138
| JBS_GIT_CREDENTIALS | Support for private repositories (See below)
4239
| JBS_MAX_MEMORY | Maximum additional memory allowed
4340
| JBS_RECIPE_DATABASE | Recipe database to use (defaults to `https://github.com/redhat-appstudio/jvm-build-data`)
44-
| JBS_S3_SYNC_ENABLED | Whether to enable Amazon S3 sync for storage (default: `false`)
4541
| JBS_WORKER_NAMESPACE | Worker namespace (default: `test-jvm-namespace`) may be customised by setting this
4642
| MAVEN_PASSWORD | Password for the Maven repository
4743
| MAVEN_REPOSITORY | The URL for the external Maven repository to deploy to

cmd/controller/main.go

-6
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,6 @@ func main() {
6262

6363
util.ImageTag = os.Getenv("IMAGE_TAG")
6464
util.ImageRepo = os.Getenv("IMAGE_REPO")
65-
if os.Getenv("S3_SYNC_ENABLED") == "true" {
66-
logger.Info("Enabling S3 Sync")
67-
util.S3Enabled = true
68-
} else {
69-
logger.Info("S3 Sync Disabled")
70-
}
7165

7266
mgr, err := controller.NewManager(restConfig, mopts)
7367
if err != nil {

deploy/base-development.sh

-12
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,9 @@ if [ -z "$JBS_BUILD_IMAGE_SECRET" ]; then
3030
# Represents an empty dockerconfig.json
3131
export JBS_BUILD_IMAGE_SECRET="ewogICAgImF1dGhzIjogewogICAgfQp9Cg==" # notsecret
3232
fi
33-
if [ -z "$JBS_S3_SYNC_ENABLED" ]; then
34-
export JBS_S3_SYNC_ENABLED=false
35-
fi
3633
if [ -z "$JBS_MAX_MEMORY" ]; then
3734
export JBS_MAX_MEMORY=4096
3835
fi
39-
# Horrendous hack to work around
40-
# https://github.com/kubernetes-sigs/kustomize/issues/5124
41-
# given an env var is a string (https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.23/)
42-
# and if 'true' or 'false' is seen that is coerced to a bool which causes an issue
43-
export JBS_S3_SYNC_ENABLED="\"$JBS_S3_SYNC_ENABLED\""
4436

4537
function cleanAllArtifacts() {
4638
# Following are created in CI code
@@ -71,9 +63,6 @@ DIR=`dirname $0`
7163

7264
echo -e "\033[0;32mRunning kustomize/kubectl...\033[0m"
7365
kustomize build $DIR/overlays/dev-template | envsubst '
74-
${AWS_ACCESS_KEY_ID}
75-
${AWS_PROFILE}
76-
${AWS_SECRET_ACCESS_KEY}
7766
${GIT_DEPLOY_IDENTITY}
7867
${GIT_DEPLOY_TOKEN}
7968
${GIT_DEPLOY_URL}
@@ -85,7 +74,6 @@ ${JBS_QUAY_IMAGE_TAG}
8574
${JBS_QUAY_ORG}
8675
${JBS_MAX_MEMORY}
8776
${JBS_RECIPE_DATABASE}
88-
${JBS_S3_SYNC_ENABLED}
8977
${JBS_WORKER_NAMESPACE}
9078
${MAVEN_PASSWORD}
9179
${MAVEN_REPOSITORY}

deploy/base/secrets/jbs-build-maven-repo-aws.yaml

-10
This file was deleted.

deploy/base/secrets/jbs-build-s3.yaml

-10
This file was deleted.

deploy/base/secrets/kustomization.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,4 @@ resources:
99
- jbs-build-git-repo.yaml
1010
- jbs-build-git.yaml
1111
- jbs-build-image.yaml
12-
- jbs-build-maven-repo-aws.yaml
1312
- jbs-build-maven-repo.yaml
14-
- jbs-build-s3.yaml

deploy/operator/overlays/dev-template/kustomization.yaml

-11
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,6 @@ images:
1313
newTag: ${JBS_QUAY_IMAGE_TAG}
1414

1515
patches:
16-
# Note - see base-development for quoting requirements for
17-
# JBS_S3_SYNC_ENABLED and the linked kubernete issue.
18-
- patch: |-
19-
- op: add
20-
path: /spec/template/spec/containers/0/env
21-
value:
22-
- name: S3_SYNC_ENABLED
23-
value: ${JBS_S3_SYNC_ENABLED}
24-
target:
25-
kind: Deployment
26-
name: hacbs-jvm-operator
2716
- patch: |-
2817
- op: replace
2918
path: /spec/template/spec/containers/0/imagePullPolicy

deploy/overlays/dev-template/config.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ apiVersion: jvmbuildservice.io/v1alpha1
33
kind: JBSConfig
44
metadata:
55
name: jvm-build-config
6-
annotations:
7-
jvmbuildservice.io/s3-bucket-name: "jvm-build-service-data"
86
spec:
97
registry:
108
owner: ${QUAY_USERNAME}

docs/cache/configuration.adoc

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ Note that these properties are only for end user builds. The config used to rebu
3232
The following remote stores are supported:
3333

3434
* maven2
35-
* s3 (not actually implemented yet)
3635

3736
Each remote store must be given a name, and the names are referenced by the build policies as mentioned above. To configure
3837
a remote artifact store you can use the following two properties:

go.mod

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ go 1.22.0
55
toolchain go1.22.6
66

77
require (
8-
github.com/aws/aws-sdk-go v1.54.19
98
github.com/go-logr/logr v1.4.2
109
github.com/google/go-containerregistry v0.20.1 // indirect
1110
github.com/google/uuid v1.6.0

java-components/build-request-processor/pom.xml

-11
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,6 @@
3030
<artifactId>common-maven</artifactId>
3131
</dependency>
3232

33-
<dependency>
34-
<groupId>com.amazonaws</groupId>
35-
<artifactId>aws-java-sdk-codeartifact</artifactId>
36-
<exclusions>
37-
<exclusion>
38-
<groupId>commons-logging</groupId>
39-
<artifactId>commons-logging</artifactId>
40-
</exclusion>
41-
</exclusions>
42-
</dependency>
43-
4433
<dependency>
4534
<groupId>io.quarkus</groupId>
4635
<artifactId>quarkus-rest-client-reactive-jackson</artifactId>

java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/deploy/BuildVerifyCommand.java

-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import java.util.Map;
1717
import java.util.Optional;
1818
import java.util.Set;
19-
import java.util.regex.Pattern;
2019
import java.util.stream.Stream;
2120

2221
import jakarta.enterprise.inject.spi.BeanManager;
@@ -37,7 +36,6 @@
3736
@CommandLine.Command(name = "verify")
3837
public class BuildVerifyCommand implements Runnable {
3938

40-
static final Pattern CODE_ARTIFACT_PATTERN = Pattern.compile("https://([^.]*)-\\d+\\..*\\.amazonaws\\.com/maven/(.*)/");
4139
private static final String DOT_JAR = ".jar";
4240
private static final String DOT_POM = ".pom";
4341
private static final String DOT = ".";

java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/deploy/TagDeployCommand.java

+1-57
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,14 @@
11
package com.redhat.hacbs.container.deploy;
22

3-
import static org.apache.commons.lang3.ObjectUtils.isEmpty;
43
import static org.apache.commons.lang3.ObjectUtils.isNotEmpty;
54

6-
import java.net.URL;
75
import java.nio.file.Path;
86
import java.util.Optional;
9-
import java.util.regex.Matcher;
10-
import java.util.regex.Pattern;
117

128
import jakarta.inject.Inject;
139

1410
import org.eclipse.microprofile.config.inject.ConfigProperty;
1511

16-
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain;
17-
import com.amazonaws.auth.profile.ProfileCredentialsProvider;
18-
import com.amazonaws.regions.Region;
19-
import com.amazonaws.regions.RegionUtils;
20-
import com.amazonaws.services.codeartifact.AWSCodeArtifactClientBuilder;
21-
import com.amazonaws.services.codeartifact.model.GetAuthorizationTokenRequest;
22-
import com.amazonaws.util.AwsHostNameUtils;
23-
import com.redhat.hacbs.container.deploy.mavenrepository.CodeArtifactRepository;
2412
import com.redhat.hacbs.container.deploy.mavenrepository.MavenRepositoryDeployer;
2513

2614
import io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext;
@@ -30,8 +18,6 @@
3018
@CommandLine.Command(name = "deploy")
3119
public class TagDeployCommand implements Runnable {
3220

33-
private static final Pattern CODE_ARTIFACT_PATTERN = Pattern.compile("https://([^.]*)-\\d+\\..*\\.amazonaws\\.com/maven/(.*)/");
34-
3521
@CommandLine.Option(names = "--directory")
3622
String artifactDirectory;
3723

@@ -42,9 +28,6 @@ public class TagDeployCommand implements Runnable {
4228
@ConfigProperty(name = "maven.password")
4329
Optional<String> mvnPassword;
4430

45-
@ConfigProperty(name = "aws.profile")
46-
Optional<String> awsProfile;
47-
4831
@CommandLine.Option(names = "--mvn-repo")
4932
String mvnRepo;
5033

@@ -53,54 +36,15 @@ public class TagDeployCommand implements Runnable {
5336

5437
public void run() {
5538
try {
56-
5739
var deploymentPath = Path.of(artifactDirectory);
5840

5941
if (!deploymentPath.toFile().exists()) {
6042
Log.warnf("No deployed artifacts found. Has the build been correctly configured to deploy?");
6143
throw new RuntimeException("Deploy failed");
6244
}
63-
CodeArtifactRepository codeArtifactRepository = null;
64-
if (isNotEmpty(mvnRepo) && mvnPassword.isEmpty()) {
65-
Log.infof("Maven repository specified as %s and no password specified", mvnRepo);
66-
URL url = new URL(mvnRepo);
67-
String repo = url.getHost();
68-
// This is special handling for AWS CodeArtifact. It will automatically retrieve a token
69-
// (which normally only last up to 12 hours). Token information will be retrieved from
70-
// the AWS configuration which will utilise the configuration file and/or scan environment
71-
// variables such as AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_PROFILE
72-
if (repo.endsWith(".amazonaws.com")) {
73-
if (isEmpty(mvnUser)) {
74-
Log.warnf("Username for deployment is empty");
75-
}
76-
Matcher matcher = CODE_ARTIFACT_PATTERN.matcher(mvnRepo);
77-
if (matcher.matches()) {
78-
var mr = matcher.toMatchResult();
79-
int firstDash = repo.indexOf("-");
80-
String parsedRegion = AwsHostNameUtils.parseRegion(repo, null);
81-
String domain = repo.substring(0, firstDash);
82-
String domainOwner = repo.substring(firstDash + 1, repo.indexOf("."));
83-
Log.infof("Generating AWS token for domain %s, owner %s, region %s", domain, domainOwner, parsedRegion);
84-
85-
Region region = RegionUtils.getRegion(parsedRegion);
86-
var awsClient = AWSCodeArtifactClientBuilder.standard()
87-
.withCredentials(awsProfile.isEmpty() ? DefaultAWSCredentialsProviderChain.getInstance()
88-
: new ProfileCredentialsProvider(awsProfile.get()))
89-
.withRegion(region.getName()).build();
90-
mvnPassword = Optional.of(awsClient.getAuthorizationToken(
91-
new GetAuthorizationTokenRequest().withDomain(domain).withDomainOwner(domainOwner))
92-
.getAuthorizationToken());
93-
codeArtifactRepository = new CodeArtifactRepository(awsClient, mr.group(1), mr.group(2));
94-
} else {
95-
Log.errorf("Unable to parse AWS CodeArtifact URL: %s", mvnRepo);
96-
}
97-
}
98-
}
99-
10045
if (isNotEmpty(mvnRepo)) {
10146
// Maven Repo Deployment
102-
MavenRepositoryDeployer deployer = new MavenRepositoryDeployer(mvnCtx, mvnUser, mvnPassword.orElse(""), mvnRepo,
103-
deploymentPath, codeArtifactRepository);
47+
MavenRepositoryDeployer deployer = new MavenRepositoryDeployer(mvnCtx, mvnUser, mvnPassword.orElse(""), mvnRepo, deploymentPath);
10448
deployer.deploy();
10549
}
10650

java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/deploy/mavenrepository/CodeArtifactRepository.java

-6
This file was deleted.

java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/deploy/mavenrepository/MavenRepositoryDeployer.java

+1-57
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@
2222
import org.eclipse.aether.repository.RemoteRepository;
2323
import org.eclipse.aether.util.repository.AuthenticationBuilder;
2424

25-
import com.amazonaws.services.codeartifact.model.DeletePackageVersionsRequest;
26-
import com.amazonaws.services.codeartifact.model.PackageFormat;
27-
import com.amazonaws.services.codeartifact.model.ResourceNotFoundException;
28-
import com.amazonaws.services.codeartifact.model.ThrottlingException;
29-
3025
import io.quarkus.bootstrap.resolver.maven.BootstrapMavenContext;
3126
import io.quarkus.bootstrap.resolver.maven.BootstrapMavenException;
3227
import io.quarkus.logging.Log;
@@ -44,18 +39,15 @@ public class MavenRepositoryDeployer {
4439

4540
private final DefaultRepositorySystemSession session;
4641

47-
private final CodeArtifactRepository codeArtifactRepository;
4842

49-
public MavenRepositoryDeployer(BootstrapMavenContext mvnCtx, String username, String password, String repository,
50-
Path artifacts, CodeArtifactRepository codeArtifactRepository)
43+
public MavenRepositoryDeployer(BootstrapMavenContext mvnCtx, String username, String password, String repository, Path artifacts)
5144
throws BootstrapMavenException {
5245
this.username = username;
5346
this.password = password;
5447
this.repository = repository;
5548
this.artifacts = artifacts;
5649

5750
this.system = mvnCtx.getRepositorySystem();
58-
this.codeArtifactRepository = codeArtifactRepository;
5951
this.session = MavenRepositorySystemUtils.newSession();
6052

6153
Log.infof("Maven credentials are username '%s' and repository '%s'", username, repository);
@@ -106,24 +98,6 @@ public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs)
10698
version);
10799
jarArtifact = jarArtifact.setFile(i.toFile());
108100
deployRequest.addArtifact(jarArtifact);
109-
110-
if (codeArtifactRepository != null) {
111-
handleThrottling(() -> {
112-
try {
113-
DeletePackageVersionsRequest request = new DeletePackageVersionsRequest()
114-
.withPackage(artifact)
115-
.withRepository(codeArtifactRepository.repository())
116-
.withDomain(codeArtifactRepository.domain())
117-
.withFormat(PackageFormat.Maven)
118-
.withNamespace(group)
119-
.withVersions(version);
120-
var result = codeArtifactRepository.client().deletePackageVersions(request);
121-
Log.infof("Deleted packages %s", result);
122-
} catch (ResourceNotFoundException e) {
123-
//not found
124-
}
125-
});
126-
}
127101
}
128102
}
129103

@@ -146,34 +120,4 @@ public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs)
146120

147121
});
148122
}
149-
150-
private void handleThrottling(Runnable task) {
151-
for (int i = 0; i < 10; ++i) {
152-
try {
153-
task.run();
154-
return;
155-
} catch (RuntimeException e) {
156-
if (!isThrottle(e)) {
157-
throw e;
158-
}
159-
}
160-
try {
161-
Thread.sleep(i * 10000);
162-
} catch (InterruptedException e) {
163-
throw new RuntimeException(e);
164-
}
165-
}
166-
}
167-
168-
private boolean isThrottle(RuntimeException e) {
169-
Throwable ex = e;
170-
while (ex != null) {
171-
if (ex instanceof ThrottlingException) {
172-
return true;
173-
}
174-
ex = ex.getCause();
175-
}
176-
return false;
177-
}
178-
179123
}

0 commit comments

Comments
 (0)