Skip to content

Commit

Permalink
fix(core): don't try to hdel an empty key set if a stage has data for…
Browse files Browse the repository at this point in the history
… all its fields
  • Loading branch information
robfletcher committed May 12, 2017
1 parent 09bc2e6 commit eaa5399
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -590,9 +590,13 @@ class JedisExecutionRepository implements ExecutionRepository {

def serializedStage = serializeStage(stage)
tx.hmset(key, filterValues(serializedStage, notNull()))
tx.hdel(key, serializedStage.keySet().findAll {

def keysToRemove = serializedStage.keySet().findAll {
serializedStage[it] == null
} as String[])
}
if (!keysToRemove.empty) {
tx.hdel(key, keysToRemove as String[])
}
}

@CompileDynamic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import com.netflix.spinnaker.kork.jedis.EmbeddedRedis
import com.netflix.spinnaker.orca.ExecutionStatus
import com.netflix.spinnaker.orca.pipeline.model.Orchestration
import com.netflix.spinnaker.orca.pipeline.model.Pipeline
import com.netflix.spinnaker.orca.pipeline.model.Stage
import com.netflix.spinnaker.orca.pipeline.persistence.ExecutionRepository.ExecutionCriteria
import com.netflix.spinnaker.orca.pipeline.persistence.jedis.JedisExecutionRepository
import redis.clients.jedis.Jedis
Expand Down Expand Up @@ -779,4 +780,28 @@ class JedisExecutionRepositorySpec extends ExecutionRepositoryTck<JedisExecution
stages.name == ["one-whatever", "one", "two-whatever", "two", "three-whatever", "three"]
}
}

def "can save a stage with all data"() {
given:
def pipeline = Pipeline
.builder()
.withApplication("orca")
.withName("dummy-pipeline")
.withStage("one")
.build()

repository.store(pipeline)

def stage = newStage(pipeline, "whatever", "one-whatever", [:], pipeline.namedStage("one"), STAGE_BEFORE)
stage.lastModified = new Stage.LastModifiedDetails(user: "rfletcher@netflix.com", allowedAccounts: ["whatever"], lastModifiedTime: System.currentTimeMillis())
stage.startTime = System.currentTimeMillis()
stage.endTime = System.currentTimeMillis()
stage.refId = "1<1"

when:
repository.storeStage(stage)

then:
notThrown(Exception)
}
}

0 comments on commit eaa5399

Please sign in to comment.