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

Added support for labels for AWS EC2 creation #4967

Conversation

c-bordon
Copy link
Member

close #4866

The methods are updated to support the definition of tags for creating EC2 instances in AWS.

These are defined as mandatory since the script will fail if any of them are not defined. This is done this way because AWS accounts (for the moment wazuh-dev, but in the future all of them) have the definition of these 3 tags mandatory.

Tests

deployability/modules/allocation/aws/provider.py Outdated Show resolved Hide resolved
deployability/launchers/allocation.py Outdated Show resolved Hide resolved
@c-bordon c-bordon requested a review from teddytpc1 February 16, 2024 13:33
@teddytpc1 teddytpc1 merged commit 6751d7b into enhancement/4865-dtt1-iteration-3-allocation-module-enable-loading-an-existing-ssh-key-pair Feb 16, 2024
@teddytpc1 teddytpc1 deleted the enhancement/4866-dtt1-iteration-3-allocation-module-implement-name-and-type-labels-on-vms-creation branch February 16, 2024 13:35
@c-bordon
Copy link
Member Author

The change proposed by @teddytpc1 was taken advantage of and the regex for the issue URL and error messages were improved.

New tests:

AWS

Termination date label:

cbordon@cbordon-MS-7C88:~/Documents/wazuh/repositorios/wazuh-qa/deployability$ python3 launchers/allocation.py --composite-name linux-ubuntu-22.04-amd64 --provider aws --size micro --label-issue https://github.com/wazuh/internal-devel-requests/issues/775 --label-team core --label-termination-date "2024-02-25 "
[2024-02-16 10:09:37] [INFO] ALLOCATOR: Creating instance at /tmp/wazuh-qa
[2024-02-16 10:09:38] [DEBUG] ALLOCATOR: No config provided. Generating from payload
[2024-02-16 10:09:38] [ERROR] ALLOCATOR: The termination_date label was not provided or is of incorrect format, example: 2024-02-25 12:00:00.
cbordon@cbordon-MS-7C88:~/Documents/wazuh/repositorios/wazuh-qa/deployability$ python3 launchers/allocation.py --composite-name linux-ubuntu-22.04-amd64 --provider aws --size micro --label-issue https://github.com/wazuh/internal-devel-requests/issues/775 --label-team core --label-termination-date "2024/02/25 12:00:00"
[2024-02-16 10:10:11] [INFO] ALLOCATOR: Creating instance at /tmp/wazuh-qa
[2024-02-16 10:10:11] [DEBUG] ALLOCATOR: No config provided. Generating from payload
[2024-02-16 10:10:11] [ERROR] ALLOCATOR: The termination_date label was not provided or is of incorrect format, example: 2024-02-25 12:00:00.
cbordon@cbordon-MS-7C88:~/Documents/wazuh/repositorios/wazuh-qa/deployability$ python3 launchers/allocation.py --composite-name linux-ubuntu-22.04-amd64 --provider aws --size micro --label-issue https://github.com/wazuh/internal-devel-requests/issues/775 --label-team core --label-termination-date "25-02-2024 12:00:00"
[2024-02-16 10:10:22] [INFO] ALLOCATOR: Creating instance at /tmp/wazuh-qa
[2024-02-16 10:10:22] [DEBUG] ALLOCATOR: No config provided. Generating from payload
[2024-02-16 10:10:22] [ERROR] ALLOCATOR: The termination_date label was not provided or is of incorrect format, example: 2024-02-25 12:00:00.
cbordon@cbordon-MS-7C88:~/Documents/wazuh/repositorios/wazuh-qa/deployability$ python3 launchers/allocation.py --composite-name linux-ubuntu-22.04-amd64 --provider aws --size micro --label-issue https://github.com/wazuh/internal-devel-requests/issues/775 --label-team core
[2024-02-16 10:10:28] [INFO] ALLOCATOR: Creating instance at /tmp/wazuh-qa
[2024-02-16 10:10:28] [DEBUG] ALLOCATOR: No config provided. Generating from payload
[2024-02-16 10:10:28] [ERROR] ALLOCATOR: The termination_date label was not provided or is of incorrect format, example: 2024-02-25 12:00:00.

Team label:

cbordon@cbordon-MS-7C88:~/Documents/wazuh/repositorios/wazuh-qa/deployability$ python3 launchers/allocation.py --composite-name linux-ubuntu-22.04-amd64 --provider aws --size micro --label-issue https://github.com/wazuh/internal-devel-requests/issues/775 --label-termination-date "2024-02-25 12:00:00" --label-team testing 
[2024-02-16 10:10:53] [INFO] ALLOCATOR: Creating instance at /tmp/wazuh-qa
[2024-02-16 10:10:53] [DEBUG] ALLOCATOR: No config provided. Generating from payload
[2024-02-16 10:10:53] [ERROR] ALLOCATOR: The team label provided does not match any of the available teams.
cbordon@cbordon-MS-7C88:~/Documents/wazuh/repositorios/wazuh-qa/deployability$ python3 launchers/allocation.py --composite-name linux-ubuntu-22.04-amd64 --provider aws --size micro --label-issue https://github.com/wazuh/internal-devel-requests/issues/775 --label-termination-date "2024-02-25 12:00:00"
[2024-02-16 10:11:01] [INFO] ALLOCATOR: Creating instance at /tmp/wazuh-qa
[2024-02-16 10:11:01] [DEBUG] ALLOCATOR: No config provided. Generating from payload
[2024-02-16 10:11:01] [ERROR] ALLOCATOR: The team label was not provided.

