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

DTT2 - Provision Module - Findings and recommendations #5176

Open
Tracked by #5116
mhamra opened this issue Apr 3, 2024 · 0 comments
Open
Tracked by #5116

DTT2 - Provision Module - Findings and recommendations #5176

mhamra opened this issue Apr 3, 2024 · 0 comments

Comments

@mhamra
Copy link
Contributor

mhamra commented Apr 3, 2024

Target version Related issue Related PR/dev branch
4.9 #4994 #5150

Description

While developing the unit tests for DTT1 iteration 3 - Provision Module, I had the opportunity to review the source code thoroughly. I list the findings in this issue for discussion and triage.

  • The provision, testing, and allocation modules use import statements that require a PYTHONPATH environment variable of the format [wazuh-qa-repo-path]/deployability. In contrast, the workflow_engine requires the PYTHONPATH format [wazuh-qa-repo-path]/deployability/modules to work. I suggest making each module independent from the others or unifying all the modules in a single Python package.

  • The ProvisionHandler class constructor compares method.lower() == 'assistant'. Uppercase method names are rejected by the constructor, so it is not necessary to convert the method variable to lowercase.

  • The ProvisionHandler class supports the methods ['package', 'assistant', 'source'], but the ProvisionHandler ._get_templates_order function method checks for a method 'aio' that is not supported. The 'aio' method should be supported as a valid method, or it should be removed from ProvisionHandler ._get_templates_order

  • In the Actions class constructor, there is a variable named action_type, and an error message f"Unsupported action_type: {action_type}". The validation and the assignment are related to component types. I suggest changing the variable name to component_type and the error message to Unsupported component_type.

  • The playbook parameter of the Ansible.run_playbook type is str | Path. In the Actions.execute method, I've seen that the run_playbook method has a dict as the playbook parameter. I suggest updating the type to dict | str | Path.
    Four instance variables are in the ComponentType class, but only two are typed. I suggest typing all the instance variables.

  • The provision.update_status variable is not a dict but a runner instance of the Ansible package.

  • The @classmethods decorator must be added to all the validator functions, for example, here:

    @validator('install', 'uninstall', pre=True)
    def validate_install_uninstall(cls, components) -> Union[None, List[str]]:
    if not components:
    return
    component_info = []
    for item in components:
    componentObj = ComponentInfo(**eval(item))

  • The @validator is marked as deprecated and will be removed in the next pydantic version. We must implement @field_validator instead.

  • Fix the typo recived:

    Validate inventory recived.

  • Fix this message, changing provisionment to 'provisioning'

    logger.info(f'Initiating provisionment.')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants