Skip to content

Commit

Permalink
fix: deployment to rs reference (kubernetes#2934)
Browse files Browse the repository at this point in the history
Previously template.ObjectMeta will always be empty, deployment will wrongly reference pod with same template.Spec together.
  • Loading branch information
oilbeater authored and k8s-ci-robot committed Apr 19, 2018
1 parent 13d9626 commit b8c4b24
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/app/backend/resource/common/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,11 @@ import (
func FilterDeploymentPodsByOwnerReference(deployment apps.Deployment, allRS []apps.ReplicaSet,
allPods []v1.Pod) []v1.Pod {
var matchingPods []v1.Pod

rsTemplate := v1.PodTemplateSpec{
ObjectMeta: deployment.Spec.Template.ObjectMeta,
Spec: deployment.Spec.Template.Spec,
}

for _, rs := range allRS {
if EqualIgnoreHash(rs.Spec.Template, rsTemplate) {
matchingPods = FilterPodsByControllerRef(&rs, allPods)
}
}
for _, rs := range allRS {
if metav1.IsControlledBy(&rs, &deployment) {
matchingPods = append(matchingPods, FilterPodsByControllerRef(&rs, allPods)...)
}
}

return matchingPods
}
Expand Down

0 comments on commit b8c4b24

Please sign in to comment.