diff --git a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntime.java b/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntime.java index 02af86c733486..50dc975075f6c 100644 --- a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntime.java +++ b/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntime.java @@ -88,7 +88,6 @@ import org.apache.pulsar.functions.secretsproviderconfigurator.SecretsProviderConfigurator; import org.apache.pulsar.functions.utils.Actions; import org.apache.pulsar.functions.utils.FunctionCommon; -import org.apache.pulsar.packages.management.core.common.PackageType; /** * Kubernetes based runtime for running functions. @@ -855,13 +854,8 @@ protected List getExecutorCommand() { } private List getDownloadCommand(Function.FunctionDetails functionDetails, String userCodeFilePath) { - if (Arrays.stream(PackageType.values()).anyMatch(type -> - functionDetails.getPackageUrl().startsWith(type.toString()))) { - return getPackageDownloadCommand(functionDetails.getPackageUrl(), userCodeFilePath); - } else { - return getDownloadCommand(functionDetails.getTenant(), functionDetails.getNamespace(), + return getDownloadCommand(functionDetails.getTenant(), functionDetails.getNamespace(), functionDetails.getName(), userCodeFilePath); - } } private List getDownloadCommand(String tenant, String namespace, String name, String userCodeFilePath) { @@ -908,39 +902,6 @@ && isNotBlank(authConfig.getClientAuthenticationParameters()) userCodeFilePath); } - private List getPackageDownloadCommand(String packageName, String userCodeFilePath) { - // add auth plugin and parameters if necessary - if (authenticationEnabled && authConfig != null) { - if (isNotBlank(authConfig.getClientAuthenticationPlugin()) - && isNotBlank(authConfig.getClientAuthenticationParameters()) - && instanceConfig.getFunctionAuthenticationSpec() != null) { - return Arrays.asList( - pulsarRootDir + configAdminCLI, - "--auth-plugin", - authConfig.getClientAuthenticationPlugin(), - "--auth-params", - authConfig.getClientAuthenticationParameters(), - "--admin-url", - pulsarAdminUrl, - "packages", - "download", - packageName, - "--path", - userCodeFilePath); - } - } - - return Arrays.asList( - pulsarRootDir + configAdminCLI, - "--admin-url", - pulsarAdminUrl, - "packages", - "download", - packageName, - "--path", - userCodeFilePath); - } - private static String setShardIdEnvironmentVariableCommand() { return String.format("%s=${POD_NAME##*-} && echo shardId=${%s}", ENV_SHARD_ID, ENV_SHARD_ID); } diff --git a/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntimeTest.java b/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntimeTest.java index 18fbe2e5160f8..df5c369303c34 100644 --- a/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntimeTest.java +++ b/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntimeTest.java @@ -806,24 +806,6 @@ public void testCustomKubernetesManifestCustomizer() throws Exception { assertEquals(spec.getSpec().getTemplate().getSpec().getServiceAccountName(), "my-service-account"); } - @Test - public void testCustomKubernetesDownloadCommands() throws Exception { - InstanceConfig config = createJavaInstanceConfig(FunctionDetails.Runtime.JAVA, false); - config.setFunctionDetails(createFunctionDetails(FunctionDetails.Runtime.JAVA, false, (fb) -> { - return fb.setPackageUrl("function://public/default/test@v1"); - })); - - factory = createKubernetesRuntimeFactory(null, 10, 1.0, 1.0); - - verifyJavaInstance(config, pulsarRootDir + "/instances/deps", false); - KubernetesRuntime container = factory.createContainer(config, userJarFile, userJarFile, 30l); - V1StatefulSet spec = container.createStatefulSet(); - String expectedDownloadCommand = "pulsar-admin --admin-url http://localhost:8080 packages download " - + "function://public/default/test@v1 --path " + pulsarRootDir + "/" + userJarFile; - String containerCommand = spec.getSpec().getTemplate().getSpec().getContainers().get(0).getCommand().get(2); - assertTrue(containerCommand.contains(expectedDownloadCommand)); - } - InstanceConfig createGolangInstanceConfig() { InstanceConfig config = new InstanceConfig(); @@ -1133,25 +1115,6 @@ public void testJavaConstructorWithAbsolutDownloadDirectoryDefined() throws Exce verifyJavaInstance(config, pulsarRootDir + "/instances/deps", false, factory.getDownloadDirectory()); } - @Test - public void testCustomKubernetesDownloadCommandsWithDownloadDirectoryDefined() throws Exception { - String downloadDirectory = "download/pulsar_functions"; - InstanceConfig config = createJavaInstanceConfig(FunctionDetails.Runtime.JAVA, false); - config.setFunctionDetails(createFunctionDetails(FunctionDetails.Runtime.JAVA, false, (fb) -> { - return fb.setPackageUrl("function://public/default/test@v1"); - })); - - factory = createKubernetesRuntimeFactory(null, 10, 1.0, 1.0, Optional.empty(), downloadDirectory); - - verifyJavaInstance(config, pulsarRootDir + "/instances/deps", false, factory.getDownloadDirectory()); - KubernetesRuntime container = factory.createContainer(config, userJarFile, userJarFile, 30l); - V1StatefulSet spec = container.createStatefulSet(); - String expectedDownloadCommand = "pulsar-admin --admin-url http://localhost:8080 packages download " - + "function://public/default/test@v1 --path " + factory.getDownloadDirectory() + "/" + userJarFile; - String containerCommand = spec.getSpec().getTemplate().getSpec().getContainers().get(0).getCommand().get(2); - assertTrue(containerCommand.contains(expectedDownloadCommand)); - } - @Test public void shouldUseConfiguredMetricsPort() throws Exception { assertMetricsPortConfigured(Collections.singletonMap("metricsPort", 12345), 12345);