-
Notifications
You must be signed in to change notification settings - Fork 163
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
mgmtapi: support deleting segments and beacons #4465
mgmtapi: support deleting segments and beacons #4465
Conversation
Support deleting segments and beacons via the management API of the control and daemon service. This is useful for cleaning up the databases (e.g., in case the issue mentioned in scionproto#4286 occurs)
e941d59
to
e86667b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 25 of 25 files at r1, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @matzf and @oncilla)
spec/control/beacons.yml
line 125 at r1 (raw file):
description: The segment ID of the beacon segment. If the input value is shorter than a segment ID, but matches the prefix of the segment ID of exactly one beacon, then this beacon is deleted.
hm but wouldn't the query delete all the matches? Why do we need that prefix behavior?
spec/control/beacons.yml
line 131 at r1 (raw file):
style: simple explode: false responses:
the implementation seems to also return 500, do we also need to list it here?
spec/segments/spec.yml
line 86 at r1 (raw file):
style: simple explode: false responses:
the implementation seems to also return 500, do we also need to list it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @matzf and @oncilla)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to add the same operations also for certs and trc databases?
Reviewed 3 of 25 files at r1.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @oncilla)
private/storage/beacon/sqlite/db.go
line 247 at r1 (raw file):
e.Lock() defer e.Unlock() _, err := e.db.ExecContext(ctx, "DELETE FROM Beacons WHERE hex(SegID) LIKE ?", partialID+"%")
In the corresponding code in the path db, you use an explicit transaction. Here, in beacons db, the DeleteExpiredBeacons also uses a transaction. Is this not needed here?
spec/segments/spec.yml
line 80 at r1 (raw file):
parameters: - in: path name: segment-id
Document the prefix semantics for this too?
Note that get beacon does not support the prefix semantics...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would make sense, yes.
But I would prefer to do it in a separate PR.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @lukedirtwalker and @matzf)
private/storage/beacon/sqlite/db.go
line 247 at r1 (raw file):
Previously, matzf (Matthias Frei) wrote…
In the corresponding code in the path db, you use an explicit transaction. Here, in beacons db, the DeleteExpiredBeacons also uses a transaction. Is this not needed here?
It's technically not needed no. But for the sake of consistency, I added it here to.
spec/control/beacons.yml
line 125 at r1 (raw file):
Previously, lukedirtwalker (Lukas Vogel) wrote…
hm but wouldn't the query delete all the matches? Why do we need that prefix behavior?
Thing is, we do not log the full ID, thus the prefix behavior.
Added a comment. But I'm on the fence. We could also drop the behavior.
spec/control/beacons.yml
line 131 at r1 (raw file):
Previously, lukedirtwalker (Lukas Vogel) wrote…
the implementation seems to also return 500, do we also need to list it here?
Done.
spec/segments/spec.yml
line 80 at r1 (raw file):
Previously, matzf (Matthias Frei) wrote…
Document the prefix semantics for this too?
Note that get beacon does not support the prefix semantics...
Done.
I'm pretty sure the beacon DB does support the prefix semantics:
scion/private/storage/beacon/sqlite/db.go
Line 254 in fce093e
subQ = append(subQ, "hex(SegID) LIKE (hex(?) || '%')") |
spec/segments/spec.yml
line 86 at r1 (raw file):
Previously, lukedirtwalker (Lukas Vogel) wrote…
the implementation seems to also return 500, do we also need to list it here?
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 13 of 13 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @matzf)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 12 of 25 files at r1, 13 of 13 files at r2, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @oncilla)
spec/segments/spec.yml
line 80 at r1 (raw file):
Previously, oncilla (Dominik Roos) wrote…
Done.
I'm pretty sure the beacon DB does support the prefix semantics:
scion/private/storage/beacon/sqlite/db.go
Line 254 in fce093e
subQ = append(subQ, "hex(SegID) LIKE (hex(?) || '%')")
Aha, thanks. I saw this, but was confused by the string concatenation operator it seems. 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status:
complete! all files reviewed, all discussions resolved (waiting on @oncilla)
spec/segments/spec.yml
line 80 at r1 (raw file):
Previously, matzf (Matthias Frei) wrote…
Aha, thanks. I saw this, but was confused by the string concatenation operator it seems. 😅
Yeah, flash back to theoretical computer science. The only other place I know that uses ||
for string concatenation :)
Support deleting segments and beacons via the management API of the control and daemon service. This is useful for cleaning up the databases (e.g., in case the issue mentioned in #4286 occurs)
This change is