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

feat(build): add halyard-integration module to exercise the just-built docker image #2144

Merged
merged 27 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6bddd03
fix(core): move @Bean methods from GoogleProfileReader so separate co…
dbyron-sf Apr 9, 2024
e8892eb
fix(config): remove unused ProviderService variable from EcsAccountVa…
dbyron-sf Apr 9, 2024
d9abbc4
fix(config): Use @Lazy with ValidatorCollection.validators
dbyron-sf Apr 9, 2024
549d14c
fix(config): add @Lazy to DeploymentService.storageService
dbyron-sf Apr 9, 2024
54c6b23
fix(dpeloy): add @Lazy annotation to GoogleIgorService.googleDistribu…
dbyron-sf Apr 9, 2024
5e6908f
fix(deploy): add @Lazy annotation to GoogleRedisBootstrapService.goog…
dbyron-sf Apr 9, 2024
ec38841
fix(deploy): add @Lazy annotation to GoogleDeckService.googleDistribu…
dbyron-sf Apr 9, 2024
dca51b1
fix(deploy): add @Lazy annotation to GoogleEchoService.googleDistribu…
dbyron-sf Apr 9, 2024
26e7847
fix(deploy): add @Lazy annotation to GoogleConsulServerService.google…
dbyron-sf Apr 9, 2024
a153ca5
fix(deploy): add @Lazy annotation to GoogleFront50Service.googleDistr…
dbyron-sf Apr 9, 2024
9d8dac7
fix(deploy): add @Lazy annotation to GoogleClouddriverService.googleD…
dbyron-sf Apr 9, 2024
0da373e
fix(deploy): add @Lazy annotation to GoogleOrcaBootstrapService.googl…
dbyron-sf Apr 9, 2024
76ff87c
fix(deploy): add @Lazy annotation to GoogleOrcaService.googleDistribu…
dbyron-sf Apr 9, 2024
1e84373
fix(deploy): add @Lazy annotation to GoogleRoscoService.googleDistrib…
dbyron-sf Apr 9, 2024
a4c5748
fix(deploy): add @Lazy annotation to GoogleFiatService.googleDistribu…
dbyron-sf Apr 9, 2024
4331b4d
fix(deploy): add @Lazy annotation to GoogleClouddriverBootstrapServic…
dbyron-sf Apr 9, 2024
8ef9191
fix(deploy): add @Lazy annotation to GoogleRedisService.googleDistrib…
dbyron-sf Apr 9, 2024
88a55bf
fix(deploy): add @Lazy annotation to GoogleGateService.googleDistribu…
dbyron-sf Apr 9, 2024
a663006
fix(deploy): add @Lazy annotation to GoogleKayentaService.googleDistr…
dbyron-sf Apr 9, 2024
7b74dbe
fix(deploy): add @Lazy annotation to GoogleVaultServerService.googleD…
dbyron-sf Apr 9, 2024
d9d4c57
fix(deploy): add @Lazy annotation to KubernetesV2ServiceDelegate.moni…
dbyron-sf Apr 9, 2024
94c4eb6
fix(deploy): remove unused SpinnakerMonitoringDaemonService.service p…
dbyron-sf Apr 9, 2024
e14c99b
feat(docker): add HEALTHCHECK
dbyron-sf Apr 9, 2024
a264a4f
feat(build): add halyard-integration module to exercise the just-buil…
dbyron-sf Apr 9, 2024
6f36051
feat(gha): run integration test in pr builds
dbyron-sf Apr 9, 2024
42daf3e
feat(gha): run integration test in branch builds
dbyron-sf Apr 9, 2024
f05bb4e
refactor(core): remove unused GoogleProfileReader.createGoogleStorage…
dbyron-sf Apr 9, 2024
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
13 changes: 13 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ jobs:
env:
ORG_GRADLE_PROJECT_version: ${{ steps.build_variables.outputs.VERSION }}
run: ./gradlew build --stacktrace ${{ steps.build_variables.outputs.REPO }}-web:installDist
- name: Build local slim container image for testing
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.slim
load: true
platforms: local
tags: |
"${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-unvalidated"
- name: Test local slim container image
env:
FULL_DOCKER_IMAGE_NAME: "${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-unvalidated"
run: ./gradlew ${{ steps.build_variables.outputs.REPO }}-integration:test
- name: Login to GAR
# Only run this on repositories in the 'spinnaker' org, not on forks.
if: startsWith(github.repository, 'spinnaker/')
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,16 @@ jobs:
tags: |
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:latest-ubuntu"
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-ubuntu"
- name: Build local slim container image for testing
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.slim
load: true
platforms: local
tags: |
"${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}"
- name: Test local slim container image
env:
FULL_DOCKER_IMAGE_NAME: "${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}"
run: ./gradlew ${{ steps.build_variables.outputs.REPO }}-integration:test
2 changes: 2 additions & 0 deletions Dockerfile.slim
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ RUN adduser -S -G spinnaker -u 1000 spinnaker
COPY halyard-web/build/install/halyard /opt/halyard
USER spinnaker

HEALTHCHECK CMD curl http://localhost:8064/health | grep UP || exit 1

