Skip to content

Commit

Permalink
bugfix: pub webhook no longer requires pod ownerRef to exist
Browse files Browse the repository at this point in the history
Signed-off-by: liheng.zms <[email protected]>
  • Loading branch information
zmberg committed Dec 27, 2024
1 parent 2cdb760 commit 621e415
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions pkg/controller/podunavailablebudget/pub_pod_event_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ func GetPubForPod(c client.Client, pod *corev1.Pod) (*policyv1alpha1.PodUnavaila
workload, err := controllerfinder.Finder.GetScaleAndSelectorForRef(ref.APIVersion, ref.Kind, pod.Namespace, ref.Name, "")
if err != nil {
return nil, err
} else if workload == nil {
return nil, nil
}
pubList := &policyv1alpha1.PodUnavailableBudgetList{}
if err = c.List(context.TODO(), pubList, &client.ListOptions{Namespace: pod.Namespace}, utilclient.DisableDeepCopy); err != nil {
Expand All @@ -110,7 +108,7 @@ func GetPubForPod(c client.Client, pod *corev1.Pod) (*policyv1alpha1.PodUnavaila
for i := range pubList.Items {
pub := &pubList.Items[i]
// if targetReference isn't nil, priority to take effect
if pub.Spec.TargetReference != nil {
if pub.Spec.TargetReference != nil && workload != nil {

Check warning on line 111 in pkg/controller/podunavailablebudget/pub_pod_event_handler.go

View check run for this annotation

Codecov / codecov/patch

pkg/controller/podunavailablebudget/pub_pod_event_handler.go#L111

Added line #L111 was not covered by tests
// belongs the same workload
if pubcontrol.IsReferenceEqual(&policyv1alpha1.TargetReference{
APIVersion: workload.APIVersion,
Expand Down

0 comments on commit 621e415

Please sign in to comment.