Skip to content

Commit

Permalink
Merge pull request #26 from chuntaojun/fix_issue_25
Browse files Browse the repository at this point in the history
fix: fix issue #25
  • Loading branch information
zhangzerui20 authored Mar 3, 2022
2 parents 4e1a250 + 9143c4b commit 31f1763
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ tags
# Build output
bin
.vscode/
vendor
22 changes: 12 additions & 10 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ package controller

import (
"fmt"
"reflect"
"strings"
"time"

"github.com/polarismesh/polaris-controller/cmd/polaris-controller/app/options"
localCache "github.com/polarismesh/polaris-controller/pkg/cache"
"github.com/polarismesh/polaris-controller/pkg/metrics"
Expand All @@ -25,9 +29,6 @@ import (
"k8s.io/client-go/util/workqueue"
"k8s.io/component-base/metrics/prometheus/ratelimiter"
"k8s.io/klog"
"reflect"
"strings"
"time"
)

// PolarisController
Expand Down Expand Up @@ -765,6 +766,14 @@ func (p *PolarisController) processSyncNamespaceAndService(service *v1.Service)
return err
}

createSvcResponse, err := polarisapi.CreateService(service)
if err != nil {
klog.Errorf("Failed create service %s, err %s", serviceMsg, createSvcResponse.Info)
p.eventRecorder.Eventf(service, v1.EventTypeWarning, polarisEvent,
"Failed create service %s, err %s", serviceMsg, createSvcResponse.Info)
return err
}

if service.Annotations[util.PolarisAliasNamespace] != "" &&
service.Annotations[util.PolarisAliasService] != "" {
createAliasResponse, err := polarisapi.CreateServiceAlias(service)
Expand All @@ -777,13 +786,6 @@ func (p *PolarisController) processSyncNamespaceAndService(service *v1.Service)
}
}

createSvcResponse, err := polarisapi.CreateService(service)
if err != nil {
klog.Errorf("Failed create service %s, err %s", serviceMsg, createSvcResponse.Info)
p.eventRecorder.Eventf(service, v1.EventTypeWarning, polarisEvent,
"Failed create service %s, err %s", serviceMsg, createSvcResponse.Info)
return err
}
return nil
}

Expand Down

0 comments on commit 31f1763

Please sign in to comment.