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

Fix ingress session cleanup #4719

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions supervisor/ingress.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def _cleanup_sessions(self) -> None:
now = utcnow()

sessions = {}
sessions_data: dict[str, IngressSessionData] = {}
sessions_data: dict[str, dict[str, str | None]] = {}
for session, valid in self.sessions.items():
# check if timestamp valid, to avoid crash on malformed timestamp
try:
Expand All @@ -102,7 +102,8 @@ def _cleanup_sessions(self) -> None:

# Is valid
sessions[session] = valid
sessions_data[session] = self.sessions_data.get(session)
if session_data := self.sessions_data.get(session):
sessions_data[session] = session_data

# Write back
self.sessions.clear()
Expand Down
11 changes: 11 additions & 0 deletions tests/test_ingress.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,14 @@ async def test_ingress_save_data(coresys: CoreSys, tmp_supervisor_data: Path):
},
"ports": {},
}


async def test_ingress_reload_ignore_none_data(coresys: CoreSys):
"""Test reloading ingress does not add None for session data and create errors."""
session = coresys.ingress.create_session()
assert session in coresys.ingress.sessions
assert session not in coresys.ingress.sessions_data

await coresys.ingress.reload()
assert session in coresys.ingress.sessions
assert session not in coresys.ingress.sessions_data
Loading