Skip to content

Commit

Permalink
BUG/MINOR: fix logic for detecting updates on namespace events
Browse files Browse the repository at this point in the history
Logic to detect if a namespace was updated on K8s update event was wrong and done the opposite way of what it should be
  • Loading branch information
hdurand0710 committed Oct 31, 2023
1 parent 857d0f8 commit f39d5c8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/store/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ func (k *K8s) EventNamespace(ns *Namespace, data *Namespace) (updateRequired boo
updateRequired = true
case MODIFIED:
nsStore := k.GetNamespace(data.Name)
if updateRequired = nsStore.Equal(data); !updateRequired {
return updateRequired
updateRequired = !EqualMap(nsStore.Labels, data.Labels)
if updateRequired {
nsStore.Labels = utils.CopyMap(data.Labels)
}
nsStore.Labels = utils.CopyMap(data.Labels)
case DELETED:
_, ok := k.Namespaces[data.Name]
if ok {
Expand Down Expand Up @@ -334,11 +334,13 @@ func (k *K8s) EventPublishService(ns *Namespace, data *Service) (updateRequired
oldService.Addresses = newService.Addresses
k.PublishServiceAddresses = newService.Addresses
k.UpdateAllIngresses = true
updateRequired = true
case ADDED:
if service, ok := ns.Services[data.Name]; ok {
k.PublishServiceAddresses = data.Addresses
service.Addresses = data.Addresses
k.UpdateAllIngresses = true
updateRequired = true
return
}
logger.Errorf("Publish service '%s/%s' not found", data.Namespace, data.Name)
Expand All @@ -348,6 +350,7 @@ func (k *K8s) EventPublishService(ns *Namespace, data *Service) (updateRequired
k.PublishServiceAddresses = nil
service.Addresses = nil
k.UpdateAllIngresses = true
updateRequired = true
} else {
logger.Warningf("Publish service '%s/%s' not registered with controller, cannot delete !", data.Namespace, data.Name)
}
Expand Down

0 comments on commit f39d5c8

Please sign in to comment.