Backblaze / boardwalk

A linear remote execution workflow engine built on top of Ansible
Other
18 stars 1 forks source link

boardwalk (bug): Not all model fields annotated, causing runtime errors #59

Closed asullivan-blze closed 1 year ago

asullivan-blze commented 1 year ago

Relates to #57.

Cause spawning issue:

11:55:44  + exec boardwalk init --limit 
11:55:44  Traceback (most recent call last):
11:55:44    File "/home/****/.local/bin/boardwalk", line 5, in <module>
11:55:44      from boardwalk.cli import cli
11:55:44    File "/home/****/.local/lib/python3.10/site-packages/boardwalk/__init__.py", line 5, in <module>
11:55:44      from .manifest import (
11:55:44    File "/home/****/.local/lib/python3.10/site-packages/boardwalk/manifest.py", line 15, in <module>
11:55:44      from boardwalk.state import LocalState
11:55:44    File "/home/****/.local/lib/python3.10/site-packages/boardwalk/state.py", line 6, in <module>
11:55:44      from boardwalk.host import Host
11:55:44    File "/home/****/.local/lib/python3.10/site-packages/boardwalk/host.py", line 25, in <module>
11:55:44      class Host(BaseModel, extra=Extra.forbid):
11:55:44    File "/home/****/.local/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py", line 104, in __new__
11:55:44      private_attributes = inspect_namespace(
11:55:44    File "/home/****/.local/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py", line 370, in inspect_namespace
11:55:44      raise PydanticUserError(
11:55:44  pydantic.errors.PydanticUserError: A non-annotated attribute was detected: `remote_mutex_path = '/opt/boardwalk.mutex'`. All model fields require a type annotation; if `remote_mutex_path` is not meant to be a field, you may be able to resolve this error by annotating it as a `ClassVar` or updating `model_config['ignored_types']`.
11:55:44  
11:55:44  For further information visit https://errors.pydantic.dev/2.4/u/model-field-missing-annotation

Main required change: add str type hint to Host class in boardwalk/host.py:

    remote_mutex_path: str = "/opt/boardwalk.mutex"
    remote_alert_msg: str = "ALERT: Boardwalk is running a workflow against this host. Services may be interrupted"
    remote_alert_string_formatted: str = f"$(tput -T xterm bold)$(tput -T xterm setaf 1)'{remote_alert_msg}'$(tput -T xterm sgr0)"
    remote_alert_motd: str = f"#!/bin/sh\necho {remote_alert_string_formatted}"
    remote_alert_motd_path: str = "/etc/update-motd.d/99-boardwalk-alert"
    remote_alert_wall_cmd: str = f"wall {remote_alert_string_formatted}"