Skip to content

Commit

Permalink
Merge pull request #363 from aneeshkp/free-publisher
Browse files Browse the repository at this point in the history
Remove hard coded replacement of api addr in consumer deployment
  • Loading branch information
openshift-merge-bot[bot] authored Oct 15, 2024
2 parents 4620235 + a755e74 commit 8f61fa8
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions examples/consumer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,11 @@ func main() {
isV1Api = common.IsV1Api(apiVersion)

if !isV1Api {
apiAddr = "ptp-event-publisher-service-NODE_NAME.openshift-ptp.svc.cluster.local:9043"
apiAddr = common.SanitizeTransportHost(apiAddr, nodeIP, nodeName)

// get the first publisher and replace the apiAddr
apiAddr = getFirstHTTPPublishers(nodeIP, nodeName, httpEventPublisher)
if apiAddr == "" {
log.Error("cannot find publisher,setting to default `\"localhost:8089\"` address")
}
apiPath = "/api/ocloudNotifications/v2/"
log.Infof("apiVersion=%s, updated apiAddr=%s, apiPath=%s", apiVersion, apiAddr, apiPath)
}
Expand Down Expand Up @@ -384,3 +386,13 @@ func updateHTTPPublishers(nodeIP, nodeName string, addr ...string) {
log.Infof("publisher endpoint updated from %s to %s healthStatusOk %t", s, publisherServiceName, PublisherHealthOk)
}
}

func getFirstHTTPPublishers(nodeIP, nodeName string, addr ...string) string {
for _, s := range addr {
if s == "" {
continue
}
return common.SanitizeTransportHost(s, nodeIP, nodeName)
}
return ""
}

0 comments on commit 8f61fa8

Please sign in to comment.