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

Disk add dialog: Change format together with the storage pool #1331

Merged
merged 2 commits into from
Nov 29, 2023

Conversation

martinpitt
Copy link
Member

Otherwise we create a race condition: The ModalBody already gets re-rendered with the new pool name, but with possibly with a format that is invalid for the new pool type. That triggers our new assertion.

This is very redundant with the effect which fine-tunes the format and disk type according to the other data. This effect is evil and should be dropped, but doing so requires more intrusive code cleanup. Introduce a helper function to avoid repeated code.


Follow-up from #1327 (comment)

@martinpitt
Copy link
Member Author

Some flakes, not sure if relevant.

@martinpitt martinpitt marked this pull request as ready for review November 28, 2023 10:03
@martinpitt
Copy link
Member Author

A better step would obviously be to drop the effect entirely. I'll see if I can find some time to experiment with that. In the meantime, @KKoukiou do you think this is an improvement, or does it make the thing even more complicated?

Copy link
Collaborator

@KKoukiou KKoukiou left a comment

Choose a reason for hiding this comment

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

I like the approach.

src/components/vm/disks/diskAdd.jsx Outdated Show resolved Hide resolved
@KKoukiou
Copy link
Collaborator

A better step would obviously be to drop the effect entirely. I'll see if I can find some time to experiment with that. In the meantime, @KKoukiou do you think this is an improvement, or does it make the thing even more complicated?

If you want to take it a step further, check the useEffect for the 'diskParams.file' state. It also has logic for changing the device and the format.

@martinpitt
Copy link
Member Author

check the useEffect for the 'diskParams.file' state

Thanks for pointing out! It's not quite the same, as that's for a pool vs. a file, but it would make sense to factorize the logic. I'll think about that.

@martinpitt
Copy link
Member Author

@KKoukiou I didn't see any significant overlap in the end. But I did clean up the effect a bit to avoid an unnecessary and racy state update.

@martinpitt martinpitt marked this pull request as draft November 28, 2023 16:19
@martinpitt
Copy link
Member Author

martinpitt commented Nov 29, 2023

Meh, every time I take a stab at this code, it crumbles into pieces. I'll back out 81e95b9 , let's at least fix the first issue.

Wait until the auto-detection of the disk format for an iso file is
finished before setting it. Otherwise it could happen that the
auto-detection changes the value after the test.
Otherwise we create a race condition: The ModalBody already gets
re-rendered with the new pool name, but with possibly with a format that
is invalid for the new pool type. That triggers our new assertion.

This is very redundant with the effect which fine-tunes the
format and disk type according to the other data. This effect is evil
and should be dropped, but doing so requires more intrusive code
cleanup. Introduce a helper function to avoid repeated code.
@martinpitt martinpitt marked this pull request as ready for review November 29, 2023 07:33
@martinpitt martinpitt requested a review from KKoukiou November 29, 2023 07:33
@KKoukiou KKoukiou merged commit 4deef0d into cockpit-project:main Nov 29, 2023
14 checks passed
@KKoukiou KKoukiou deleted the format-race branch November 29, 2023 10:33
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.

2 participants