Skip to content

Commit

Permalink
Added check if the instance is running when it shouldn't start a new …
Browse files Browse the repository at this point in the history
…storm-webdav too
  • Loading branch information
vrbanecd committed Jan 30, 2025
1 parent aebea82 commit a94aa2a
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions teapot.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ async def _get_proc(cmd):


async def _stop_webdav_instance(username, state, condition):
logger.info("Stopping webdav instance for user %s.", username)
async with condition:
if state[username] == "RUNNING":
state[username] = "STOPPING"
Expand All @@ -473,7 +472,6 @@ async def _stop_webdav_instance(username, state, condition):

pid = session.get("pid")
if pid:
logger.debug("Stopping webdav instance with PID %d", pid)
try:
kill_proc = subprocess.Popen(
f"sudo kill {pid}", shell=True # trunk-ignore(bandit)
Expand Down Expand Up @@ -819,6 +817,45 @@ async def storm_webdav_state(state, condition, sub):
return None, port, user

else:
running = False
loops = 0
while not running:
await anyio.sleep(1)
if loops >= STARTUP_TIMEOUT:
logger.debug(
"The webdav instance for user %s is not reachable after %d tries.",
user,
STARTUP_TIMEOUT,
)
async with condition:
if state[user] == "STARTING" or state[user] == "RUNNING":
state[user] = "NOT RUNNING"
async with app.state.state_lock:
app.state.session_state.pop(user)
logger.debug("The unresponsive webdav instance is removed.")
return None, -1, user
try:
context1 = ssl.create_default_context()
context1.load_verify_locations(
cafile=config["Storm-webdav"]["Storm-webdav_CA"]
)
resp = httpx.get(
"https://"
+ config["Storm-webdav"]["SERVER_ADDRESS"]
+ ":"
+ str(port)
+ "/",
verify=context1,
)
if resp.status_code >= 200:
running = True
except httpx.ConnectError:
loops += 1
logger.debug(
"Waiting for the webdav instance to start. This is check %d/%d.",
loops,
STARTUP_TIMEOUT,
)
async with condition:
async with app.state.state_lock:
port = app.state.session_state[user].get("port", None)
Expand Down

1 comment on commit a94aa2a

@vrbanecd
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
16 16 0 32 50.00 44.091982s

Passed Tests

Name ⏱️ Duration Suite
GET NO TOKEN 0.010 s Teapot-Tests
GET INVALID TOKEN 0.040 s Teapot-Tests
PUT REQUEST INVALID TOKEN 0.010 s Teapot-Tests
PUT REQUEST NO TOKEN 0.010 s Teapot-Tests
GET FILE NO TOKEN 0.011 s Teapot-Tests
GET FILE INVALID TOKEN 0.010 s Teapot-Tests
DELETE REQUEST INVALID TOKEN 0.010 s Teapot-Tests
DELETE REQUEST NO TOKEN 0.009 s Teapot-Tests
GET NO TOKEN EXTRA_AREA 0.010 s Teapot-Tests
GET INVALID TOKEN EXTRA_AREA 0.010 s Teapot-Tests
PUT REQUEST INVALID TOKEN EXTRA_AREA 0.010 s Teapot-Tests
PUT REQUEST NO TOKEN EXTRA_AREA 0.009 s Teapot-Tests
GET FILE NO TOKEN EXTRA_AREA 0.011 s Teapot-Tests
GET FILE INVALID TOKEN EXTRA_AREA 0.009 s Teapot-Tests
DELETE REQUEST INVALID TOKEN EXTRA_AREA 0.011 s Teapot-Tests
DELETE REQUEST NO TOKEN EXTRA_AREA 0.010 s Teapot-Tests

Failed Tests

Name Message ⏱️ Duration Suite
GET USER1 Url: https://teapot:8081/default_area/ Expected status: 500 != 200 10.658 s Teapot-Tests
GET USER2 Url: https://teapot:8081/default_area/ Expected status: 500 != 200 10.707 s Teapot-Tests
PUT REQUEST USER1 Url: https://teapot:8081/default_area/TestFile1 Expected status: 500 != 201 Also teardown failed: Url: https://teapot:8081/default_area/TestFile1 Expected status: 500 != 204 2.046 s Teapot-Tests
PUT REQUEST USER2 Url: https://teapot:8081/default_area/TestFile1 Expected status: 500 != 201 Also teardown failed: Url: https://teapot:8081/default_area/TestFile1 Expected status: 500 != 204 2.046 s Teapot-Tests
GET FILE USER1 Setup failed: Url: https://teapot:8081/default_area/TestFile2 Expected status: 500 != 201 Also teardown failed: Url: https://teapot:8081/default_area/TestFile2 Expected status: 500 != 204 2.052 s Teapot-Tests
GET FILE USER2 Setup failed: Url: https://teapot:8081/default_area/TestFile2 Expected status: 500 != 201 Also teardown failed: Url: https://teapot:8081/default_area/TestFile2 Expected status: 500 != 204 2.047 s Teapot-Tests
DELETE REQUEST USER1 Setup failed: Url: https://teapot:8081/default_area/TestFile2 Expected status: 500 != 201 1.023 s Teapot-Tests
DELETE REQUEST USER2 Setup failed: Url: https://teapot:8081/default_area/TestFile2 Expected status: 500 != 201 1.024 s Teapot-Tests
GET USER1 EXTRA_AREA Url: https://teapot:8081/extra_area Expected status: 500 != 200 1.022 s Teapot-Tests
GET USER2 EXTRA_AREA Url: https://teapot:8081/extra_area Expected status: 500 != 200 1.025 s Teapot-Tests
PUT REQUEST USER1 EXTRA_AREA Url: https://teapot:8081/extra_area/TestFile1 Expected status: 500 != 201 Also teardown failed: Url: https://teapot:8081/extra_area/TestFile1 Expected status: 500 != 204 2.048 s Teapot-Tests
PUT REQUEST USER2 EXTRA_AREA Url: https://teapot:8081/extra_area/TestFile1 Expected status: 500 != 201 Also teardown failed: Url: https://teapot:8081/extra_area/TestFile1 Expected status: 500 != 204 2.047 s Teapot-Tests
GET FILE USER1 EXTRA_AREA Setup failed: Url: https://teapot:8081/extra_area/TestFile2 Expected status: 500 != 201 Also teardown failed: Url: https://teapot:8081/extra_area/TestFile2 Expected status: 500 != 204 2.053 s Teapot-Tests
GET FILE USER2 EXTRA_AREA Setup failed: Url: https://teapot:8081/extra_area/TestFile2 Expected status: 500 != 201 Also teardown failed: Url: https://teapot:8081/extra_area/TestFile2 Expected status: 500 != 204 2.048 s Teapot-Tests
DELETE REQUEST USER1 EXTRA_AREA Setup failed: Url: https://teapot:8081/extra_area/TestFile2 Expected status: 500 != 201 1.023 s Teapot-Tests
DELETE REQUEST USER2 EXTRA_AREA Setup failed: Url: https://teapot:8081/extra_area/TestFile2 Expected status: 500 != 201 1.031 s Teapot-Tests

Please sign in to comment.