Issue label:

cbordon@cbordon-MS-7C88:~/Documents/wazuh/repositorios/wazuh-qa/deployability$ python3 launchers/allocation.py --composite-name linux-ubuntu-22.04-amd64 --provider aws --size micro  --label-termination-date "2024-02-25 12:00:00" --label-team devops
[2024-02-16 10:12:13] [INFO] ALLOCATOR: Creating instance at /tmp/wazuh-qa
[2024-02-16 10:12:13] [DEBUG] ALLOCATOR: No config provided. Generating from payload
[2024-02-16 10:12:13] [ERROR] ALLOCATOR: The issue label was not provided or is of incorrect format, example: https://github.com/wazuh/<repository>/issues/<issue-number>.
cbordon@cbordon-MS-7C88:~/Documents/wazuh/repositorios/wazuh-qa/deployability$ python3 launchers/allocation.py --composite-name linux-ubuntu-22.04-amd64 --provider aws --size micro  --label-termination-date "2024-02-25 12:00:00" --label-team devops --label-issue https://github.com/wazuh/wazuh-qa/issues/775
[2024-02-16 10:12:45] [INFO] ALLOCATOR: Creating instance at /tmp/wazuh-qa
[2024-02-16 10:12:45] [DEBUG] ALLOCATOR: No config provided. Generating from payload
cbordon@cbordon-MS-7C88:~/Documents/wazuh/repositorios/wazuh-qa/deployability$ python3 launchers/allocation.py --composite-name linux-ubuntu-22.04-amd64 --provider aws --size micro  --label-termination-date "2024-02-25 12:00:00" --label-team devops --label-issue https://github.com/c-bordon/internal-devel-request/issues/775
[2024-02-16 10:13:02] [INFO] ALLOCATOR: Creating instance at /tmp/wazuh-qa
[2024-02-16 10:13:03] [DEBUG] ALLOCATOR: No config provided. Generating from payload
[2024-02-16 10:13:03] [ERROR] ALLOCATOR: The issue label was not provided or is of incorrect format, example: https://github.com/wazuh/<repository>/issues/<issue-number>.
cbordon@cbordon-MS-7C88:~/Documents/wazuh/repositorios/wazuh-qa/deployability$ python3 launchers/allocation.py --composite-name linux-ubuntu-22.04-amd64 --provider aws --size micro  --label-termination-date "2024-02-25 12:00:00" --label-team devops --label-issue https://google.com/wazuh/internal-devel-request/issues/775
[2024-02-16 10:13:16] [INFO] ALLOCATOR: Creating instance at /tmp/wazuh-qa
[2024-02-16 10:13:17] [DEBUG] ALLOCATOR: No config provided. Generating from payload
[2024-02-16 10:13:17] [ERROR] ALLOCATOR: The issue label was not provided or is of incorrect format, example: https://github.com/wazuh/<repository>/issues/<issue-number>.
cbordon@cbordon-MS-7C88:~/Documents/wazuh/repositorios/wazuh-qa/deployability$ python3 launchers/allocation.py --composite-name linux-ubuntu-22.04-amd64 --provider aws --size micro  --label-termination-date "2024-02-25 12:00:00" --label-team devops --label-issue https://github.com/wazuh/internal-devel-request/pull/775
[2024-02-16 10:13:31] [INFO] ALLOCATOR: Creating instance at /tmp/wazuh-qa
[2024-02-16 10:13:31] [DEBUG] ALLOCATOR: No config provided. Generating from payload
[2024-02-16 10:13:31] [ERROR] ALLOCATOR: The issue label was not provided or is of incorrect format, example: https://github.com/wazuh/<repository>/issues/<issue-number>.
cbordon@cbordon-MS-7C88:~/Documents/wazuh/repositorios/wazuh-qa/deployability$ python3 launchers/allocation.py --composite-name linux-ubuntu-22.04-amd64 --provider aws --size micro  --label-termination-date "2024-02-25 12:00:00" --label-team devops --label-issue https://github.com/wazuh/internal-devel-request/issues/testing
[2024-02-16 10:13:40] [INFO] ALLOCATOR: Creating instance at /tmp/wazuh-qa
[2024-02-16 10:13:40] [DEBUG] ALLOCATOR: No config provided. Generating from payload
[2024-02-16 10:13:40] [ERROR] ALLOCATOR: The issue label was not provided or is of incorrect format, example: https://github.com/wazuh/<repository>/issues/<issue-number>.

