Stores hash of pod manifest in mirror pod's annotation

Use the hash to track whether the mirror pod is a truthful representation of
the static pod.
This commit is contained in:
Yu-Ju Hong
2015-10-20 13:51:54 -07:00
parent b896a66679
commit f8aa206ffa
6 changed files with 45 additions and 29 deletions

View File

@@ -52,7 +52,7 @@ func (mc *basicMirrorClient) CreateMirrorPod(pod *api.Pod) error {
for k, v := range pod.Annotations {
copyPod.Annotations[k] = v
}
copyPod.Annotations[kubetypes.ConfigMirrorAnnotationKey] = kubetypes.MirrorType
copyPod.Annotations[kubetypes.ConfigMirrorAnnotationKey] = getPodHash(pod)
_, err := mc.apiserverClient.Pods(copyPod.Namespace).Create(&copyPod)
return err
@@ -81,9 +81,16 @@ func IsStaticPod(pod *api.Pod) bool {
}
func IsMirrorPod(pod *api.Pod) bool {
if value, ok := pod.Annotations[kubetypes.ConfigMirrorAnnotationKey]; !ok {
return false
} else {
return value == kubetypes.MirrorType
}
_, ok := pod.Annotations[kubetypes.ConfigMirrorAnnotationKey]
return ok
}
func getHashFromMirrorPod(pod *api.Pod) (string, bool) {
hash, ok := pod.Annotations[kubetypes.ConfigMirrorAnnotationKey]
return hash, ok
}
func getPodHash(pod *api.Pod) string {
// The annotation exists for all static pods.
return pod.Annotations[kubetypes.ConfigHashAnnotationKey]
}