Skip to content

Commit

Permalink
fix(*): Small improvements from demos (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
robzienert authored Dec 19, 2017
1 parent 3ae3d65 commit a650426
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ import org.springframework.boot.context.properties.ConfigurationProperties
@ConfigurationProperties("keel")
class KeelProperties {
var prettyPrintJson: Boolean = false
var immediatelyRunIntents: Boolean = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ data class AmazonSecurityGroupSpec(
override val regions: Set<String>,
override val inboundRules: Set<SecurityGroupRule>,
val outboundRules: Set<SecurityGroupRule>,
// We don't care to support EC2 Classic, but for some reason clouddriver returns nulls (and isn't "default" vpcs)
val vpcName: String?,
val description: String
) : SecurityGroupSpec()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ open class OrcaIntentLauncher
val result = intentProcessor(intentProcessors, intent).converge(intent)

if (result.orchestrations.isEmpty()) {
log.info("Not converging state for intent {}, {}",
log.info("No action needed to converge intent {}, {}",
value("intent", intent.id()),
value("summary", result.changeSummary))
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ interface SchedulerAgent {
*/
@Component
class QueueBackedSchedulerAgent(
private val queue: Queue
private val queue: Queue,
@Value("\${scheduler.retry.onStart.ms:30000}") private val ensureSchedulerFrequency: Long
) : SchedulerAgent {

private val log = LoggerFactory.getLogger(javaClass)

@PostConstruct fun ensureSchedule(@Value("\${scheduler.retry.onStart.ms:30000}") ensureSchedulerFrequency: Long) {
@PostConstruct fun ensureSchedule() {
log.info("Ensuring scheduler convergence task exists")
queue.ensure(ScheduleConvergence(), Duration.ofMillis(ensureSchedulerFrequency))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ConvergeIntentHandler
private val refreshesId = registry.createId("intent.refreshes")

override fun handle(message: ConvergeIntent) {
log.info("Converging {}", value("intent", message.intent.id()))
log.debug("Converging {}", value("intent", message.intent.id()))

if (clock.millis() > message.timeoutTtl) {
log.warn("Intent timed out, canceling converge for {}", value("intent", message.intent.id()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.netflix.spinnaker.keel.controllers.v1

import com.netflix.spinnaker.config.KeelProperties
import com.netflix.spinnaker.keel.Intent
import com.netflix.spinnaker.keel.IntentActivityRepository
import com.netflix.spinnaker.keel.IntentRepository
Expand All @@ -24,7 +25,9 @@ import com.netflix.spinnaker.keel.dryrun.DryRunIntentLauncher
import com.netflix.spinnaker.keel.event.AfterIntentDeleteEvent
import com.netflix.spinnaker.keel.event.AfterIntentUpsertEvent
import com.netflix.spinnaker.keel.model.UpsertIntentRequest
import com.netflix.spinnaker.keel.orca.OrcaIntentLauncher
import com.netflix.spinnaker.keel.tracing.TraceRepository
import net.logstash.logback.argument.StructuredArguments
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.ApplicationEventPublisher
Expand All @@ -43,10 +46,12 @@ import javax.ws.rs.QueryParam
class IntentController
@Autowired constructor(
private val dryRunIntentLauncher: DryRunIntentLauncher,
private val orcaIntentLauncher: OrcaIntentLauncher,
private val intentRepository: IntentRepository,
private val intentActivityRepository: IntentActivityRepository,
private val traceRepository: TraceRepository,
private val applicationEventPublisher: ApplicationEventPublisher
private val applicationEventPublisher: ApplicationEventPublisher,
private val keelProperties: KeelProperties
) {

private val log = LoggerFactory.getLogger(javaClass)
Expand All @@ -68,7 +73,6 @@ class IntentController
// TODO rz - validate intents
// TODO rz - calculate graph

// TODO rz - config for running immediately
// TODO rz - add "notes" API property for history/audit

if (req.dryRun) {
Expand All @@ -79,6 +83,12 @@ class IntentController

req.intents.forEach { intent ->
intentRepository.upsertIntent(intent)

if (keelProperties.immediatelyRunIntents) {
log.info("Immediately launching intent {}", StructuredArguments.value("intent", intent.id()))
orcaIntentLauncher.launch(intent)
}

intentList.add(UpsertIntentResponse(intent.id(), intent.status))
applicationEventPublisher.publishEvent(AfterIntentUpsertEvent(intent))
}
Expand Down

0 comments on commit a650426

Please sign in to comment.