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

Periodically reload allowlist from file #510

Merged
merged 1 commit into from
May 9, 2024

Conversation

ian-shim
Copy link
Contributor

@ian-shim ian-shim commented Apr 22, 2024

Why are these changes needed?

Deprecated auth.allowlist and periodically reloads allowlist from the json file specified in auth.allowlist-file

  • Merge only when auth.allowlist is no longer in use

Checks

  • I've made sure the lint is passing in this PR.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, in that case, please comment that they are not relevant.
  • Testing Strategy
    • Unit tests
    • Integration tests
    • This PR is not tested :(

@ian-shim ian-shim requested review from dmanc and mooselumph April 22, 2024 04:10
@ian-shim ian-shim marked this pull request as ready for review April 22, 2024 04:10
func (s *DispersalServer) LoadAllowlist() {
al, err := ReadAllowlistFromFile(s.rateConfig.AllowlistFile)
if err != nil {
s.logger.Error("failed to load allowlist", "err", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

So if it fails to load allowlist, it will just keep the old values?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes!

s.logger.Error("failed to load allowlist", "err", err)
return
}
s.rateConfig.Allowlist = al
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this need any locks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think this really needs to be synchronized.
The worst case is that a potentially disallowed request goes through at the moment new allowlist is loaded (or vice versa)

@ian-shim ian-shim merged commit a4ae98e into Layr-Labs:master May 9, 2024
6 checks passed
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