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(gce): support resourceManagerTags in instance template #6282

Closed
wants to merge 27 commits into from
Closed
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
f86151c
chore(gce): upgrade client
edgarulg Sep 19, 2024
638ef9a
feat(gce): add resourceManagerTags in input
edgarulg Sep 19, 2024
efbb01a
fix(gce): workaround upgrade issues
edgarulg Sep 19, 2024
1cb12d6
fix(gce): upgrade google-api-client
edgarulg Sep 19, 2024
efa77fe
test(gce): disable test
edgarulg Sep 19, 2024
f90080a
feat(gce): add resourceManagerTags in the basic description
edgarulg Sep 21, 2024
4823d3f
feat(gce): remove resourceManagerTags from the instanceProperties
edgarulg Sep 21, 2024
73c3594
feat(gce): add logs for resourceManagerTags
edgarulg Sep 22, 2024
31eaaa0
feat(gce): add resourceManagerTags to the instanceTemplate properties
edgarulg Sep 23, 2024
d304c26
feat(gce): upgrade to 1.35.1 to keep backward compatibility
edgarulg Sep 23, 2024
031bf1d
fix(cloudfoundry): Update ProcessStats model due to capi-1.84.0 chang…
christosarvanitis Sep 24, 2024
128e4b3
feat(gce): remove explicit version from implementation statement
edgarulg Sep 24, 2024
e8a3775
chore(dependencies): Autobump korkVersion (#6284)
spinnakerbot Sep 25, 2024
52c0dfe
chore(dependencies): Autobump fiatVersion (#6285)
spinnakerbot Sep 25, 2024
fa2d7ac
chore(gce): upgrade client
edgarulg Sep 19, 2024
a47d424
feat(gce): add resourceManagerTags in input
edgarulg Sep 19, 2024
86647b7
fix(gce): workaround upgrade issues
edgarulg Sep 19, 2024
909768d
fix(gce): upgrade google-api-client
edgarulg Sep 19, 2024
1e39686
test(gce): disable test
edgarulg Sep 19, 2024
faea970
feat(gce): add resourceManagerTags in the basic description
edgarulg Sep 21, 2024
43580cc
feat(gce): remove resourceManagerTags from the instanceProperties
edgarulg Sep 21, 2024
487f8aa
feat(gce): add logs for resourceManagerTags
edgarulg Sep 22, 2024
bdb9b41
feat(gce): add resourceManagerTags to the instanceTemplate properties
edgarulg Sep 23, 2024
ca9f54f
feat(gce): upgrade to 1.35.1 to keep backward compatibility
edgarulg Sep 23, 2024
2b6757a
feat(gce): remove explicit version from implementation statement
edgarulg Sep 24, 2024
e9cd982
Merge remote-tracking branch 'origin/gce-add-fields' into gce-add-fields
edgarulg Sep 25, 2024
e0c4e47
feat(gce): remove force deps and fix issues with new version of googl…
edgarulg Sep 25, 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
2 changes: 1 addition & 1 deletion cats/cats-core/cats-core.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ dependencies {

implementation "org.slf4j:slf4j-api"
implementation "com.fasterxml.jackson.core:jackson-annotations"
implementation "org.codehaus.groovy:groovy"
implementation "org.apache.groovy:groovy"
implementation "com.google.guava:guava"

testImplementation project(":cats:cats-test")
Expand Down
2 changes: 1 addition & 1 deletion cats/cats-redis/cats-redis.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ dependencies {

compileOnly "org.projectlombok:lombok"

implementation "org.codehaus.groovy:groovy"
implementation "org.apache.groovy:groovy"
implementation "com.fasterxml.jackson.core:jackson-databind"
implementation "io.spinnaker.kork:kork-jedis"
implementation "com.github.ben-manes.caffeine:guava"
Expand Down
2 changes: 1 addition & 1 deletion cats/cats-test/cats-test.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ tasks.compileGroovy.enabled = true

dependencies {
implementation project(":cats:cats-core")
implementation "org.codehaus.groovy:groovy"
implementation "org.apache.groovy:groovy"

implementation "org.springframework.boot:spring-boot-starter-test"
implementation "org.spockframework:spock-core"
Expand Down
2 changes: 1 addition & 1 deletion cats/cats.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ subprojects {
dependencies {
implementation project(":clouddriver-api")

implementation "org.codehaus.groovy:groovy"
implementation "org.apache.groovy:groovy"
}
}
2 changes: 1 addition & 1 deletion clouddriver-alicloud/clouddriver-alicloud.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies {
implementation 'com.aliyun:aliyun-java-sdk-ess:2.3.2'
implementation "org.springframework.boot:spring-boot-actuator"
implementation "org.springframework.boot:spring-boot-starter-web"
implementation "org.codehaus.groovy:groovy"
implementation "org.apache.groovy:groovy"
implementation "org.apache.commons:commons-lang3"

testImplementation "cglib:cglib-nodep"
Expand Down
4 changes: 2 additions & 2 deletions clouddriver-appengine/clouddriver-appengine.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ dependencies {
implementation "com.squareup.retrofit:retrofit"
implementation "commons-io:commons-io"
implementation "org.apache.commons:commons-compress:1.21"
implementation "org.codehaus.groovy:groovy"
implementation "org.codehaus.groovy:groovy-json"
implementation "org.apache.groovy:groovy"
implementation "org.apache.groovy:groovy-json"
implementation "org.eclipse.jgit:org.eclipse.jgit.ssh.jsch:5.13.1.202206130422-r"
implementation "org.springframework.boot:spring-boot-actuator"
implementation "org.springframework.boot:spring-boot-starter-web"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ class AppengineServerGroup implements ServerGroup, Serializable {
this.allowsGradualTrafficMigration = versionAllowsGradualTrafficMigration(version)
}

Boolean isDisabled() {
disabled
}
@Override
ServerGroup.InstanceCounts getInstanceCounts() {
new ServerGroup.InstanceCounts(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.storage.Storage;
import com.google.api.services.storage.StorageScopes;
import com.google.api.services.storage.model.Objects;
Expand Down Expand Up @@ -56,7 +56,7 @@ public static class Factory {
public Factory(String applicationName) throws IOException, GeneralSecurityException {
applicationName_ = applicationName;
transport_ = GoogleNetHttpTransport.newTrustedTransport();
jsonFactory_ = JacksonFactory.getDefaultInstance();
jsonFactory_ = GsonFactory.getDefaultInstance();
}

public Factory(String applicationName, HttpTransport transport, JsonFactory jsonFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.appengine.v1.Appengine;
import com.google.auth.http.HttpCredentialsAdapter;
import com.google.auth.oauth2.GoogleCredentials;
Expand All @@ -35,7 +35,7 @@ public AppengineCredentials(String project) {

public Appengine getAppengine(String applicationName) {
HttpTransport httpTransport = buildHttpTransport();
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
JsonFactory jsonFactory = GsonFactory.getDefaultInstance();
GoogleCredentials credentials = getCredentials();
HttpRequestInitializer requestInitializer = new HttpCredentialsAdapter(credentials);

Expand Down
7 changes: 2 additions & 5 deletions clouddriver-artifacts/clouddriver-artifacts.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ dependencies {
implementation "org.apache.commons:commons-lang3"
implementation "org.apache.ivy:ivy:2.4.0"
implementation "org.apache.maven:maven-resolver-provider:3.5.4"
implementation "org.codehaus.groovy:groovy"
implementation "org.apache.groovy:groovy"
implementation "org.springframework.boot:spring-boot-actuator"
implementation "org.springframework.boot:spring-boot-starter-web"

Expand All @@ -71,10 +71,7 @@ dependencies {
integrationImplementation "org.testcontainers:mysql"
integrationImplementation "org.testcontainers:junit-jupiter"
integrationImplementation "com.mysql:mysql-connector-j"
integrationImplementation ("io.rest-assured:rest-assured:4.0.0") {
// Exclude groovy pulled in by rest-assured, so we use kork's version
exclude group: "org.codehaus.groovy", module: "groovy"
}
integrationImplementation "io.rest-assured:rest-assured"
}

task integrationTest(type: Test) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.storage.Storage;
import com.google.api.services.storage.StorageScopes;
import com.google.auth.http.HttpCredentialsAdapter;
Expand Down Expand Up @@ -52,7 +52,7 @@ public class GcsArtifactCredentials implements ArtifactCredentials {
GcsArtifactCredentials(String applicationName, GcsArtifactAccount account)
throws IOException, GeneralSecurityException {
HttpTransport transport = GoogleNetHttpTransport.newTrustedTransport();
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
JsonFactory jsonFactory = GsonFactory.getDefaultInstance();
Optional<String> credentialsPath = account.getJsonPath();

GoogleCredentials credentials;
Expand Down
6 changes: 2 additions & 4 deletions clouddriver-aws/clouddriver-aws.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ dependencies {
implementation "io.reactivex:rxjava"
implementation "org.apache.httpcomponents:httpclient"
implementation "org.apache.httpcomponents:httpcore"
implementation "org.codehaus.groovy:groovy"
implementation "org.apache.groovy:groovy"
implementation "org.springframework.boot:spring-boot-actuator"
implementation "org.springframework.boot:spring-boot-starter-web"
implementation 'com.aestasit.infrastructure.sshoogr:sshoogr:0.9.25'
Expand All @@ -71,9 +71,7 @@ dependencies {
integrationImplementation "org.springframework:spring-test"
integrationImplementation sourceSets.test.output
integrationImplementation sourceSets.main.output
integrationImplementation ("io.rest-assured:rest-assured:4.0.0") {
exclude group: "org.codehaus.groovy", module: "groovy" // use kork's version
}
integrationImplementation "io.rest-assured:rest-assured"
}

task integrationTest(type: Test) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ class BasicAmazonDeployHandler implements DeployHandler<BasicAmazonDeployDescrip
)

if (serverGroup) {
String subnetIdTag = serverGroup.asg.tags.find { it.key == SUBNET_ID_OVERRIDE_TAG }?.value
String subnetIdTag = serverGroup.asg.tags.find { it.key == BasicAmazonDeployHandler.SUBNET_ID_OVERRIDE_TAG }?.value
if (subnetIdTag) {
// source server group had subnet id overrides, propagate them forward
description.subnetIds = subnetIdTag.split(",")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,20 @@ import com.amazonaws.services.cloudwatch.model.Dimension
import com.amazonaws.services.cloudwatch.model.Metric
import com.fasterxml.jackson.annotation.JsonInclude
import com.netflix.spinnaker.clouddriver.model.CloudMetricDescriptor
import groovy.transform.Immutable

@Immutable
@JsonInclude(JsonInclude.Include.NON_EMPTY)
class AmazonMetricDescriptor implements CloudMetricDescriptor {
final String cloudProvider = 'aws'
final String namespace
final String name
final List<Dimension> dimensions

AmazonMetricDescriptor (String cloudProvider, String namespace, String name, List<Dimension> dimensions) {
this.cloudProvider = cloudProvider
this.namespace = namespace
this.name = name
this.dimensions = dimensions
}
static AmazonMetricDescriptor from(Metric metric) {
new AmazonMetricDescriptor('aws', metric.namespace, metric.metricName, metric.dimensions)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@ class SimpleServerGroup implements ServerGroup {
ServerGroup.Capacity capacity
ServerGroup.ImageSummary imageSummary
ServerGroup.ImagesSummary imagesSummary

Boolean isDisabled() {
disabled
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -572,5 +572,9 @@ class DiscoverySupportUnitSpec extends Specification {
ServerGroup.Capacity capacity
ServerGroup.ImageSummary getImageSummary() {}
ServerGroup.ImagesSummary getImagesSummary() {}

Boolean isDisabled() {
disabled
}
}
}
2 changes: 1 addition & 1 deletion clouddriver-azure/clouddriver-azure.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies {
implementation "io.spinnaker.fiat:fiat-core:$fiatVersion"
implementation "io.spinnaker.kork:kork-exceptions"
implementation "io.spinnaker.kork:kork-moniker"
implementation "org.codehaus.groovy:groovy"
implementation "org.apache.groovy:groovy"
implementation "org.springframework.boot:spring-boot-actuator"
implementation "org.springframework.boot:spring-boot-starter-web"
implementation "com.azure.resourcemanager:azure-resourcemanager:2.19.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ class AzureServerGroupDescription extends AzureResourceOpsDescription implements
String.format("%s-%s-%s", application, stack, detail)
}

Boolean isDisabled() {
disabled
}

@Override
Set<String> getLoadBalancers() {
if(this.appGatewayName != null) return Sets.newHashSet(this.appGatewayName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ package com.netflix.spinnaker.clouddriver.azure.resources.servergroup.ops.prepro
import com.netflix.spinnaker.clouddriver.azure.resources.servergroup.model.EnableDisableDestroyAzureServerGroupDescription
import com.netflix.spinnaker.clouddriver.orchestration.AtomicOperationDescriptionPreProcessor
import groovy.util.logging.Slf4j
import org.slf4j.Logger
import org.springframework.stereotype.Component

@Slf4j
@Component
class RegionsToRegionDescriptionPreProcessor implements AtomicOperationDescriptionPreProcessor {

private Logger getLog() {
return log
}

@Override
boolean supports(Class descriptionClass) {
return descriptionClass == EnableDisableDestroyAzureServerGroupDescription
Expand All @@ -36,7 +42,7 @@ class RegionsToRegionDescriptionPreProcessor implements AtomicOperationDescripti
region = regions[0]

if (regions.size() > 1) {
log.warn("EnableDisableDestroyAzureServerGroupDescription has regions size greater than 1: $regions")
getLog().warn("EnableDisableDestroyAzureServerGroupDescription has regions size greater than 1: $regions")
}
}

Expand Down
2 changes: 1 addition & 1 deletion clouddriver-cloudfoundry/clouddriver-cloudfoundry.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dependencies {
implementation project(":cats:cats-core")
implementation project(":clouddriver-docker")

implementation "org.codehaus.groovy:groovy"
implementation "org.apache.groovy:groovy"

implementation "io.spinnaker.fiat:fiat-core:$fiatVersion"
implementation "org.apache.commons:commons-lang3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public enum State {
RUNNING,
CRASHED,
STARTING,
STOPPING,
DOWN
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ static String describeProcessState(ProcessStats.State state) {
return "is still starting";
case CRASHED:
return "crashed";
case STOPPING:
return "is in graceful shutdown - stopping";
case RUNNING:
case DOWN:
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public Void operate(List priorOutputs) {
() -> client.getApplications().getAppState(description.getServerGroupId()),
inProgressState ->
inProgressState != ProcessStats.State.STARTING
&& inProgressState != ProcessStats.State.RUNNING,
&& inProgressState != ProcessStats.State.RUNNING
&& inProgressState != ProcessStats.State.STOPPING,
null,
getTask(),
description.getServerGroupName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,27 @@ void failedToStop() {
.isEqualTo(
"Cloud Foundry API returned with error(s): Failed to stop 'myapp' which instead is running");
}

@Test
void failedToStopStopping() {
OperationPoller poller = mock(OperationPoller.class);

//noinspection unchecked
when(poller.waitForOperation(any(Supplier.class), any(), any(), any(), any(), any()))
.thenReturn(ProcessStats.State.STOPPING);

StopCloudFoundryServerGroupAtomicOperation op =
new StopCloudFoundryServerGroupAtomicOperation(poller, desc);

Task task = runOperation(op);
List<Object> resultObjects = task.getResultObjects();
assertThat(resultObjects.size()).isEqualTo(1);
Object o = resultObjects.get(0);
assertThat(o).isInstanceOf(Map.class);
Object ex = ((Map) o).get("EXCEPTION");
assertThat(ex).isInstanceOf(CloudFoundryApiException.class);
assertThat(((CloudFoundryApiException) ex).getMessage())
.isEqualTo(
"Cloud Foundry API returned with error(s): Failed to stop 'myapp' which instead is in graceful shutdown - stopping");
}
}
2 changes: 1 addition & 1 deletion clouddriver-cloudrun/clouddriver-cloudrun.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dependencies {
implementation "com.squareup.retrofit:retrofit"
implementation "commons-io:commons-io"
implementation "org.apache.commons:commons-compress:1.20"
implementation "org.codehaus.groovy:groovy"
implementation "org.apache.groovy:groovy"
implementation "org.eclipse.jgit:org.eclipse.jgit:5.7.0.202003110725-r"
implementation "org.springframework.boot:spring-boot-actuator"
implementation "org.springframework.boot:spring-boot-starter-web"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.client.json.gson.GsonFactory;
import com.google.api.services.run.v1.CloudRun;
import com.google.auth.http.HttpCredentialsAdapter;
import com.google.auth.oauth2.GoogleCredentials;
Expand All @@ -35,7 +35,7 @@ public CloudrunCredentials(String project) {

public CloudRun getCloudrun(String applicationName) {
HttpTransport httpTransport = buildHttpTransport();
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
JsonFactory jsonFactory = GsonFactory.getDefaultInstance();
GoogleCredentials credentials =
getCredentials().createScoped("https://www.googleapis.com/auth/cloud-platform");
HttpRequestInitializer requestInitializer = new HttpCredentialsAdapter(credentials);
Expand Down
4 changes: 2 additions & 2 deletions clouddriver-consul/clouddriver-consul.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ dependencies {
implementation "com.squareup.okhttp:okhttp"
implementation "com.squareup.retrofit:converter-jackson"
implementation "com.squareup.retrofit:retrofit"
implementation "org.codehaus.groovy:groovy"
implementation "org.codehaus.groovy:groovy-json"
implementation "org.apache.groovy:groovy"
implementation "org.apache.groovy:groovy-json"
implementation "org.springframework.boot:spring-boot-starter-web"
implementation "io.spinnaker.kork:kork-retrofit"
implementation "io.spinnaker.kork:kork-exceptions"
Expand Down
2 changes: 1 addition & 1 deletion clouddriver-core-tck/clouddriver-core-tck.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ dependencies {
implementation "org.junit.jupiter:junit-jupiter-api"
implementation "org.apache.commons:commons-lang3"
implementation "org.assertj:assertj-core"
implementation "org.codehaus.groovy:groovy"
implementation "org.apache.groovy:groovy"
}
6 changes: 3 additions & 3 deletions clouddriver-core/clouddriver-core.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies {

// This is because some classes in this module use the Groovy @Immutable annotation,
// which appears to require consumers to have core groovy on the classpath
api "org.codehaus.groovy:groovy"
api "org.apache.groovy:groovy"

implementation "javax.inject:javax.inject:1"
implementation "javax.validation:validation-api"
Expand Down Expand Up @@ -41,8 +41,8 @@ dependencies {
implementation "com.jakewharton.retrofit:retrofit1-okhttp3-client"
implementation "io.reactivex:rxjava"
implementation "net.jodah:failsafe:1.0.4"
implementation "org.codehaus.groovy:groovy"
implementation "org.codehaus.groovy:groovy-templates"
implementation "org.apache.groovy:groovy"
implementation "org.apache.groovy:groovy-templates"
implementation "org.springframework.boot:spring-boot-actuator"
implementation "redis.clients:jedis"
implementation "org.jooq:jooq"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class InMemoryTaskRepository implements TaskRepository {
List<Task> list() {
List<Task> tasks = new ArrayList<>();
for (Task value : repository.values()) {
if (!value.getStatus().completed) {
if (!value.getStatus().isCompleted()) {
tasks.add(value)
}
}
Expand Down
Loading
Loading