Skip to content

Commit

Permalink
Fix port discovery diff
Browse files Browse the repository at this point in the history
Sort service ports by port number before comparing slices
  • Loading branch information
stefanprodan committed Oct 5, 2019
1 parent 9a9baad commit e8a2d4b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/router/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package router
import (
"fmt"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
flaggerv1 "github.com/weaveworks/flagger/pkg/apis/flagger/v1alpha3"
clientset "github.com/weaveworks/flagger/pkg/client/clientset/versioned"
"go.uber.org/zap"
Expand Down Expand Up @@ -128,7 +129,10 @@ func (c *KubernetesRouter) reconcileService(canary *flaggerv1.Canary, name strin
}

if svc != nil {
portsDiff := cmp.Diff(svcSpec.Ports, svc.Spec.Ports)
sortPorts := func(a, b interface{}) bool {
return a.(corev1.ServicePort).Port < b.(corev1.ServicePort).Port
}
portsDiff := cmp.Diff(svcSpec.Ports, svc.Spec.Ports, cmpopts.SortSlices(sortPorts))
selectorsDiff := cmp.Diff(svcSpec.Selector, svc.Spec.Selector)

if portsDiff != "" || selectorsDiff != "" {
Expand Down

0 comments on commit e8a2d4b

Please sign in to comment.