Skip to content

Conversation

@bitromortac
Copy link
Contributor

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 failed state, which we don't have so far and we'd end up storing non-useful sessions, but it could be useful for debugging.

@bitromortac bitromortac marked this pull request as ready for review November 20, 2025 13:41
@bitromortac bitromortac force-pushed the 2511-delete-session-after-fail branch from d131076 to 2df8605 Compare November 20, 2025 13:54
Copy link
Contributor

@ViktorT-11 ViktorT-11 left a 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 {
Copy link
Contributor

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?

Copy link
Contributor Author

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 "+
Copy link
Contributor

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.

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.

2 participants