Skip to content

Commit

Permalink
Fix: Add kubernetes namespace to function instance url (apache#4701)
Browse files Browse the repository at this point in the history
### Motivation


Currently, if the kubernetes namespace set to deploy functions in is different than the one in which brokers/workers reside, get status and stats doesn't work because the url for instances does not specify the namespace.
  • Loading branch information
jerrypeng authored and sijie committed Jul 21, 2019
1 parent e7c8109 commit 8c3445a
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ public void start() throws Exception {
if (channel == null && stub == null) {
channel = new ManagedChannel[instanceConfig.getFunctionDetails().getParallelism()];
stub = new InstanceControlGrpc.InstanceControlFutureStub[instanceConfig.getFunctionDetails().getParallelism()];
String jobName = createJobName(instanceConfig.getFunctionDetails());
for (int i = 0; i < instanceConfig.getFunctionDetails().getParallelism(); ++i) {
String address = createJobName(instanceConfig.getFunctionDetails()) + "-" +
i + "." + createJobName(instanceConfig.getFunctionDetails());
String address = getServiceUrl(jobName, jobNamespace, i);
channel[i] = ManagedChannelBuilder.forAddress(address, GRPC_PORT)
.usePlaintext(true)
.build();
Expand Down Expand Up @@ -993,6 +993,10 @@ private static String createJobName(String tenant, String namespace, String func
return "pf-" + tenant + "-" + namespace + "-" + functionName;
}

private static String getServiceUrl(String jobName, String jobNamespace, int instanceId) {
return String.format("%s-%d.%s.%s.svc.cluster.local", jobName, instanceId, jobName, jobNamespace);
}

public static void doChecks(Function.FunctionDetails functionDetails) {
final String jobName = createJobName(functionDetails);
if (!jobName.equals(jobName.toLowerCase())) {
Expand Down

0 comments on commit 8c3445a

Please sign in to comment.