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

hotfix: race condition #46

Merged
merged 5 commits into from
Aug 1, 2024
Merged

hotfix: race condition #46

merged 5 commits into from
Aug 1, 2024

Conversation

becelot
Copy link
Member

@becelot becelot commented Jul 30, 2024

Fixes a race condition that can occur if more than one ccp service was requesting resources at the same time.

This happened due to the following pattern:

// start of every terraform provider resource implementation
c := m.(*client.Client)

c.HostURL = c.ServiceURLs["ssl-monitoring"]

By accident, c was a globally shared resource. Hence, when two services set the HostURL at approximately the same time, the HostURL was overwritten for the first service, and the wrong endpoint was used.

To fix this issue, every service now has a copy of the client with the correct HostURL already set. The above pattern can therefore be shortened to

c, err := m.(*client.CcpClient).GetService("ssl-monitoring")

@becelot becelot requested review from Seenox and atddo July 30, 2024 13:39
@cancom cancom deleted a comment from incend1o Aug 1, 2024
Copy link
Member

@Seenox Seenox left a comment

Choose a reason for hiding this comment

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

Thanks 🙏

@Seenox Seenox merged commit 019854c into main Aug 1, 2024
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.

3 participants