-
Notifications
You must be signed in to change notification settings - Fork 109
sessions: delete session after registration failure #1174
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
base: master
Are you sure you want to change the base?
sessions: delete session after registration failure #1174
Conversation
d131076 to
2df8605
Compare
ViktorT-11
left a comment
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.
Nice catch 🎉! LGTM
| // If we tried to link to a previous session, we delete the newly | ||
| // created session in the case of errors to avoid having non-revoked | ||
| // sessions lying around. | ||
| fail := func(err error) error { |
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.
Nit: Not sure we need a separate lambda function for this when it's only being called once?
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.
right, I wasn't sure if we also want to delete the session on an error later on, so I left it for now
| if err != nil { | ||
| return nil, fmt.Errorf("error registering session with "+ | ||
| "autopilot server: %v", err) | ||
| return nil, fail(fmt.Errorf("error registering session with "+ |
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.
Given that we're not 100% sure here that this errors due to the session not having been stored on the autopilot server (as this could simplify fail for loss of the connection mid execution for example), I can see the motivation still persisting this on the litd node, to aim to not have sessions stored on the autopilot server, which do not exist on the corresponding litd node.
But since that can already occur for various other reasons as well, I think it's fine to just delete it.
Due to recent changes we'll always create a session first with status
reserved. After the session is created and if the autopilot rejects session registration we are left with a session that can't be used. This is problematic for session linking, as the reserved session would need to be revoked first in order to link another session, but we don't return a reference to the new session for revocation. The session isn't usable anyhow so I suggest to delete it after a failure. I only did that for the registration failure, but we could extend the case to other errors later in the session creation.An alternative to this would be to move the session into a terminal
failedstate, which we don't have so far and we'd end up storing non-useful sessions, but it could be useful for debugging.