Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deadlock and ux bugs in asoctl #4270

Merged
merged 4 commits into from
Sep 17, 2024
Merged

Fix deadlock and ux bugs in asoctl #4270

merged 4 commits into from
Sep 17, 2024

Conversation

theunrepentantgeek
Copy link
Member

What this PR does / why we need it:

Fixes a deadlock bug that occurs if an error is returned before the first progressbar is created.

Fixes a UX bug where completed progress bars are left on screen as debris.

How does this PR make you feel:
gif

"github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"os"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: avoid reordering these? stdlib imports in first group makes sense IMO.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@@ -128,6 +122,9 @@ func importAzureResource(
return errors.Wrapf(err, "failed to create ARM client")
}

//
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing comment?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

@@ -139,6 +136,9 @@ func importAzureResource(
}
}

// Make sure all output is written when we're done
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: maybe leave a note that this shouldn't be defered until right before Import is called, because the Import call is what actually uses/writes to the progress bar and calls to Wait will deadlock if a bar was added but never written to?

Though... if that's actually the case, is it also possible to deadlock if armIDs is empty? We'd not take the for loop at all but importreporter.NewBar would still be created which is what actually triggers the deadlock?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to test this case somehow?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as one bar is created, nothing deadlocks. The call to importer.Import() will do that, so we should be safe. I'll refactor the code to tidy things up and add some docs.

@theunrepentantgeek theunrepentantgeek added this pull request to the merge queue Sep 17, 2024
Merged via the queue into main with commit b5287c3 Sep 17, 2024
7 checks passed
@theunrepentantgeek theunrepentantgeek deleted the fix/asoctl-bugs branch September 17, 2024 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

3 participants