Skip to content

Commit

Permalink
feat(sql): Ability to enable/disable StorageServiceMigrator via FP …
Browse files Browse the repository at this point in the history
…or YAML

`spinnaker.migration.enabled` (defaults to `false`)
  • Loading branch information
ajordens committed Jul 8, 2019
1 parent 0b2f51a commit c86ff70
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ class CompositeStorageServiceConfiguration() {
)

@Bean
@ConditionalOnProperty("spinnaker.migration.enabled")
fun storageServiceMigrator(registry: Registry,
fun storageServiceMigrator(dynamicConfigService: DynamicConfigService,
registry: Registry,
properties: StorageServiceMigratorConfigurationProperties,
storageServices: List<StorageService>,
entityTagsDAO : EntityTagsDAO) =
StorageServiceMigrator(
dynamicConfigService,
registry,
storageServices.first { it.javaClass.canonicalName.equals(properties.primaryClass) },
storageServices.first { it.javaClass.canonicalName.equals(properties.previousClass) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.netflix.spinnaker.front50.model.ObjectType
import com.netflix.spinnaker.front50.model.StorageService
import com.netflix.spinnaker.front50.model.Timestamped
import com.netflix.spinnaker.front50.model.tag.EntityTagsDAO
import com.netflix.spinnaker.kork.dynamicconfig.DynamicConfigService
import com.netflix.spinnaker.security.AuthenticatedRequest
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.async
Expand All @@ -33,11 +34,11 @@ import java.util.concurrent.TimeUnit
import kotlin.system.measureTimeMillis

class StorageServiceMigrator(
private val dynamicConfigService: DynamicConfigService,
private val registry: Registry,
private val target: StorageService,
private val source: StorageService,
private val entityTagsDAO: EntityTagsDAO

) {

companion object {
Expand Down Expand Up @@ -177,6 +178,11 @@ class StorageServiceMigrator(

@Scheduled(fixedDelay = 60000)
fun migrate() {
if (!dynamicConfigService.isEnabled("spinnaker.migration", false)) {
log.info("Migrator has been disabled")
return
}

val migrationDurationMs = measureTimeMillis {
ObjectType.values().forEach {
if (it != ObjectType.ENTITY_TAGS) {
Expand Down

0 comments on commit c86ff70

Please sign in to comment.