Skip to content

Commit

Permalink
fix(agents): Add additional cleanup agents when agentScheduler is null (
Browse files Browse the repository at this point in the history
  • Loading branch information
jonsie authored Nov 16, 2020
1 parent 6815f34 commit 0af2a3f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public static List<Agent> buildAwsCleanupAgents(
}
}
}
if (awsCleanupProvider.getAgentScheduler() != null) {
if (awsCleanupProvider.getAgentScheduler() == null) {
if (awsConfigurationProperties.getCleanup().getAlarms().getEnabled()) {
newlyAddedAgents.add(
new CleanupAlarmsAgent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.fasterxml.jackson.databind.ObjectMapper
import com.netflix.spectator.api.DefaultRegistry
import com.netflix.spinnaker.cats.agent.AgentProvider
import com.netflix.spinnaker.clouddriver.aws.AmazonCloudProvider
import com.netflix.spinnaker.clouddriver.aws.AwsConfigurationProperties
import com.netflix.spinnaker.clouddriver.aws.TestCredential
import com.netflix.spinnaker.clouddriver.aws.edda.EddaApiFactory
import com.netflix.spinnaker.clouddriver.aws.provider.AwsCleanupProvider
Expand Down Expand Up @@ -64,6 +65,8 @@ class AmazonCredentialsLifecycleHandlerSpec extends Specification {
)
def deployDefaults = new AwsConfiguration.DeployDefaults()

def awsConfigurationProperties = new AwsConfigurationProperties()

def setup() {
awsCleanupProvider = new AwsCleanupProvider()
awsInfrastructureProvider = new AwsInfrastructureProvider()
Expand Down Expand Up @@ -111,7 +114,7 @@ class AmazonCredentialsLifecycleHandlerSpec extends Specification {
getAmazonEC2(_, _) >> amazonEC2
}
def handler = new AmazonCredentialsLifecycleHandler(awsCleanupProvider, awsInfrastructureProvider, awsProvider,
amazonCloudProvider, amazonClientProvider, null, null, objectMapper, null, eddaApiFactory, null, registry, reservationReportPool, agentProviders, null, null, dynamicConfigService, deployDefaults,
amazonCloudProvider, amazonClientProvider, null, awsConfigurationProperties, objectMapper, null, eddaApiFactory, null, registry, reservationReportPool, agentProviders, null, null, dynamicConfigService, deployDefaults,
credentialsRepository)
def credThree = TestCredential.named('three')

Expand All @@ -132,7 +135,7 @@ class AmazonCredentialsLifecycleHandlerSpec extends Specification {

def 'subsequent call should not add reservation caching agents'() {
def handler = new AmazonCredentialsLifecycleHandler(awsCleanupProvider, awsInfrastructureProvider, awsProvider,
amazonCloudProvider, null, null, null, objectMapper, null, eddaApiFactory, null, registry, reservationReportPool, agentProviders, null, null, dynamicConfigService, deployDefaults,
amazonCloudProvider, null, null, awsConfigurationProperties, objectMapper, null, eddaApiFactory, null, registry, reservationReportPool, agentProviders, null, null, dynamicConfigService, deployDefaults,
credentialsRepository)
def credThree = TestCredential.named('three')
handler.reservationReportCachingAgentScheduled = true
Expand All @@ -157,7 +160,7 @@ class AmazonCredentialsLifecycleHandlerSpec extends Specification {
getAmazonEC2(_, _) >> amazonEC2
}
def handler = new AmazonCredentialsLifecycleHandler(awsCleanupProvider, awsInfrastructureProvider, awsProvider,
amazonCloudProvider, amazonClientProvider, null, null, objectMapper, null, eddaApiFactory, null, registry, reservationReportPool, agentProviders, null, null, dynamicConfigService, deployDefaults,
amazonCloudProvider, amazonClientProvider, null, awsConfigurationProperties, objectMapper, null, eddaApiFactory, null, registry, reservationReportPool, agentProviders, null, null, dynamicConfigService, deployDefaults,
credentialsRepository)
def credThree = TestCredential.named('three')
handler.credentialsAdded(credThree)
Expand Down

0 comments on commit 0af2a3f

Please sign in to comment.