Skip to content

Commit

Permalink
Merge pull request #324 from weaveworks/fix-ports-order
Browse files Browse the repository at this point in the history
Fix port discovery diff
  • Loading branch information
stefanprodan authored Oct 5, 2019
2 parents 9a9baad + 2141d88 commit 5cdacf8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion charts/flagger/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ image:
pullPolicy: IfNotPresent
pullSecret:

podAnnotations: {}
podAnnotations:
prometheus.io/scrape: "true"
prometheus.io/port: "8080"

metricsServer: "http://prometheus:9090"

Expand Down
1 change: 1 addition & 0 deletions kustomize/base/flagger/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ spec:
app: flagger
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "8080"
spec:
serviceAccountName: flagger
containers:
Expand Down
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 5cdacf8

Please sign in to comment.