Skip to content

Commit

Permalink
Merge pull request #474 from rphillips/backports/87461
Browse files Browse the repository at this point in the history
Bug 1903248: UPSTREAM: 87461: kubelet: ensure pod UIDs are unique
  • Loading branch information
openshift-merge-robot committed Dec 11, 2020
2 parents ad738ba + efe7e4c commit 8ed9339
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/kubelet/config/common.go
Expand Up @@ -58,13 +58,15 @@ func generatePodName(name string, nodeName types.NodeName) string {
func applyDefaults(pod *api.Pod, source string, isFile bool, nodeName types.NodeName) error {
if len(pod.UID) == 0 {
hasher := md5.New()
hash.DeepHashObject(hasher, pod)
// DeepHashObject resets the hash, so we should write the pod source
// information AFTER it.
if isFile {
fmt.Fprintf(hasher, "host:%s", nodeName)
fmt.Fprintf(hasher, "file:%s", source)
} else {
fmt.Fprintf(hasher, "url:%s", source)
}
hash.DeepHashObject(hasher, pod)
pod.UID = types.UID(hex.EncodeToString(hasher.Sum(nil)[0:]))
klog.V(5).Infof("Generated UID %q pod %q from %s", pod.UID, pod.Name, source)
}
Expand Down

0 comments on commit 8ed9339

Please sign in to comment.