mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
change slots when annotations change (#914)
when the annotations change, we need to get a different slot key to launch new containers with these annotations and let the old containers die off unused. I started on a test for this, but changing all combinations of each field in isolation to change is not very fun without reflection, and there's still a subset of fields we're managing, so it put us in about the same spot as we are now.
This commit is contained in:
@@ -326,6 +326,25 @@ func getSlotQueueKey(call *call) string {
|
|||||||
hash.Write(unsafeBytes("\x00"))
|
hash.Write(unsafeBytes("\x00"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// we need to additionally delimit config and annotations to eliminate overlap bug
|
||||||
|
hash.Write(unsafeBytes("\x00"))
|
||||||
|
|
||||||
|
keys = keys[:0] // clear keys
|
||||||
|
for k := range call.Annotations {
|
||||||
|
i := sort.SearchStrings(keys, k)
|
||||||
|
keys = append(keys, "")
|
||||||
|
copy(keys[i+1:], keys[i:])
|
||||||
|
keys[i] = k
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, k := range keys {
|
||||||
|
hash.Write(unsafeBytes(k))
|
||||||
|
hash.Write(unsafeBytes("\x00"))
|
||||||
|
v, _ := call.Annotations.Get(k)
|
||||||
|
hash.Write(v)
|
||||||
|
hash.Write(unsafeBytes("\x00"))
|
||||||
|
}
|
||||||
|
|
||||||
var buf [sha1.Size]byte
|
var buf [sha1.Size]byte
|
||||||
hash.Sum(buf[:0])
|
hash.Sum(buf[:0])
|
||||||
return string(buf[:])
|
return string(buf[:])
|
||||||
|
|||||||
Reference in New Issue
Block a user