wazuh / wazuh-qa

Wazuh - Quality Assurance
GNU General Public License v2.0
61 stars 30 forks source link

DDT1 - Allocatiton module - bug macOS host dediicated #5228

Closed fcaffieri closed 1 month ago

fcaffieri commented 1 month ago

Description

The following error was encountered when trying macOS allocation.

Input YAML:

version: 0.1
description: Test agent restart with provisioning agents' with provision module
variables:
  agent-os:
    - macos-sonoma-14.3-amd64
  manager-os: linux-ubuntu-22.04-amd64
  infra-provider: aws
  working-dir: /tmp/dtt1-poc

tasks:
  # Unique manager allocate task
  - task: "allocate-manager-{manager-os}"
    description: "Allocate resources for the manager."
    do:
      this: process
      with:
        path: python3
        args:
          - modules/allocation/main.py
          - action: create
          - provider: "{infra-provider}"
          - size: large
          - composite-name: "{manager-os}"
          - inventory-output: "{working-dir}/manager-{manager-os}/inventory.yaml"
          - track-output: "{working-dir}/manager-{manager-os}/track.yaml"
          - label-termination-date: "1d"
          - label-team: "qa"
    on-error: "abort-all"
    cleanup:
      this: process
      with:
        path: python3
        args:
          - modules/allocation/main.py
          - action: delete
          - track-output: "{working-dir}/manager-{manager-os}/track.yaml"

Error:

