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 race condition when listing stacks #15931

Merged
merged 3 commits into from
Apr 15, 2024
Merged

Fix race condition when listing stacks #15931

merged 3 commits into from
Apr 15, 2024

Conversation

tgummerer
Copy link
Collaborator

When listing stacks, we currently try to get all the stacks from the backend, and then get the checkpoint to for each stack to show the summary.

However there's a race between listing the stacks and getting the checkpoints, so the checkpoint may be missing by the time we get to that part of the code.

Unfortunately the errors we're getting form getCheckpoint are not structured, so we can't tell if we got a 404 from the cloud here, so the next best option we have is re-checking whether the stack still exists.

This is another attempt at fixing #15658.

When listing stacks, we currently try to get all the stacks from the
backend, and then get the checkpoint to for each stack to show the
summary.

However there's a race between listing the stacks and getting the
checkpoints, so the checkpoint may be missing by the time we get to
that part of the code.

Unfortunately the errors we're getting form getCheckpoint are not
structured, so we can't tell if we got a 404 from the cloud here, so
the next best option we have is re-checking whether the stack still
exists.
@tgummerer tgummerer requested a review from a team as a code owner April 15, 2024 07:44
return nil, nil, err
// There is a race between listing stacks and getting their checkpoints. If there's an error getting
// the checkpoint, check if the stack still exists before returning an error.
stacks, stackErr := b.getStacks(ctx)
Copy link
Member

Choose a reason for hiding this comment

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

Use stackExists rather than listing the whole bucket again.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah neat that's much better!

@pulumi-bot
Copy link
Contributor

Changelog

[uncommitted] (2024-04-15)

Bug Fixes

  • [backend/diy] Fix race condition when listing stacks
    #15931

@tgummerer tgummerer added this pull request to the merge queue Apr 15, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 15, 2024
@tgummerer tgummerer added this pull request to the merge queue Apr 15, 2024
Merged via the queue into master with commit cd9d160 Apr 15, 2024
49 checks passed
@tgummerer tgummerer deleted the tg/stacks-race branch April 15, 2024 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants