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

Add task information in the allocation logs when create or delete an instance #5623

Conversation

Enaraque
Copy link
Member

@Enaraque Enaraque commented Jul 30, 2024

Related issue
#5614

Description

When an instance was created or deleted, the logs only contained information about the instance ID, making it difficult to recognize each instance if more than one was created or deleted at the same time.

To improve this, more details have been added to the logs to identify the instance more easily. When an action is performed with the instance, the logs now display both the name and ID of the current instance.

  • Before:
[2024-07-30 11:42:26] [INFO] ALLOCATOR: Instance i-02de975e0d07f8b70 created.
[2024-07-30 11:42:27] [INFO] ALLOCATOR: Instance i-02de975e0d07f8b70 started.
  • After:
[2024-07-30 11:42:26] [INFO] ALLOCATOR [QA-5614-UBUNTU-22.04]: Instance i-02de975e0d07f8b70 created.
[2024-07-30 11:42:27] [INFO] ALLOCATOR [QA-5614-UBUNTU-22.04]: Instance i-02de975e0d07f8b70 started.

Note

This change is only effective for instance creation in AWS because when creating a VM with vagrant the identifier is the machine name itself and it does not make sense to display it twice.

Additionally, the issue has been fixed where, when rolling back the creation of an instance, the message [yyy-mm-dd hh:mm:ss] [INFO] ALLOCATOR: Instance i-<id> deleted was displayed twice along with the message [yyy-mm-dd hh:mm:ss] [INFO] ALLOCATOR: Instance i-<id> created successfully, which was contradictory.

  • Before
[2024-07-30 12:36:26] [INFO] ALLOCATOR: Instance i-02de975e0d07f8b70 deleted.
[2024-07-30 12:36:26] [INFO] ALLOCATOR: Instance i-02de975e0d07f8b70 deleted.
[2024-07-30 12:36:26] [INFO] ALLOCATOR: Instance i-02de975e0d07f8b70 created successfully.
  • After
[2024-07-30 12:36:26] [INFO] ALLOCATOR [QA-5614-UBUNTU-22.04]: Instance i-02de975e0d07f8b70 deleted.

Tests

  • Create instance
AWS
  • With --label-issue
root@ip-172-31-47-84:/home/ubuntu/wazuh-qa/deployability# python3 modules/allocation/main.py --action create --provider aws --size micro --composite-name linux-ubuntu-22.04-amd64 --inventory-output "/tmp/4-9-0/logs-tests-5614/inventory.yaml" --track-output "/tmp/4-9-0/logs-tests-5614/track.yaml" --label-issue "https:/wazuh/wazuh-qa/issues/5614" --label-termination-date "1d" --label-team "devops"
[2024-07-30 11:41:51] [DEBUG] SPNEGO._GSS: Python gssapi not available, cannot use any GSSAPIProxy protocols: No module named 'gssapi'
[2024-07-30 11:41:51] [DEBUG] SPNEGO._GSS: Python gssapi IOV extension not available: No module named 'gssapi'
[2024-07-30 11:41:52] [INFO] ALLOCATOR: Creating instance at /tmp/wazuh-qa
[2024-07-30 11:41:53] [DEBUG] ALLOCATOR: No config provided. Generating from payload
[2024-07-30 11:41:53] [DEBUG] ALLOCATOR: Generating new key pair
[2024-07-30 11:41:53] [DEBUG] ALLOCATOR: Creating base directory: /tmp/wazuh-qa/AWS-F289F5C9-D745-42AD-A0BB-EF1CC17AAC24
[2024-07-30 11:42:26] [DEBUG] ALLOCATOR: Renaming temp /tmp/wazuh-qa/AWS-F289F5C9-D745-42AD-A0BB-EF1CC17AAC24 directory to /tmp/wazuh-qa/i-02de975e0d07f8b70
[2024-07-30 11:42:26] [INFO] ALLOCATOR [QA-5614-UBUNTU-22.04]: Instance i-02de975e0d07f8b70 created.
[2024-07-30 11:42:27] [INFO] ALLOCATOR [QA-5614-UBUNTU-22.04]: Instance i-02de975e0d07f8b70 started.
[2024-07-30 11:42:27] [INFO] ALLOCATOR [QA-5614-UBUNTU-22.04]: The inventory file generated at /tmp/4-9-0/logs-tests-5614/inventory.yaml
[2024-07-30 11:42:27] [INFO] ALLOCATOR [QA-5614-UBUNTU-22.04]: The track file generated at /tmp/4-9-0/logs-tests-5614/track.yaml
[2024-07-30 11:42:27] [WARNING] ALLOCATOR [QA-5614-UBUNTU-22.04]: Error on attempt 1 of 30: [Errno None] Unable to connect to port 2200 on 44.220.161.87
[2024-07-30 11:42:57] [INFO] ALLOCATOR [QA-5614-UBUNTU-22.04]: SSH connection successful.
[2024-07-30 11:42:57] [INFO] ALLOCATOR [QA-5614-UBUNTU-22.04]: Instance i-02de975e0d07f8b70 created successfully.
  • With --instance-name