Successful deploy

cbordon@cbordon-MS-7C88:~/Documents/wazuh/repositorios/wazuh-qa/deployability$ python3 launchers/allocation.py --composite-name linux-ubuntu-22.04-amd64 --provider aws --size micro --label-issue https://github.com/wazuh/internal-devel-requests/issues/775 --label-termination-date "2024-02-25 12:00:00" --label-team core
[2024-02-16 10:14:12] [INFO] ALLOCATOR: Creating instance at /tmp/wazuh-qa
[2024-02-16 10:14:12] [DEBUG] ALLOCATOR: No config provided. Generating from payload
[2024-02-16 10:14:12] [DEBUG] ALLOCATOR: Generating new key pair
[2024-02-16 10:14:12] [DEBUG] ALLOCATOR: Creating base directory: /tmp/wazuh-qa/AWS-5FFE6787-B459-4191-9EE6-E25C5253B988
[2024-02-16 10:14:32] [DEBUG] ALLOCATOR: Renaming temp /tmp/wazuh-qa/AWS-5FFE6787-B459-4191-9EE6-E25C5253B988 directory to /tmp/wazuh-qa/i-0ddae446c8f87f418
[2024-02-16 10:14:32] [INFO] ALLOCATOR: Instance i-0ddae446c8f87f418 created.
[2024-02-16 10:14:33] [INFO] ALLOCATOR: Instance i-0ddae446c8f87f418 started.
[2024-02-16 10:14:34] [INFO] ALLOCATOR: Inventory file generated at /tmp/wazuh-qa/inventory.yml
[2024-02-16 10:14:34] [INFO] ALLOCATOR: Track file generated at /tmp/wazuh-qa/track.yml

Screenshot_20240216_101507

Vagrant

With labels

cbordon@cbordon-MS-7C88:~/Documents/wazuh/repositorios/wazuh-qa/deployability$ python3 launchers/allocation.py --composite-name linux-ubuntu-22.04-amd64 --provider vagrant --size micro --label-issue https://github.com/wazuh/wazuh-jenkins/issues/775 --label-termination-date "2024-02-25 12:00:00" --label-team core
[2024-02-16 10:18:44] [INFO] ALLOCATOR: Creating instance at /tmp/wazuh-qa
[2024-02-16 10:18:44] [DEBUG] ALLOCATOR: No config provided. Generating from payload
[2024-02-16 10:18:44] [DEBUG] ALLOCATOR: Generating new key pair
[2024-02-16 10:18:47] [DEBUG] ALLOCATOR: Vagrantfile created. Creating instance.
[2024-02-16 10:18:47] [INFO] ALLOCATOR: Instance VAGRANT-0977989B-57AE-40DF-B29C-F8DA52F8223B created.
[2024-02-16 10:19:31] [INFO] ALLOCATOR: Instance VAGRANT-0977989B-57AE-40DF-B29C-F8DA52F8223B started.
[2024-02-16 10:19:33] [DEBUG] ALLOCATOR: Using provided credentials
[2024-02-16 10:19:33] [INFO] ALLOCATOR: Inventory file generated at /tmp/wazuh-qa/inventory.yml
[2024-02-16 10:19:33] [INFO] ALLOCATOR: Track file generated at /tmp/wazuh-qa/track.yml

Without labels

cbordon@cbordon-MS-7C88:~/Documents/wazuh/repositorios/wazuh-qa/deployability$ python3 launchers/allocation.py --composite-name linux-ubuntu-22.04-amd64 --provider vagrant --size micro
[2024-02-16 10:21:02] [INFO] ALLOCATOR: Creating instance at /tmp/wazuh-qa
[2024-02-16 10:21:02] [DEBUG] ALLOCATOR: No config provided. Generating from payload
[2024-02-16 10:21:02] [DEBUG] ALLOCATOR: Generating new key pair
[2024-02-16 10:21:05] [DEBUG] ALLOCATOR: Vagrantfile created. Creating instance.
[2024-02-16 10:21:05] [INFO] ALLOCATOR: Instance VAGRANT-B8F51F7F-239D-4D47-B78B-300D9A52C4BF created.
[2024-02-16 10:21:45] [INFO] ALLOCATOR: Instance VAGRANT-B8F51F7F-239D-4D47-B78B-300D9A52C4BF started.
[2024-02-16 10:21:47] [DEBUG] ALLOCATOR: Using provided credentials
[2024-02-16 10:21:47] [INFO] ALLOCATOR: Inventory file generated at /tmp/wazuh-qa/inventory.yml
[2024-02-16 10:21:47] [INFO] ALLOCATOR: Track file generated at /tmp/wazuh-qa/track.yml

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

Successfully merging this pull request may close these issues.

DTT1 - Iteration 3 - Allocation module - Implement name and type labels on VMs creation
2 participants