Sometimes you might be faced with the fact that your
exec.R file isn’t working properly. This may be due to problems in the file itself, in the way your script tries to upload the results to a bucket or on how the pods are handling arguments.
This vignette tries to show you how to debug your deployment on these three scenarios while at the same time giving you an example of how to write your
Suppose you’ve just been through the deployment workflow for your task:
library(kuber) kub_create_cluster("my-cluster") #> ✔ Creating cluster kub_create_task("~/my-dir", "my-cluster", "my-bucket", "my-image", "~/my-key.json") #> ✔ Fetching cluster information #> ✔ Fetching bucket information #> ✔ Creating bucket #> ● Edit `~/my-dir/exec.R'` #> ● Create `~/my-dir/list.rds` with usable objects #> ● Run `kub_push_task("~/my-dir")` file.edit("~/my-dir/exec.R") file.copy("~/my-list.rds", "~/my-dir/list.rds", TRUE) kub_push_task("~/my-dir") #> ✔ Building image #> ✔ Authenticating #> ✔ Pushing image #> ✔ Removing old jobs #> ✔ Creating new jobs kub_run_task("~/my-dir") #> ✔ Authenticating #> ✔ Setting cluster context #> ✔ Creating jobs #> ● Run `kub_list_pods()` to follow up on the pods
But now, when you run
STATUS column says “Error” or some other equivalent undesirable message. First you must check whether
The first debug strategy should be lightly editing your
exec.R file in order for it to run in your local machine. For instance, replace every instance of
saveRDS() and run the script locally:
If the expected RDS files aren’t written to disk, then your problem might be in the code. You can also run the script step by step by also replacing the command line arguments at the top of the file:
In case none of this works, then consider whether
Now you should see what’s happening to the pods themselves. Run
kub_list_pods() and copy the name of the pod you want to examine:
This command will show you the output of your script, which could inform your debugging process. If this isn’t enough, try running the docker container manually:
This will execute your
exec.R inside the container environment and is the closest you will get to your pod without getting inside it. Speaking of which, if nothing has worked up until now, then you should see whether
To do this, you must open two terminal windows. In the first one, run your container:
In the second one, get your container’s ID in order to access it:
With this last command, you’ll essentially be ssh-ing into your pod. This allows you to run any shell command you want, run R scripts in the local environment or even edit any files that might not be setup properly.
If even this doesn’t help you debug your deployment, please create an issue on Github.