root@ip-172-31-47-84:/home/ubuntu/wazuh-qa/deployability# python3 modules/allocation/main.py --action create --provider aws --size micro --composite-name linux-ubuntu-22.04-amd64 --instance-name test-log-ubuntu22 --inventory-output "/tmp/4-9-0/logs-tests-5614/inventory.yaml" --track-output "/tmp/4-9-0/logs-tests-5614/track.yaml" --label-termination-date "1d" --label-team "devops"
[2024-07-30 15:05:38] [DEBUG] SPNEGO._GSS: Python gssapi not available, cannot use any GSSAPIProxy protocols: No module named 'gssapi'
[2024-07-30 15:05:38] [DEBUG] SPNEGO._GSS: Python gssapi IOV extension not available: No module named 'gssapi'
[2024-07-30 15:05:38] [INFO] ALLOCATOR: Creating instance at /tmp/wazuh-qa
[2024-07-30 15:05:40] [DEBUG] ALLOCATOR: No config provided. Generating from payload
[2024-07-30 15:05:40] [DEBUG] ALLOCATOR: Generating new key pair
[2024-07-30 15:05:40] [DEBUG] ALLOCATOR: Creating base directory: /tmp/wazuh-qa/AWS-28F7B360-94CE-4E72-BCC2-A4601AF4871F
[2024-07-30 15:06:13] [DEBUG] ALLOCATOR: Renaming temp /tmp/wazuh-qa/AWS-28F7B360-94CE-4E72-BCC2-A4601AF4871F directory to /tmp/wazuh-qa/i-08a1339f597510bd4
[2024-07-30 15:06:13] [INFO] ALLOCATOR [TEST-LOG-UBUNTU22]: Instance i-08a1339f597510bd4 created.
[2024-07-30 15:06:14] [INFO] ALLOCATOR [TEST-LOG-UBUNTU22]: Instance i-08a1339f597510bd4 started.
[2024-07-30 15:06:14] [INFO] ALLOCATOR [TEST-LOG-UBUNTU22]: The inventory file generated at /tmp/4-9-0/logs-tests-5614/inventory.yaml
[2024-07-30 15:06:14] [INFO] ALLOCATOR [TEST-LOG-UBUNTU22]: The track file generated at /tmp/4-9-0/logs-tests-5614/track.yaml
[2024-07-30 15:06:17] [WARNING] ALLOCATOR [TEST-LOG-UBUNTU22]: Error on attempt 1 of 30: [Errno None] Unable to connect to port 2200 on 34.227.59.35
[2024-07-30 15:06:47] [INFO] ALLOCATOR [TEST-LOG-UBUNTU22]: SSH connection successful.
[2024-07-30 15:06:47] [INFO] ALLOCATOR [TEST-LOG-UBUNTU22]: Instance i-08a1339f597510bd4 created successfully
  • With --composite-name
