diff --git a/kontrol-service/engine/flow/dev_flow.go b/kontrol-service/engine/flow/dev_flow.go index a4ff802..d1adb58 100644 --- a/kontrol-service/engine/flow/dev_flow.go +++ b/kontrol-service/engine/flow/dev_flow.go @@ -351,7 +351,7 @@ func DeleteDevFlow(pluginRunner *plugins.PluginRunner, flowId string, service *r for pluginIdx, plugin := range service.StatefulPlugins { logrus.Infof("Attempting to delete flow for plugin '%v' on flow '%v'", plugin.Name, flowId) pluginId := plugins.GetPluginId(flowId, service.ServiceID, pluginIdx) - err := pluginRunner.DeleteFlow(plugin.Name, pluginId, map[string]string{}) + err := pluginRunner.DeleteFlow(plugin.Name, pluginId) if err != nil { logrus.Errorf("Error deleting flow: %v.", err) return stacktrace.Propagate(err, "An error occurred while trying to call delete flow of plugin '%v' on service '%v' for flow '%v'", plugin.Name, service.ServiceID, flowId) diff --git a/kontrol-service/plugins/plugins.go b/kontrol-service/plugins/plugins.go index eb64a8b..2bcc23c 100644 --- a/kontrol-service/plugins/plugins.go +++ b/kontrol-service/plugins/plugins.go @@ -91,7 +91,7 @@ func (pr *PluginRunner) CreateFlow(pluginUrl string, serviceSpec corev1.ServiceS return newDeploymentSpec, string(configMapBytes), nil } -func (pr *PluginRunner) DeleteFlow(pluginUrl, flowUuid string, arguments map[string]string) error { +func (pr *PluginRunner) DeleteFlow(pluginUrl, flowUuid string) error { repoPath, err := pr.getOrCloneRepo(pluginUrl) if err != nil { return fmt.Errorf("failed to get or clone repository: %v", err) @@ -102,7 +102,7 @@ func (pr *PluginRunner) DeleteFlow(pluginUrl, flowUuid string, arguments map[str return err } - _, err = runPythonDeleteFlow(repoPath, configMap, flowUuid, arguments) + _, err = runPythonDeleteFlow(repoPath, configMap, flowUuid) if err != nil { return err } @@ -216,7 +216,8 @@ with open('%s', 'w') as f: return string(resultBytes), nil } -func runPythonDeleteFlow(repoPath, configMap, flowUuid string, arguments map[string]string) (string, error) { +func runPythonDeleteFlow(repoPath, configMap, flowUuid string) (string, error) { + scriptPath := filepath.Join(repoPath, "main.py") if _, err := os.Stat(scriptPath); os.IsNotExist(err) { @@ -235,11 +236,6 @@ func runPythonDeleteFlow(repoPath, configMap, flowUuid string, arguments map[str } } - argsJSON, err := json.Marshal(arguments) - if err != nil { - return "", fmt.Errorf("failed to marshal arguments: %v", err) - } - tempResultFile, err := os.CreateTemp("", "result_*.json") if err != nil { return "", fmt.Errorf("failed to create temporary result file: %v", err) @@ -255,7 +251,6 @@ import main config_map = %s flow_uuid = %q -args = json.loads('''%s''') sig = inspect.signature(main.delete_flow) kwargs = {} @@ -264,8 +259,6 @@ for param in sig.parameters.values(): kwargs['flow_uuid'] = flow_uuid elif param.name == 'config_map': kwargs['config_map'] = config_map - elif param.name in args: - kwargs[param.name] = args[param.name] elif param.default is not param.empty: kwargs[param.name] = param.default else: @@ -277,7 +270,7 @@ result = main.delete_flow(**kwargs) # Write the result to a temporary file with open('%s', 'w') as f: json.dump(result, f) -`, repoPath, configMap, flowUuid, argsJSON, tempResultFile.Name()) +`, repoPath, configMap, flowUuid, tempResultFile.Name()) if err := executePythonScript(venvPath, repoPath, tempScript); err != nil { return "", err diff --git a/kontrol-service/plugins/plugins_test.go b/kontrol-service/plugins/plugins_test.go index 5200156..f7c832c 100644 --- a/kontrol-service/plugins/plugins_test.go +++ b/kontrol-service/plugins/plugins_test.go @@ -95,7 +95,7 @@ func TestSimplePlugin(t *testing.T) { require.NoError(t, err) require.Equal(t, "helloworld", configMapData["original_text"]) - err = runner.DeleteFlow(simplePlugin, flowUuid, map[string]string{}) + err = runner.DeleteFlow(simplePlugin, flowUuid) require.NoError(t, err) // Verify that the flow UUID was removed from memory @@ -120,7 +120,7 @@ func TestIdentityPlugin(t *testing.T) { require.NoError(t, err) require.Equal(t, map[string]interface{}{}, configMapData) - err = runner.DeleteFlow(identityPlugin, flowUuid, map[string]string{}) + err = runner.DeleteFlow(identityPlugin, flowUuid) require.NoError(t, err) // Verify that the flow UUID was removed from memory @@ -146,7 +146,7 @@ func TestComplexPlugin(t *testing.T) { require.NoError(t, err) require.Equal(t, "ip_addr", configMapData["original_value"]) - err = runner.DeleteFlow(complexPlugin, flowUuid, map[string]string{}) + err = runner.DeleteFlow(complexPlugin, flowUuid) require.NoError(t, err) // Verify that the flow UUID was removed from memory @@ -171,7 +171,7 @@ func TestRedisPluginTest(t *testing.T) { require.NoError(t, err) require.Empty(t, configMapData) - err = runner.DeleteFlow(complexPlugin, flowUuid, map[string]string{}) + err = runner.DeleteFlow(complexPlugin, flowUuid) require.NoError(t, err) // Verify that the flow UUID was removed from memory