[2024-04-16 12:49:45] [INFO] [60817] [ThreadPoolExecutor-0_0] [workflow_engine]: [allocate-agent-macos-sonoma-14.3-amd64] Starting task.
[2024-04-16 12:49:45] [DEBUG] [60817] [ThreadPoolExecutor-0_0] [workflow_engine]: Running task "allocate-agent-macos-sonoma-14.3-amd64" with arguments: ['modules/allocation/main.py', '--action=create', '--provider=aws', '--size=small', '--composite-name=macos-sonoma-14.3-amd64', '--inventory-output=/tmp/dtt1-poc/agent-macos-sonoma-14.3-amd64/inventory.yaml', '--track-output=/tmp/dtt1-poc/agent-macos-sonoma-14.3-amd64/track.yaml', '--label-termination-date=1d', '--label-team=qa']
[2024-04-16 12:49:48] [ERROR] [60817] [ThreadPoolExecutor-0_0] [workflow_engine]: [allocate-agent-macos-sonoma-14.3-amd64] Task failed with error: Error executing process task Traceback (most recent call last):
  File "/home/fcaffieri/wazuh-env/wazuh-qa/deployability/modules/allocation/main.py", line 38, in <module>
    main()
  File "/home/fcaffieri/wazuh-env/wazuh-qa/deployability/modules/allocation/main.py", line 34, in main
    Allocator.run(InputPayload(**vars(parse_arguments())))
  File "/home/fcaffieri/wazuh-env/wazuh-qa/deployability/modules/allocation/allocation.py", line 35, in run
    return cls.__create(payload)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/fcaffieri/wazuh-env/wazuh-qa/deployability/modules/allocation/allocation.py", line 54, in __create
    instance = provider.create_instance(
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/fcaffieri/wazuh-env/wazuh-qa/deployability/modules/allocation/generic/provider.py", line 70, in create_instance
    return cls._create_instance(base_dir, params, config, ssh_key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/fcaffieri/wazuh-env/wazuh-qa/deployability/modules/allocation/aws/provider.py", line 105, in _create_instance
    host_identifier = cls._generate_dedicated_host(config, str(params.composite_name.split("-")[3]))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/fcaffieri/wazuh-env/wazuh-qa/deployability/modules/allocation/aws/provider.py", line 300, in _generate_dedicated_host
    host = client.allocate_hosts(InstanceType=config.type,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/fcaffieri/wazuh-env/wazuh-qa/.venv/lib/python3.11/site-packages/botocore/client.py", line 535, in _api_call
    return self._make_api_call(operation_name, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/fcaffieri/wazuh-env/wazuh-qa/.venv/lib/python3.11/site-packages/botocore/client.py", line 936, in _make_api_call
    request_dict = self._convert_to_request_dict(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/fcaffieri/wazuh-env/wazuh-qa/.venv/lib/python3.11/site-packages/botocore/client.py", line 1010, in _convert_to_request_dict
    request_dict = self._serializer.serialize_to_request(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/fcaffieri/wazuh-env/wazuh-qa/.venv/lib/python3.11/site-packages/botocore/validate.py", line 381, in serialize_to_request
    raise ParamValidationError(report=report.generate_report())
botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid type for parameter TagSpecifications[0].Tags[2].Value, value: None, type: <class 'NoneType'>, valid types: <class 'str'>
c-bordon commented 1 month ago

Testing macOS Sonoma

cbordon@cbordon-MS-7C88:~/Documents/wazuh/repositorios/wazuh-qa$ python3 deployability/modules/allocation/main.py --provider=aws --size=small --composite-name=macos-sonoma-14.3-amd64 --inventory-output=/tmp/dtt1-poc/agent-macos-sonoma-14.3-amd64/inventory.yaml --track-output=/tmp/dtt1-poc/agent-macos-sonoma-14.3-amd64/track.yaml --label-termination-date=1d --label-team=qa
[2024-04-16 16:12:28] [INFO] ALLOCATOR: Creating instance at /tmp/wazuh-qa
[2024-04-16 16:12:28] [DEBUG] ALLOCATOR: No config provided. Generating from payload
[2024-04-16 16:12:28] [DEBUG] ALLOCATOR: Generating new key pair
[2024-04-16 16:12:28] [DEBUG] ALLOCATOR: Creating base directory: /tmp/wazuh-qa/AWS-08107AB8-D35E-46C4-969F-BC54FC83CD82
[2024-04-16 16:12:29] [INFO] ALLOCATOR: Creating dedicated host: sonoma-14.3-amd64-Host-amd64
[2024-04-16 16:12:30] [INFO] ALLOCATOR: Dedicated host created: h-0e7acba641ac61574
[2024-04-16 16:12:48] [DEBUG] ALLOCATOR: Renaming temp /tmp/wazuh-qa/AWS-08107AB8-D35E-46C4-969F-BC54FC83CD82 directory to /tmp/wazuh-qa/i-04abd63b93567a097
[2024-04-16 16:12:48] [INFO] ALLOCATOR: Instance i-04abd63b93567a097 created.
[2024-04-16 16:12:50] [INFO] ALLOCATOR: Instance i-04abd63b93567a097 started.
[2024-04-16 16:12:50] [INFO] ALLOCATOR: Inventory file generated at /tmp/dtt1-poc/agent-macos-sonoma-14.3-amd64/inventory.yaml
[2024-04-16 16:12:50] [INFO] ALLOCATOR: Track file generated at /tmp/dtt1-poc/agent-macos-sonoma-14.3-amd64/track.yaml
cbordon@cbordon-MS-7C88:~/Documents/wazuh/repositorios/wazuh-qa$ cat /tmp/dtt1-poc/agent-macos-sonoma-14.3-amd64/inventory.yaml
ansible_connection: ssh
ansible_host: ec2-107-23-191-112.compute-1.amazonaws.com
ansible_port: 2200
ansible_ssh_private_key_file: /tmp/wazuh-qa/i-04abd63b93567a097/sonoma-14.3-amd64-key-8333
ansible_user: ec2-user
cbordon@cbordon-MS-7C88:~/Documents/wazuh/repositorios/wazuh-qa$ ssh -i /tmp/wazuh-qa/i-04abd63b93567a097/sonoma-14.3-amd64-key-8333 -p 2200 ec2-user@ec2-107-23-191-112.compute-1.amazonaws.com
ssh: connect to host ec2-107-23-191-112.compute-1.amazonaws.com port 2200: Connection timed out
cbordon@cbordon-MS-7C88:~/Documents/wazuh/repositorios/wazuh-qa$ ssh -i /tmp/wazuh-qa/i-04abd63b93567a097/sonoma-14.3-amd64-key-8333 -p 2200 ec2-user@ec2-107-23-191-112.compute-1.amazonaws.com
The authenticity of host '[ec2-107-23-191-112.compute-1.amazonaws.com]:2200 ([107.23.191.112]:2200)' can't be established.
ED25519 key fingerprint is SHA256:Zte1dcelyJzt+Ep3l2yR/I5706V1rfmHocEFpj9W4Fg.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[ec2-107-23-191-112.compute-1.amazonaws.com]:2200' (ED25519) to the list of known hosts.

    ┌───┬──┐   __|  __|_  )
    │ ╷╭╯╷ │   _|  (     /
    │  └╮  │  ___|\___|___|
    │ ╰─┼╯ │  Amazon EC2
    └───┴──┘  macOS Sonoma 14.3

Error reading managed configuration (2: No such file or directory). Proceeding with default configuration.
Error reading managed configuration (2: No such file or directory). Proceeding with default configuration.
Error reading managed configuration (2: No such file or directory). Proceeding with default configuration.
ec2-user@ip-172-31-22-127 ~ % exit
Connection to ec2-107-23-191-112.compute-1.amazonaws.com closed.
cbordon@cbordon-MS-7C88:~/Documents/wazuh/repositorios/wazuh-qa$ python3 deployability/modules/allocation/main.py --action delete --track-output /tmp/dtt1-poc/agent-macos-sonoma-14.3-amd64/track.yaml
[2024-04-16 16:20:32] [INFO] ALLOCATOR: Deleting instance from trackfile /tmp/dtt1-poc/agent-macos-sonoma-14.3-amd64/track.yaml
[2024-04-16 16:20:33] [DEBUG] ALLOCATOR: Deleting credentials: sonoma-14.3-amd64-key-8333
[2024-04-16 16:29:01] [INFO] ALLOCATOR: Releasing dedicated host: h-0e7acba641ac61574
[2024-04-16 16:29:02] [INFO] ALLOCATOR: Unable to release Dedicated Host h-0e7acba641ac61574. mac1.metal hosts must be allocated to your AWS account for at least 24 hour(s). You can release this host any time after 2024-04-17T19:12:30.778Z.
[2024-04-16 16:29:02] [INFO] ALLOCATOR: Instance i-04abd63b93567a097 deleted.

Screenshot_20240416_161842 Screenshot_20240416_162047

fcaffieri commented 1 month ago

LGTM