srkukarni closed pull request #2737: The log4j should be prefixed by pulsarRootDir URL: https://github.com/apache/pulsar/pull/2737
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/pulsar-functions/instance/src/main/python/util.py b/pulsar-functions/instance/src/main/python/util.py index c9337d991f..4736457bbc 100644 --- a/pulsar-functions/instance/src/main/python/util.py +++ b/pulsar-functions/instance/src/main/python/util.py @@ -25,6 +25,7 @@ import os import inspect import sys +import importlib import log @@ -52,7 +53,7 @@ def import_class_from_path(from_path, full_class_name): sys.path.insert(0, from_path) if not classname_path: try: - mod = __import__(class_name, level=-1) + mod = importlib.import_module(class_name) return mod except Exception as e: Log.info("Import failed class_name %s from path %s" % (class_name, from_path)) @@ -60,7 +61,7 @@ def import_class_from_path(from_path, full_class_name): return None else: try: - mod = __import__(classname_path, fromlist=[class_name], level=-1) + mod = importlib.import_module(classname_path) retval = getattr(mod, class_name) return retval except Exception as e: diff --git a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/KubernetesRuntime.java b/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/KubernetesRuntime.java index 631b910a80..7303d8fe9b 100644 --- a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/KubernetesRuntime.java +++ b/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/KubernetesRuntime.java @@ -119,7 +119,7 @@ this.originalCodeFileName = pulsarRootDir + "/" + originalCodeFileName; this.pulsarAdminUrl = pulsarAdminUrl; this.processArgs = RuntimeUtils.composeArgs(instanceConfig, instanceFile, logDirectory, this.originalCodeFileName, pulsarServiceUrl, stateStorageServiceUrl, - authConfig, "$" + ENV_SHARD_ID, GRPC_PORT, -1l, "conf/log4j2.yaml", installUserCodeDependencies); + authConfig, "$" + ENV_SHARD_ID, GRPC_PORT, -1l, pulsarRootDir + "/conf/log4j2.yaml", installUserCodeDependencies); running = false; doChecks(instanceConfig.getFunctionDetails()); } diff --git a/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/KubernetesRuntimeTest.java b/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/KubernetesRuntimeTest.java index 6d2fc23eed..4606e31a4d 100644 --- a/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/KubernetesRuntimeTest.java +++ b/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/KubernetesRuntimeTest.java @@ -124,7 +124,7 @@ public void testJavaConstructor() throws Exception { assertEquals(args.size(), 30); String expectedArgs = "java -cp " + javaInstanceJarFile + " -Dpulsar.functions.java.instance.jar=" + javaInstanceJarFile - + " -Dlog4j.configurationFile=conf/log4j2.yaml " + + " -Dlog4j.configurationFile=/pulsar/conf/log4j2.yaml " + "-Dpulsar.function.log.dir=" + logDirectory + "/" + FunctionDetailsUtils.getFullyQualifiedName(config.getFunctionDetails()) + " -Dpulsar.function.log.file=" + config.getFunctionDetails().getName() + "-$SHARD_ID" + " org.apache.pulsar.functions.runtime.JavaInstanceMain" ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services