Skip to content

Commit

Permalink
fix: fix ep resourceVersion comparison and clean up (#901)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmssczy authored and tao12345666333 committed Apr 22, 2022
1 parent db250da commit eb90123
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/ingress/apisix_tls.go
Expand Up @@ -206,7 +206,7 @@ func (c *apisixTlsController) onAdd(obj interface{}) {
func (c *apisixTlsController) onUpdate(prev, curr interface{}) {
oldTls := prev.(*configv2beta3.ApisixTls)
newTls := curr.(*configv2beta3.ApisixTls)
if oldTls.GetResourceVersion() == newTls.GetResourceVersion() {
if oldTls.GetResourceVersion() >= newTls.GetResourceVersion() {
return
}
key, err := cache.MetaNamespaceKeyFunc(curr)
Expand Down
2 changes: 1 addition & 1 deletion pkg/ingress/endpoint.go
Expand Up @@ -133,7 +133,7 @@ func (c *endpointsController) onUpdate(prev, curr interface{}) {
prevEp := prev.(*corev1.Endpoints)
currEp := curr.(*corev1.Endpoints)

if prevEp.GetResourceVersion() == currEp.GetResourceVersion() {
if prevEp.GetResourceVersion() >= currEp.GetResourceVersion() {
return
}
key, err := cache.MetaNamespaceKeyFunc(currEp)
Expand Down
2 changes: 1 addition & 1 deletion pkg/ingress/endpointslice.go
Expand Up @@ -157,7 +157,7 @@ func (c *endpointSliceController) onUpdate(prev, curr interface{}) {
prevEp := prev.(*discoveryv1.EndpointSlice)
currEp := curr.(*discoveryv1.EndpointSlice)

if prevEp.GetResourceVersion() == currEp.GetResourceVersion() {
if prevEp.GetResourceVersion() >= currEp.GetResourceVersion() {
return
}
key, err := cache.MetaNamespaceKeyFunc(currEp)
Expand Down
2 changes: 1 addition & 1 deletion pkg/ingress/secret.go
Expand Up @@ -254,7 +254,7 @@ func (c *secretController) onUpdate(prev, curr interface{}) {
prevSec := prev.(*corev1.Secret)
currSec := curr.(*corev1.Secret)

if prevSec.GetResourceVersion() == currSec.GetResourceVersion() {
if prevSec.GetResourceVersion() >= currSec.GetResourceVersion() {
return
}
key, err := cache.MetaNamespaceKeyFunc(currSec)
Expand Down
5 changes: 2 additions & 3 deletions pkg/ingress/status.go
Expand Up @@ -28,7 +28,6 @@ import (
networkingv1beta1 "k8s.io/api/networking/v1beta1"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/tools/cache"
gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
Expand All @@ -55,7 +54,7 @@ func (c *Controller) verifyGeneration(conditions *[]metav1.Condition, newConditi
}

// recordStatus record resources status
func (c *Controller) recordStatus(at interface{}, reason string, err error, status v1.ConditionStatus, generation int64) {
func (c *Controller) recordStatus(at interface{}, reason string, err error, status metav1.ConditionStatus, generation int64) {
// build condition
message := _commonSuccessMessage
if err != nil {
Expand Down Expand Up @@ -335,7 +334,7 @@ func (c *Controller) ingressPublishAddresses() ([]string, error) {
switch svc.Spec.Type {
case apiv1.ServiceTypeLoadBalancer:
if len(svc.Status.LoadBalancer.Ingress) < 1 {
return addrs, fmt.Errorf(_gatewayLBNotReadyMessage)
return addrs, fmt.Errorf("%s", _gatewayLBNotReadyMessage)
}

for _, ip := range svc.Status.LoadBalancer.Ingress {
Expand Down

0 comments on commit eb90123

Please sign in to comment.