VMware Cloud Foundation (VCF) – Deleting Tasks

Overview

Every once in awhile, things don’t work so well. VMware Cloud Foundation (VCF) suffers this as well and then you are left with a mess of failed tasks, sometimes, in the tens, but can be in the hundreds, or even thousands!

This is the workflow I follow when I need to mass remove tasks. There may be a better way, I am sure there is, even, but this is how I do it.

VCF API Explorer

Start by logging into SDDC Manager. In the left side menu, select Developer Center at the very bottom.

Filter for or scroll down to Tasks.

Select the first GET to retrieve a list of all tasks. Scroll down to the Try it out section and locate the taskStatus Parameter. Enter the Value of Failed.

Scroll down further and select EXECUTE. Depending on how many failed tasks there are (or whatever status you are looking for), this may take a few moments. You should see a PageOfTask either way.

Select the icon to the immediate left of the PageOfTask. It looks like an arrow pointing to a clipboard.

The next steps can be performed with either Visual Studio Code or Notepad++.

Text Manipulation – Visual Studio Code

Open Visual Studio Code.

Open a new tab, if necessary and paste the contents that you copied.

This will likely be a long JSON file.

Open up a Find window (Edit > Find). Input “id” in the Find text box and press Enter or Return.

On Windows: press Alt + Enter to select all lines.
On macOS: press Option + Enter to select all lines.

Press the Shift key and the right arrow until the end of the line is selected.

Press Ctrl + C to copy all of the “id” entries. Open a new tab and paste the contents with Ctrl + V.

Open up a third tab and paste in the following text on one line:

curl -X DELETE 127.0.0.1/tasks/registrations/<ID OF THE FAILED TASK>

(ref: https://www.martingustafsson.com/removing-failed-tasks-in-sddc-manager/)

Go back to the second tab, the tab where all the “id” entries were pasted. We need to change into Column Selection Mode. Select Selection and select Column Selection Mode. There will be a checkmark when it is active.

Select only the id text without the quotes.

Copy the selected text. Switch over to the third tab, where the curl command was pasted. Select the <ID OF THE FAILED TASK> text and paste the contents of the clipboard.

Staying on this tab, select the first part of the curl command or copy the following:

curl -X DELETE 127.0.0.1/tasks/registrations/

Select column one of all the entries pasted. It will look like a giant blinking cursor.

Paste the text and it will fill in all of the lines with the rest of the command.


Text Manipulation – Notepad++

Open Notepad++.

Open a new tab, if necessary and paste the contents that you copied.

This will likely be a long JSON file.

Open a Find window, Search > Find…

Input “id” in the Find what text box and select Find All in Current Document.

The Search results will show up in the lower portion of the window. Select all (Ctrl + A) and copy the contents (Ctrl + C).

Paste the contents into a new tab.

Open up a third tab and paste in the following text on one line:

curl -X DELETE 127.0.0.1/tasks/registrations/<ID OF THE FAILED TASK>

(ref: https://www.martingustafsson.com/removing-failed-tasks-in-sddc-manager/)

Activate Column Mode (Edit > Column Mode…).

Review the Column Mode Tip menu for ways to use column mode.

Go back to the tab with the pasted “id” contents. I use the Alt keyboard key and select the contents of the “id” with the mouse. Copy the selected text.

Go to the third tab or the tab with the curl command and replace the <ID OF THE FAILED TASK> text with the copied “id” contents.

Staying on this tab, select the first part of the curl command or copy the following:

curl -X DELETE 127.0.0.1/tasks/registrations/

Select the void space using the column mode.

Paste the curl command so that the entire command is visible.


SDDC Manager

There are a few methods to accomplish the next step. The easiest is to make an SSH connection to the SDDC Manager. Log in as vcf, then elevate to root typing su -.

Back in Visual Studio Code (or whatever application you are using for text manipulation), select all of the curl commands with Ctrl + A and then Ctrl + C.

On the ssh session window, paste the clipboard contents. You may have to press Enter or Return on the last line.

Go back to SDDC Manager and Refresh the Tasks.

At this point, all the Failed tasks should be removed (if Failed) was the status you were working with.


Conclusion

Hopefully this post helped clean up the bulk of your SDDC Manager Tasks. If you find any issues or a better way to do this, please take the time to reach out!


Leave a Reply

Your email address will not be published. Required fields are marked *