Skip to content

Commit e8a2d4b

Browse files
committed
Fix port discovery diff
Sort service ports by port number before comparing slices
1 parent 9a9baad commit e8a2d4b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/router/kubernetes.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package router
33
import (
44
"fmt"
55
"github.com/google/go-cmp/cmp"
6+
"github.com/google/go-cmp/cmp/cmpopts"
67
flaggerv1 "github.com/weaveworks/flagger/pkg/apis/flagger/v1alpha3"
78
clientset "github.com/weaveworks/flagger/pkg/client/clientset/versioned"
89
"go.uber.org/zap"
@@ -128,7 +129,10 @@ func (c *KubernetesRouter) reconcileService(canary *flaggerv1.Canary, name strin
128129
}
129130

130131
if svc != nil {
131-
portsDiff := cmp.Diff(svcSpec.Ports, svc.Spec.Ports)
132+
sortPorts := func(a, b interface{}) bool {
133+
return a.(corev1.ServicePort).Port < b.(corev1.ServicePort).Port
134+
}
135+
portsDiff := cmp.Diff(svcSpec.Ports, svc.Spec.Ports, cmpopts.SortSlices(sortPorts))
132136
selectorsDiff := cmp.Diff(svcSpec.Selector, svc.Spec.Selector)
133137

134138
if portsDiff != "" || selectorsDiff != "" {

0 commit comments

Comments
 (0)