Skip to content

Commit

Permalink
fix: validate statefulset pod by name
Browse files Browse the repository at this point in the history
Some controller (e.g. vcluster) will add pod owner reference to statefulset, however this pod is not controlled by statefulset controller, we should not treat it as a statefulset pod.

(cherry picked from commit 6b60a58)
  • Loading branch information
oilbeater committed Jan 18, 2022
1 parent b5544bc commit f3f8c4d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/controller/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,9 @@ func (c *Controller) handleUpdatePod(key string) error {
func isStatefulSetPod(pod *v1.Pod) (bool, string) {
for _, owner := range pod.OwnerReferences {
if owner.Kind == "StatefulSet" && strings.HasPrefix(owner.APIVersion, "apps/") {
return true, owner.Name
if strings.HasPrefix(pod.Name, owner.Name) {
return true, owner.Name
}
}
}
return false, ""
Expand Down

0 comments on commit f3f8c4d

Please sign in to comment.