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

Make installer's Ensure/Install & Remove methods thread-safe #35

Open
radeksimko opened this issue Nov 11, 2021 · 0 comments
Open

Make installer's Ensure/Install & Remove methods thread-safe #35

radeksimko opened this issue Nov 11, 2021 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@radeksimko
Copy link
Member

While reading the relevant code I realized that we make (somewhat unconscious) assumption that the state (removable files) only survives until the next Ensure or Install call, so the user can't really call both or one of those repeatedly, unless they also always call Remove before.

There is a number of problems related to thread-safety currently:

removableSources []src.Removable

We track the state in a slice which isn't guarded by any synchronization mechanism, so if someone was to call Ensure and Remove at the same time this could result in a data race condition.

Additionally the state is shared between both Ensure and Install methods and the Remove method would just remove any removable files that are currently present in the slice.

hc-install/installer.go

Lines 126 to 133 in e677aa4

if i.removableSources != nil {
for _, rs := range i.removableSources {
err := rs.Remove(ctx)
if err != nil {
errs = multierror.Append(errs, err)
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant