From 8e6ed0803975428510da81641c0641f1085d1c8b Mon Sep 17 00:00:00 2001 From: ChristianZaccaria Date: Fri, 10 Nov 2023 12:20:20 +0000 Subject: [PATCH] Add debugger template and instructions --- doc/usage/debugger/README.md | 14 ++++++ doc/usage/debugger/launch.json.template | 49 +++++++++++++++++++ .../genericresource/genericresource.go | 2 +- 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 doc/usage/debugger/README.md create mode 100644 doc/usage/debugger/launch.json.template diff --git a/doc/usage/debugger/README.md b/doc/usage/debugger/README.md new file mode 100644 index 00000000..fa90cce3 --- /dev/null +++ b/doc/usage/debugger/README.md @@ -0,0 +1,14 @@ + ## Local debugging with VSCode + Steps outlining how to run MCAD locally from your IDE / debugger. + - Ensure you are authenticated to your Kubernetes/OpenShift Cluster. + - Copy the [launch.json.template](https://github.com/project-codeflare/multi-cluster-app-dispatcher/tree/main/doc/usage/debugger/launch.json.example) file and save it as `launch.json` in the `.vscode` folder in the root of your project. + This can be done by running the following commands in the root of your project: + ```bash + mkdir --parents .vscode + cp --interactive doc/usage/debugger/launch.json.template .vscode/launch.json + ``` + - In the `launch.json` file, update the `args` sections with the path to your kubeconfig. + - In VSCode on the activity bar click `Run and Debug` or `CTRL + SHIFT + D` to start a local debugging session of MCAD. + + ### Optional + To set the desired log level set `--v`, `` in the args sections of the `launch.json` file. diff --git a/doc/usage/debugger/launch.json.template b/doc/usage/debugger/launch.json.template new file mode 100644 index 00000000..5d8b6d46 --- /dev/null +++ b/doc/usage/debugger/launch.json.template @@ -0,0 +1,49 @@ +{ + // MCAD Debugger configuration for VSCode + + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Launch MCAD Controller", + "type": "go", + "request": "launch", + "mode": "auto", + "program": "cmd/kar-controllers/main.go", + // Uncomment the line below to enable race testing. + // "buildFlags": "-race", + "env": { + "DISPATCH_RESOURCE_RESERVATION_TIMEOUT":"120000", + "PREEMPTION":"false", + "DISPATCHER_MODE":"false", + "QUOTA_ENABLED":"false", + }, + // To set the desired log level set "--v", "" in the args. + "args": ["--kubeconfig", "", "--v", "15", "--logtostderr"], + // This controls the working directory the code runs in + "cwd": "${workspaceRoot}", + "showLog": true + }, + { + "name": "Launch MCAD Controller with QuotaManager", + "type": "go", + "request": "launch", + "mode": "auto", + "program": "cmd/kar-controllers/main.go", + "buildFlags": "-race", + "env": { + "DISPATCH_RESOURCE_RESERVATION_TIMEOUT":"120000", + "PREEMPTION":"false", + "DISPATCHER_MODE":"false", + }, + // To set the desired log level set "--v", "" in the args. + "args": ["--kubeconfig", "", "--quotaEnabled", "true", "--v", "4", "--logtostderr"], + // This controls the working directory the code runs in + "cwd": "${workspaceRoot}", + "showLog": true, + "port": 8081 + } + ] +} diff --git a/pkg/controller/queuejobresources/genericresource/genericresource.go b/pkg/controller/queuejobresources/genericresource/genericresource.go index a1057f76..b9686153 100644 --- a/pkg/controller/queuejobresources/genericresource/genericresource.go +++ b/pkg/controller/queuejobresources/genericresource/genericresource.go @@ -337,7 +337,7 @@ func (gr *GenericResources) SyncQueueJob(aw *arbv1.AppWrapper, awr *arbv1.AppWra // Get the related resources of created object // var thisObj *unstructured.Unstructured - //var err1 error + // var err1 error // if namespaced { // thisObj, err1 = dclient.Resource(rsrc).Namespace(namespace).Get(context.Background(), name, metav1.GetOptions{}) // } else {