Skip to content

Commit

Permalink
fix config reset and improve error display when worker crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodriguez committed Nov 6, 2023
1 parent 53ca11d commit db13c1b
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 45 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/basic-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ jobs:
python3.11 ./platform/panduza_platform/__main__.py &
sleep 1
- name: Export test env variables
uses: cardinalby/export-env-action@v1
with:
envFile: './platform/tests/auto/envs/fake_bench.env'
# - name: Export test env variables
# uses: cardinalby/export-env-action@v1
# with:
# envFile: './platform/tests/auto/envs/fake_bench.env'

# ---
- name: Execute tests
Expand Down
4 changes: 4 additions & 0 deletions client/panduza/robof/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class KeywordsPlatform(object):
def panduza_platform_load_dtree(self, platform_alias, dtree):
"""
"""

if dtree == '':
dtree = {}

p = Platform(alias=platform_alias)
p.dtree.content.set(dtree)

Expand Down
3 changes: 1 addition & 2 deletions platform/panduza_platform/core/mqtt_async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,7 @@ def __on_socket_close(self, client, userdata, sock):
self.log.warning("Socket closed")

# self.__state = "error"
self.worker_panic()

# self.worker_panic()

# ---

Expand Down
21 changes: 13 additions & 8 deletions platform/panduza_platform/core/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,20 @@ async def load_config_content_task(self, new_dtree):
# Internal store of the platform config
self.dtree = new_dtree

# ---

async def handle_worker_panic(self, name, status):
#
self.log.error(f"PANIC: {name}")

self.log.error( str(status.get("name", "")) + "\n" )
self.log.error( str(status.get("final_state", "")) + "\n" )
self.log.error( str(status.get("error_string", "")) + "\n" )

# Remove mounted device from the previous configuration
await self.unmount_all_devices()

# ---



Expand Down Expand Up @@ -236,14 +249,6 @@ async def load_config_content_task(self, new_dtree):



# # ---

# def panic(self):
# """
# """
# self.alive = False

# # ---

# def load_interface(self, bench_name, device, interface_config):
# """Load a new interface
Expand Down
4 changes: 2 additions & 2 deletions platform/panduza_platform/core/platform_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ async def __drv_state_err(self):
"""
"""
try:
self.worker_panic()
await self.worker_panic()
await self._PZA_DRV_loop_err()
except Exception as e:
self.log.error(str(e))
Expand Down Expand Up @@ -390,7 +390,7 @@ async def _prepare_update(self, update_obj, att, cmd_att, field,

# Check types
if not type(v) in valid_types:
raise Exception(f"Invalid type for direction.value {type(v)}")
raise Exception(f"Invalid type for {att}.{field} got: {type(v)} / expect: {valid_types}")

# Try to set
await set_callback(v)
Expand Down
8 changes: 6 additions & 2 deletions platform/panduza_platform/core/platform_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ def __init__(self) -> None:
def reset_work_time(self):
self.work_time = 0

# def worker_panic(self):
# self.__thread.handle_worker_panic(self.PZA_WORKER_name())
# ---

async def worker_panic(self):
await self.platform.handle_worker_panic(self.PZA_WORKER_name(), self.PZA_WORKER_status())

# ---

async def task(self):
"""
Expand Down
3 changes: 2 additions & 1 deletion platform/tests/auto/benches/virtual/bench.resource
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ Setup Bench Config
${PLATFORMS} Panduza Scan All Platforms localhost 1883
Log ${PLATFORMS}
Create test platform alias from scan ${PLATFORMS} test_platform
Panduza platform load dtree test_platform
Panduza platform load dtree test_platform ${EMPTY}
Sleep 1


Setup Bench Fake Interfaces
Set Log Level DEBUG
${PLATFORMS} Panduza Scan All Platforms localhost 1883
Expand Down
1 change: 0 additions & 1 deletion platform/tests/auto/envs/.gitkeep

This file was deleted.

1 change: 0 additions & 1 deletion platform/tests/auto/envs/fake_bench.env

This file was deleted.

24 changes: 0 additions & 24 deletions platform/tests/auto/envs/fake_bench.sh

This file was deleted.

0 comments on commit db13c1b

Please sign in to comment.