Skip to content

Commit

Permalink
refactor(clouddriver): Shortening kato operation request id (#3111)
Browse files Browse the repository at this point in the history
There's nothing strictly wrong with the current request ID, it's just super long. This
change will hash the entire request ID rather than just the payload body so it's shorter.
  • Loading branch information
robzienert committed Aug 27, 2019
1 parent 91e2301 commit bd596e4
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.netflix.spinnaker.orca.clouddriver


import com.google.common.hash.Hashing
import com.netflix.spinnaker.orca.ExecutionContext
import com.netflix.spinnaker.orca.clouddriver.model.Task
Expand Down Expand Up @@ -56,10 +55,8 @@ class KatoService {

private static String requestId(Object payload) {
final ExecutionContext context = ExecutionContext.get()
return "${context.getStageId()}-${context.getStageStartTime()}-${requestHash(payload)}".toString()
}

private static String requestHash(Object payload) {
return Hashing.sha256().hashBytes(OrcaObjectMapper.getInstance().writeValueAsBytes(payload))
final byte[] payloadBytes = OrcaObjectMapper.getInstance().writeValueAsBytes(payload)
return Hashing.sha256().hashBytes(
"${context.getStageId()}-${context.getStageStartTime()}-${payloadBytes}".toString().bytes)
}
}

0 comments on commit bd596e4

Please sign in to comment.