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

SKY-147 Scanner #7

Merged
merged 21 commits into from
May 10, 2022
Merged

SKY-147 Scanner #7

merged 21 commits into from
May 10, 2022

Conversation

ro-tex
Copy link
Collaborator

@ro-tex ro-tex commented May 2, 2022

PULL REQUEST

Overview

This PR introduces a background worker task that scans the DB for underpinned (meaning they don't have enough pinners) skylinks and pins them to the local skyd.

Other items:

  • maybe use a locking library: SKY-146 Unpin endpoint #2 (comment)
    -> Using the mongo-lock library here would be counter-productive because we can't easily find a single skylink record which matches our criteria and it's not locked. We can find all of them and iterate over the cursor, trying to lock one until we manage to do so but this is a much heavier call and it's just unnecessary. The current simple approach of findOneAndUpdate which finds the first skylink that matches our criteria and sets its lock timestamp should be all that we need at this point. This operation should be atomic, so it shouldn't be able to silently fail with either a double-lock or no lock at all.
  • DB methods to use skymodules.Skylink: SKY-146 Unpin endpoint #2 (comment)

Example for Visual Changes

Checklist

Review and complete the checklist to ensure that the PR is complete before assigned to an approver.

  • All new methods or updated methods have clear docstrings
  • Testing added or updated for new methods
  • Verify if any changes impact the WebPortal Health Checks
  • Approriate documentation updated
  • Changelog file created

Issues Closed

@ro-tex ro-tex self-assigned this May 2, 2022
@ro-tex ro-tex mentioned this pull request May 2, 2022
5 tasks
@ro-tex ro-tex changed the base branch from main to ivo/unpin May 2, 2022 11:26
@ro-tex ro-tex changed the title Scanner SKY-147 Scanner May 3, 2022
@linear
Copy link

linear bot commented May 3, 2022

Base automatically changed from ivo/unpin to main May 4, 2022 10:16
ro-tex added 4 commits May 4, 2022 14:09
# Conflicts:
#	api/handlers.go
#	database/skylink.go
#	test/database/skylink_test.go
Refactor a worker a bit to improve readability naming consistency (threaded should be run in a goroutine by itself).
Don't pass the entire configuration struct to submodules, pass only the needed values.
@ro-tex ro-tex marked this pull request as ready for review May 4, 2022 16:29
conf/configuration.go Outdated Show resolved Hide resolved
conf/configuration.go Outdated Show resolved Hide resolved
database/skylink.go Outdated Show resolved Hide resolved
database/skylink.go Outdated Show resolved Hide resolved
database/skylink.go Show resolved Hide resolved
skyd/skyd.go Outdated Show resolved Hide resolved
skyd/skyd.go Outdated Show resolved Hide resolved
skyd/skyd.go Show resolved Hide resolved
skyd/skyd.go Outdated Show resolved Hide resolved
test/database/skylink_test.go Outdated Show resolved Hide resolved
workers/scanner.go Show resolved Hide resolved
api/handlers.go Show resolved Hide resolved
api/handlers.go Show resolved Hide resolved
api/handlers.go Outdated Show resolved Hide resolved
conf/configuration.go Outdated Show resolved Hide resolved
conf/configuration.go Outdated Show resolved Hide resolved
workers/scanner.go Show resolved Hide resolved
workers/scanner.go Show resolved Hide resolved
workers/scanner.go Outdated Show resolved Hide resolved
workers/scanner.go Show resolved Hide resolved
workers/scanner.go Outdated Show resolved Hide resolved
Use a random sia path when pinning a skylink.
api/handlers.go Show resolved Hide resolved
conf/configuration.go Outdated Show resolved Hide resolved
database/skylink.go Outdated Show resolved Hide resolved
database/skylink.go Outdated Show resolved Hide resolved
database/skylink.go Outdated Show resolved Hide resolved
database/skylink.go Outdated Show resolved Hide resolved
database/skylink.go Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
workers/scanner.go Show resolved Hide resolved
workers/scanner.go Outdated Show resolved Hide resolved
@ro-tex ro-tex requested a review from ChrisSchinnerl May 5, 2022 16:38
@ro-tex ro-tex requested a review from MSevey May 5, 2022 16:38
skyd/skyd.go Show resolved Hide resolved
workers/scanner.go Outdated Show resolved Hide resolved
MSevey
MSevey previously approved these changes May 6, 2022
Copy link
Contributor

@MSevey MSevey left a comment

Choose a reason for hiding this comment

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

I think most things can be handled in follow ups to unblock this PR and allow for smaller PRs to handle the individual follow ups

workers/scanner.go Show resolved Hide resolved
workers/scanner.go Show resolved Hide resolved
Wait for the file to reach full redundancy before pinning the next one.
Use the estimated time for reaching full redundancy to decide how long to wait.
peterjan
peterjan previously approved these changes May 9, 2022
@peterjan
Copy link

peterjan commented May 9, 2022

LGTM, I guess it's fine to do everything in a F/U at this point

Randomize sleep between scans.
api/handlers.go Show resolved Hide resolved
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.

4 participants