@@ -30,20 +30,49 @@ func (r *KubernetesIngressResource) ShouldStatusBeUpdated(_ context.Context, tcp
30
30
case tcp .Spec .ControlPlane .Ingress == nil && tcp .Status .Kubernetes .Ingress == nil :
31
31
// No update in case of no ingress in spec, neither in status.
32
32
return false
33
- case tcp .Spec .ControlPlane .Ingress != nil && tcp .Status .Kubernetes .Ingress == nil ,
34
- // Must be updated when TCP is using an Ingress, and status is not tracking it
35
- // or
36
- // Must be updated when the status is referring to an Ingress, although spec doesn't.
37
- tcp .Spec .ControlPlane .Ingress == nil && tcp .Status .Kubernetes .Ingress != nil :
33
+ case tcp .Spec .ControlPlane .Ingress != nil && tcp .Status .Kubernetes .Ingress == nil , // TCP is using an Ingress, Status not tracking it
34
+ tcp .Spec .ControlPlane .Ingress == nil && tcp .Status .Kubernetes .Ingress != nil : // Status tracks an Ingress, Spec doesn't
38
35
return true
39
- case len (r .resource .Status .LoadBalancer .Ingress ) > 0 && tcp .Status .Kubernetes .Ingress == nil || tcp .Status .Kubernetes .Ingress .LoadBalancer .Ingress == nil :
40
- // Must be updated since missing the Ingress status
41
- return true
42
- case r .resource .Status .LoadBalancer .Ingress [0 ].IP != tcp .Status .Kubernetes .Ingress .LoadBalancer .Ingress [0 ].IP :
43
- // Must bne updated, Ingress load balancer IP is slightly different
36
+ case len (tcp .Status .Kubernetes .Ingress .IngressStatus .LoadBalancer .Ingress ) != len (r .resource .Status .LoadBalancer .Ingress ):
37
+ // Mismatch count of tracked LoadBalancer Ingress
44
38
return true
45
39
default :
46
- return tcp .Status .Kubernetes .Ingress .Name != r .resource .GetName () || tcp .Status .Kubernetes .Ingress .Namespace != r .resource .GetNamespace ()
40
+ statusIngress := tcp .Status .Kubernetes .Ingress .IngressStatus .LoadBalancer .Ingress
41
+
42
+ for i , ingress := range r .resource .Status .LoadBalancer .Ingress {
43
+ if ingress .IP != statusIngress [i ].IP {
44
+ return true
45
+ }
46
+
47
+ if len (ingress .Ports ) != len (statusIngress [i ].Ports ) {
48
+ return true
49
+ }
50
+
51
+ for p , port := range ingress .Ports {
52
+ if port .Port != statusIngress [i ].Ports [p ].Port {
53
+ return true
54
+ }
55
+
56
+ if port .Protocol != statusIngress [i ].Ports [p ].Protocol {
57
+ return true
58
+ }
59
+
60
+ if port .Error == nil && statusIngress [i ].Ports [p ].Error != nil ||
61
+ port .Error != nil && statusIngress [i ].Ports [p ].Error == nil {
62
+ return true
63
+ }
64
+
65
+ if port .Error == nil && statusIngress [i ].Ports [p ].Error == nil {
66
+ continue
67
+ }
68
+
69
+ if * port .Error != * statusIngress [i ].Ports [p ].Error {
70
+ return true
71
+ }
72
+ }
73
+ }
74
+
75
+ return false
47
76
}
48
77
}
49
78
0 commit comments