Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove hard coded replacement of api addr in consumer deployment #363

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ""
}