CMD ["/opt/halyard/bin/halyard"]
2 changes: 2 additions & 0 deletions Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ RUN adduser --system --uid 1000 --group spinnaker
COPY halyard-web/build/install/halyard /opt/halyard
USER spinnaker

HEALTHCHECK CMD curl http://localhost:8064/health | grep UP || exit 1

CMD ["/opt/halyard/bin/halyard"]
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

/**
Expand All @@ -43,7 +44,7 @@ public class DeploymentService {

@Autowired private HalconfigParser halconfigParser;

@Autowired private PersistentStorageService storageService;
@Lazy @Autowired private PersistentStorageService storageService;

public void setDeploymentConfiguration(
String deploymentName, DeploymentConfiguration deploymentConfiguration) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

/**
Expand All @@ -35,6 +36,7 @@
@Slf4j
@Component
public class ValidatorCollection {
@Lazy
@Autowired(required = false)
private List<Validator> validators = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemSetBuilder;
import com.netflix.spinnaker.halyard.config.services.v1.AccountService;
import com.netflix.spinnaker.halyard.config.services.v1.ConfigService;
import com.netflix.spinnaker.halyard.config.services.v1.ProviderService;
import com.netflix.spinnaker.halyard.core.problem.v1.Problem.Severity;
import java.util.List;
import java.util.Optional;
Expand All @@ -15,8 +14,6 @@

@Component
public class EcsAccountValidator extends Validator<EcsAccount> {
@Autowired ProviderService providerService;

@Autowired AccountService accountService;

@Autowired ConfigService configService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,15 @@
package com.netflix.spinnaker.halyard.core.registry.v1;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.services.storage.Storage;
import com.google.api.services.storage.StorageScopes;
import com.netflix.spinnaker.halyard.core.provider.v1.google.GoogleCredentials;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import org.yaml.snakeyaml.Yaml;

Expand All @@ -56,16 +49,6 @@ private Yaml getYamlParser() {
return applicationContext.getBean(Yaml.class);
}

@Bean
public Storage applicationDefaultGoogleStorage() {
return createGoogleStorage(true);
}

@Bean
public Storage unauthenticatedGoogleStorage() {
return createGoogleStorage(false);
Copy link
Member

Choose a reason for hiding this comment

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

Moved the class but left the private method call - can we delete it?

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, thanks! f05bb4e

}

public InputStream readProfile(String artifactName, String version, String profileName)
throws IOException {
String path = profilePath(artifactName, version, profileName);
Expand Down Expand Up @@ -118,36 +101,4 @@ private InputStream getContents(String objectName) throws IOException {

return new ByteArrayInputStream(output.toByteArray());
}

private Storage createGoogleStorage(boolean useApplicationDefaultCreds) {
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
String applicationName = "Spinnaker/Halyard";
HttpRequestInitializer requestInitializer = null;

if (useApplicationDefaultCreds) {
try {
com.google.auth.oauth2.GoogleCredentials credentials =
com.google.auth.oauth2.GoogleCredentials.getApplicationDefault();
if (credentials.createScopedRequired()) {
credentials =
credentials.createScoped(
Collections.singleton(StorageScopes.DEVSTORAGE_FULL_CONTROL));
}
requestInitializer = GoogleCredentials.setHttpTimeout(credentials);
log.info("Loaded application default credential for reading BOMs & profiles.");
} catch (Exception e) {
log.debug(
"No application default credential could be loaded for reading BOMs & profiles. Continuing unauthenticated: {}",
e.getMessage());
}
}
if (requestInitializer == null) {
requestInitializer = GoogleCredentials.retryRequestInitializer();
}

return new Storage.Builder(
GoogleCredentials.buildHttpTransport(), jsonFactory, requestInitializer)
.setApplicationName(applicationName)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Copyright 2017 Google, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/

package com.netflix.spinnaker.halyard.core.registry.v1;

import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.services.storage.Storage;
import com.google.api.services.storage.StorageScopes;
import com.netflix.spinnaker.halyard.core.provider.v1.google.GoogleCredentials;
import java.util.Collections;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConditionalOnProperty("spinnaker.config.input.gcs.enabled")
@Slf4j
public class GoogleProfileReaderConfig {
@Bean
public Storage applicationDefaultGoogleStorage() {
return createGoogleStorage(true);
}

@Bean
public Storage unauthenticatedGoogleStorage() {
return createGoogleStorage(false);
}

private Storage createGoogleStorage(boolean useApplicationDefaultCreds) {
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
String applicationName = "Spinnaker/Halyard";
HttpRequestInitializer requestInitializer = null;

if (useApplicationDefaultCreds) {
try {
com.google.auth.oauth2.GoogleCredentials credentials =
com.google.auth.oauth2.GoogleCredentials.getApplicationDefault();
if (credentials.createScopedRequired()) {
credentials =
credentials.createScoped(
Collections.singleton(StorageScopes.DEVSTORAGE_FULL_CONTROL));
}
requestInitializer = GoogleCredentials.setHttpTimeout(credentials);
log.info("Loaded application default credential for reading BOMs & profiles.");
} catch (Exception e) {
log.debug(
"No application default credential could be loaded for reading BOMs & profiles. Continuing unauthenticated: {}",
e.getMessage());
}
}
if (requestInitializer == null) {
requestInitializer = GoogleCredentials.retryRequestInitializer();
}

return new Storage.Builder(
GoogleCredentials.buildHttpTransport(), jsonFactory, requestInitializer)
.setApplicationName(applicationName)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ public abstract class SpinnakerMonitoringDaemonService

@Autowired MetricRegistryProfileFactoryBuilder metricRegistryProfileFactoryBuilder;

@Autowired List<SpinnakerService> services;

@Override
public SpinnakerArtifact getArtifact() {
return SpinnakerArtifact.SPINNAKER_MONITORING_DAEMON;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import lombok.EqualsAndHashCode;
import lombok.experimental.Delegate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

@EqualsAndHashCode(callSuper = true)
Expand All @@ -37,7 +38,7 @@ public class GoogleClouddriverBootstrapService extends ClouddriverBootstrapServi
final DeployPriority deployPriority = new DeployPriority(6);
final boolean requiredToBootstrap = true;

@Delegate @Autowired GoogleDistributedServiceDelegate googleDistributedServiceDelegate;
@Lazy @Delegate @Autowired GoogleDistributedServiceDelegate googleDistributedServiceDelegate;

@Override
public List<SidecarService> getSidecars(SpinnakerRuntimeSettings runtimeSettings) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import lombok.EqualsAndHashCode;
import lombok.experimental.Delegate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

@EqualsAndHashCode(callSuper = true)
Expand All @@ -38,7 +39,7 @@ public class GoogleClouddriverService extends ClouddriverService
final DeployPriority deployPriority = new DeployPriority(4);
final boolean requiredToBootstrap = false;

@Delegate @Autowired GoogleDistributedServiceDelegate googleDistributedServiceDelegate;
@Lazy @Delegate @Autowired GoogleDistributedServiceDelegate googleDistributedServiceDelegate;

@Override
public List<Profile> getProfiles(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@
import lombok.EqualsAndHashCode;
import lombok.experimental.Delegate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

@EqualsAndHashCode(callSuper = true)
@Component
@Data
public class GoogleConsulServerService extends ConsulServerService
implements GoogleDistributedService<ConsulApi> {
@Delegate @Autowired GoogleDistributedServiceDelegate googleDistributedServiceDelegate;
@Lazy @Delegate @Autowired GoogleDistributedServiceDelegate googleDistributedServiceDelegate;

@Override
public String getDefaultInstanceType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import lombok.EqualsAndHashCode;
import lombok.experimental.Delegate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

@EqualsAndHashCode(callSuper = true)
Expand All @@ -37,7 +38,7 @@ public class GoogleDeckService extends DeckService
final DeployPriority deployPriority = new DeployPriority(4);
final boolean requiredToBootstrap = false;

@Delegate @Autowired GoogleDistributedServiceDelegate googleDistributedServiceDelegate;
@Lazy @Delegate @Autowired GoogleDistributedServiceDelegate googleDistributedServiceDelegate;

@Override
public List<SidecarService> getSidecars(SpinnakerRuntimeSettings runtimeSettings) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import lombok.EqualsAndHashCode;
import lombok.experimental.Delegate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

@EqualsAndHashCode(callSuper = true)
Expand All @@ -37,7 +38,7 @@ public class GoogleEchoService extends EchoService
final DeployPriority deployPriority = new DeployPriority(4);
final boolean requiredToBootstrap = false;

@Delegate @Autowired GoogleDistributedServiceDelegate googleDistributedServiceDelegate;
@Lazy @Delegate @Autowired GoogleDistributedServiceDelegate googleDistributedServiceDelegate;

@Override
public List<SidecarService> getSidecars(SpinnakerRuntimeSettings runtimeSettings) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import lombok.EqualsAndHashCode;
import lombok.experimental.Delegate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

@EqualsAndHashCode(callSuper = true)
Expand All @@ -37,7 +38,7 @@ public class GoogleFiatService extends FiatService
final DeployPriority deployPriority = new DeployPriority(4);
final boolean requiredToBootstrap = false;

@Delegate @Autowired GoogleDistributedServiceDelegate googleDistributedServiceDelegate;
@Lazy @Delegate @Autowired GoogleDistributedServiceDelegate googleDistributedServiceDelegate;

@Override
public List<SidecarService> getSidecars(SpinnakerRuntimeSettings runtimeSettings) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import lombok.EqualsAndHashCode;
import lombok.experimental.Delegate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

@EqualsAndHashCode(callSuper = true)
Expand All @@ -38,7 +39,7 @@ public class GoogleFront50Service extends Front50Service
final DeployPriority deployPriority = new DeployPriority(4);
final boolean requiredToBootstrap = false;

@Delegate @Autowired GoogleDistributedServiceDelegate googleDistributedServiceDelegate;
@Lazy @Delegate @Autowired GoogleDistributedServiceDelegate googleDistributedServiceDelegate;

@Override
public List<Profile> getProfiles(
Expand Down
Loading