Skip to content

Commit

Permalink
fix(core): null safety and some debug logging for ongoing issue with …
Browse files Browse the repository at this point in the history
…missing stage data
  • Loading branch information
robfletcher committed May 6, 2017
1 parent c3951bb commit f359591
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import static com.google.common.collect.Maps.filterValues
import static com.netflix.spinnaker.orca.pipeline.model.Execution.DEFAULT_EXECUTION_ENGINE
import static com.netflix.spinnaker.orca.pipeline.model.SyntheticStageOwner.STAGE_BEFORE
import static java.lang.System.currentTimeMillis
import static java.util.Collections.emptySet
import static java.util.Collections.*
import static redis.clients.jedis.BinaryClient.LIST_POSITION.AFTER
import static redis.clients.jedis.BinaryClient.LIST_POSITION.BEFORE

Expand Down Expand Up @@ -620,21 +620,27 @@ class JedisExecutionRepository implements ExecutionRepository {
def stage = new Stage<>()
stage.stageNavigator = stageNavigator
stage.id = stageId

// TODO: temp debug
if (map["stage.${stageId}.status".toString()] == null) {
log.warn("Stage $stageId data is missing ${map.findAll { k, v -> k.startsWith("stage.$stageId") }}")
}

stage.refId = map["stage.${stageId}.refId".toString()]
stage.type = map["stage.${stageId}.type".toString()]
stage.name = map["stage.${stageId}.name".toString()]
stage.startTime = map["stage.${stageId}.startTime".toString()]?.toLong()
stage.endTime = map["stage.${stageId}.endTime".toString()]?.toLong()
stage.status = ExecutionStatus.valueOf(map["stage.${stageId}.status".toString()])
stage.status = map["stage.${stageId}.status".toString()] ? ExecutionStatus.valueOf(map["stage.${stageId}.status".toString()]) : null
stage.initializationStage = map["stage.${stageId}.initializationStage".toString()].toBoolean()
stage.syntheticStageOwner = map["stage.${stageId}.syntheticStageOwner".toString()] ? SyntheticStageOwner.valueOf(map["stage.${stageId}.syntheticStageOwner".toString()]) : null
stage.parentStageId = map["stage.${stageId}.parentStageId".toString()]
stage.requisiteStageRefIds = map["stage.${stageId}.requisiteStageRefIds".toString()]?.tokenize(",") ?: emptySet()
stage.scheduledTime = map["stage.${stageId}.scheduledTime".toString()]?.toLong()
stage.context = mapper.readValue(map["stage.${stageId}.context".toString()], MAP_STRING_TO_OBJECT)
stage.tasks = mapper.readValue(map["stage.${stageId}.tasks".toString()], LIST_OF_TASKS)
stage.context = map["stage.${stageId}.context".toString()] ? mapper.readValue(map["stage.${stageId}.context".toString()], MAP_STRING_TO_OBJECT) : emptyMap()
stage.tasks = map["stage.${stageId}.tasks".toString()] ? mapper.readValue(map["stage.${stageId}.tasks".toString()], LIST_OF_TASKS) : emptyList()
if (map["stage.${stageId}.lastModified".toString()]) {
stage.lastModified = mapper.readValue(map["stage.${stageId}.lastModified".toString()], MAP_STRING_TO_OBJECT)
stage.lastModified = map["stage.${stageId}.lastModified".toString()] ? mapper.readValue(map["stage.${stageId}.lastModified".toString()], MAP_STRING_TO_OBJECT) : emptyMap()
}
stage.execution = execution
execution.stages << stage
Expand Down

0 comments on commit f359591

Please sign in to comment.