root@ip-172-31-47-84:/home/ubuntu/wazuh-qa/deployability# python3 modules/allocation/main.py --action create --provider aws --size micro --composite-name linux-ubuntu-22.04-amd64 --inventory-output "/tmp/4-9-0/logs-tests-5614/inventory.yaml" --track-output "/tmp/4-9-0/logs-tests-5614/track.yaml" --label-termination-date "1d" --label-team "devops"
[2024-07-30 14:21:59] [DEBUG] SPNEGO._GSS: Python gssapi not available, cannot use any GSSAPIProxy protocols: No module named 'gssapi'
[2024-07-30 14:21:59] [DEBUG] SPNEGO._GSS: Python gssapi IOV extension not available: No module named 'gssapi'
[2024-07-30 14:21:59] [INFO] ALLOCATOR: Creating instance at /tmp/wazuh-qa
[2024-07-30 14:22:01] [DEBUG] ALLOCATOR: No config provided. Generating from payload
[2024-07-30 14:22:01] [DEBUG] ALLOCATOR: Generating new key pair
[2024-07-30 14:22:01] [DEBUG] ALLOCATOR: Creating base directory: /tmp/wazuh-qa/AWS-503C1FAA-4CBF-4522-B1AF-7CABD15DBDEA
[2024-07-30 14:22:34] [DEBUG] ALLOCATOR: Renaming temp /tmp/wazuh-qa/AWS-503C1FAA-4CBF-4522-B1AF-7CABD15DBDEA directory to /tmp/wazuh-qa/i-0937cedffbaa4c8db
[2024-07-30 14:22:34] [INFO] ALLOCATOR [UBUNTU-22.04-AMD64]: Instance i-0937cedffbaa4c8db created.
[2024-07-30 14:22:35] [INFO] ALLOCATOR [UBUNTU-22.04-AMD64]: Instance i-0937cedffbaa4c8db started.
[2024-07-30 14:22:35] [INFO] ALLOCATOR [UBUNTU-22.04-AMD64]: The inventory file generated at /tmp/4-9-0/logs-tests-5614/inventory.yaml
[2024-07-30 14:22:35] [INFO] ALLOCATOR [UBUNTU-22.04-AMD64]: The track file generated at /tmp/4-9-0/logs-tests-5614/track.yaml
[2024-07-30 14:22:38] [WARNING] ALLOCATOR [UBUNTU-22.04-AMD64]: Error on attempt 1 of 30: [Errno None] Unable to connect to port 2200 on 3.89.38.8
[2024-07-30 14:23:08] [INFO] ALLOCATOR [UBUNTU-22.04-AMD64]: SSH connection successful.
[2024-07-30 14:23:08] [INFO] ALLOCATOR [UBUNTU-22.04-AMD64]: Instance i-0937cedffbaa4c8db created successfully.
Vagrant
$ python3 modules/allocation/main.py --action create --provider vagrant --size micro --composite-name linux-centos-7-amd64 --inventory-output  /tmp/4-9-0/linux-centos-7-vg/inventory.yaml --track-output  /tmp/4-9-0/linux-centos-7-vg/track.yaml --instance-name linux-centos-7-amd64
[2024-07-30 14:13:18] [DEBUG] SPNEGO._GSS: Python gssapi not available, cannot use any GSSAPIProxy protocols: No module named 'gssapi'
[2024-07-30 14:13:18] [DEBUG] SPNEGO._GSS: Python gssapi IOV extension not available: No module named 'gssapi'
[2024-07-30 14:13:18] [INFO] ALLOCATOR: Creating instance at /tmp/wazuh-qa
[2024-07-30 14:13:18] [DEBUG] ALLOCATOR: No config provided. Generating from payload
[2024-07-30 14:13:18] [DEBUG] ALLOCATOR: Generating new key pair
[2024-07-30 14:13:22] [DEBUG] ALLOCATOR: Vagrantfile created. Creating instance.
[2024-07-30 14:13:22] [INFO] ALLOCATOR: Instance linux-centos-7-amd64-1779 created.
[2024-07-30 14:15:58] [INFO] ALLOCATOR: Instance linux-centos-7-amd64-1779 started.
[2024-07-30 14:16:00] [INFO] ALLOCATOR: The inventory file generated at /tmp/4-9-0/linux-centos-7-vg/inventory.yaml
[2024-07-30 14:16:00] [INFO] ALLOCATOR: The track file generated at /tmp/4-9-0/linux-centos-7-vg/track.yaml
[2024-07-30 14:16:00] [INFO] ALLOCATOR: SSH connection successful.
[2024-07-30 14:16:00] [INFO] ALLOCATOR: Instance linux-centos-7-amd64-1779 created successfully.

As shown, the logs with vagrant are not modified.

  • Delete instance
AWS
root@ip-172-31-47-84:/home/ubuntu/wazuh-qa/deployability# python3 modules/allocation/main.py --action delete --track-output "/tmp/4-9-0/logs-tests-5614/track.yaml"
[2024-07-30 12:35:39] [DEBUG] SPNEGO._GSS: Python gssapi not available, cannot use any GSSAPIProxy protocols: No module named 'gssapi'
[2024-07-30 12:35:39] [DEBUG] SPNEGO._GSS: Python gssapi IOV extension not available: No module named 'gssapi'
[2024-07-30 12:35:39] [INFO] ALLOCATOR: Deleting instance from trackfile /tmp/4-9-0/logs-tests-5614/track.yaml
[2024-07-30 12:35:40] [DEBUG] ALLOCATOR: Deleting credentials: qa-5614-ubuntu-22.04-key-8181
[2024-07-30 12:36:26] [INFO] ALLOCATOR [QA-5614-UBUNTU-22.04]: Instance i-02de975e0d07f8b70 deleted.
Vagrant
$ python3 modules/allocation/main.py --action delete --track-output  "/tmp/4-9-0/linux-centos-7-vg/track.yaml"
[2024-07-30 14:32:16] [DEBUG] SPNEGO._GSS: Python gssapi not available, cannot use any GSSAPIProxy protocols: No module named 'gssapi'
[2024-07-30 14:32:16] [DEBUG] SPNEGO._GSS: Python gssapi IOV extension not available: No module named 'gssapi'
[2024-07-30 14:32:16] [INFO] ALLOCATOR: Deleting instance from trackfile /tmp/4-9-0/linux-centos-7-vg/track.yaml
[2024-07-30 14:32:16] [DEBUG] ALLOCATOR: Destroying instance linux-centos-7-amd64-1779
[2024-07-30 14:32:20] [INFO] ALLOCATOR: Instance linux-centos-7-amd64-1779 deleted.

@Enaraque Enaraque requested a review from a team July 30, 2024 15:12
@Enaraque Enaraque self-assigned this Jul 30, 2024
@Enaraque Enaraque linked an issue Jul 30, 2024 that may be closed by this pull request
Copy link
Member

@c-bordon c-bordon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@juliamagan juliamagan merged commit 545730d into 4.9.0 Jul 31, 2024
@juliamagan juliamagan deleted the change/5614-change-allocator-logs-to-reference-tasks-instead-of-generic-values branch July 31, 2024 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change Allocator logs to reference tasks instead of generic values
3 participants