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

Stopping agents ungracefully feature #72

Merged
merged 7 commits into from
Nov 22, 2023

Conversation

pro-akim
Copy link
Member

Related Issue
#61

Description

This PR includes additional parameters for stop_agent and stop_agents, making possible to stop them ungracefully

Evidences

Running:

  1. wh.stop_agent("agent1", type='gracefully')

  2. wh.stop_agent("agent1", type='ungracefully')

  3. wh.stop_agents(["agent1", "agent2"], type='gracefully', parallel=True)

  4. wh.stop_agents(["agent1", "agent2"], type='ungracefully', parallel=True)

  5. wh.stop_agents(["agent1", "agent2"], type='gracefully', parallel=False)

  6. wh.stop_agents(["agent1", "agent2"], type='ungracefully', parallel=False)

Results:

  1. agent1 stopped gracefully

  2. agent1 stopped ungracefully

  3. agent1 and agent2 stopped gracefully

  4. agent1 and agent2 stopped ungracefully

  5. agent1 and agent2 stopped gracefully one by one

  6. agent1 and agent2 stopped ungracefully one by one

@pro-akim pro-akim self-assigned this Jun 28, 2023
@pro-akim pro-akim linked an issue Jun 28, 2023 that may be closed by this pull request
@BelenValdivia
Copy link

@pro-akim Check the failing unit tests

@pro-akim
Copy link
Member Author

pro-akim commented Jul 5, 2023

05/07/2023

Checks were done before the PR, however, it will be tested one more time when the pipeline is back. It will remain on on-hold status.

@pro-akim
Copy link
Member Author

pro-akim commented Jul 6, 2023

Evidences

Running:

  1. wh.stop_agent("agent1", type='gracefully')

  2. wh.stop_agent("agent1", type='ungracefully')

  3. wh.stop_agents(["agent1", "agent2"], type='gracefully', parallel=True)

  4. wh.stop_agents(["agent1", "agent2"], type='ungracefully', parallel=True)

  5. wh.stop_agents(["agent1", "agent2"], type='gracefully', parallel=False)

  6. wh.stop_agents(["agent1", "agent2"], type='ungracefully', parallel=False)

Results:

Wazuh agent_control. List of available agents:
   ID: 000, Name: ip-172-31-14-219.ec2.internal (server), IP: 127.0.0.1, Active/Local
   ID: 001, Name: ip-172-31-4-68, IP: any, Disconnected
   ID: 002, Name: EC2AMAZ-2BV3AJS, IP: any, Active
Wazuh agent_control. List of available agents:
   ID: 000, Name: ip-172-31-14-219.ec2.internal (server), IP: 127.0.0.1, Active/Local
   ID: 001, Name: ip-172-31-4-68, IP: any, Disconnected
   ID: 002, Name: EC2AMAZ-2BV3AJS, IP: any, Active
Wazuh agent_control. List of available agents:
   ID: 000, Name: ip-172-31-6-43 (server), IP: 127.0.0.1, Active/Local
   ID: 001, Name: ip-172-31-2-206, IP: any, Disconnected
   ID: 002, Name: EC2AMAZ-2BV3AJS, IP: any, Disconnected
Wazuh agent_control. List of available agents:
   ID: 000, Name: ip-172-31-6-43 (server), IP: 127.0.0.1, Active/Local
   ID: 001, Name: ip-172-31-2-206, IP: any, Disconnected
   ID: 002, Name: EC2AMAZ-2BV3AJS, IP: any, Disconnected

Stopped one by one

Wazuh agent_control. List of available agents:
   ID: 000, Name: ip-172-31-6-43 (server), IP: 127.0.0.1, Active/Local
   ID: 001, Name: ip-172-31-2-206, IP: any, Disconnected
   ID: 002, Name: EC2AMAZ-2BV3AJS, IP: any, Disconnected

Stopped one by one

Wazuh agent_control. List of available agents:
   ID: 000, Name: ip-172-31-6-43 (server), IP: 127.0.0.1, Active/Local
   ID: 001, Name: ip-172-31-2-206, IP: any, Disconnected
   ID: 002, Name: EC2AMAZ-2BV3AJS, IP: any, Disconnected

Unit tests seem to be ok

@pro-akim pro-akim requested review from Rebits and juliamagan and removed request for Rebits July 6, 2023 16:49
@BelenValdivia
Copy link

PR checks still failing
image

@pro-akim
Copy link
Member Author

pro-akim commented Jul 11, 2023

11/07/2023

Automatically triggered unit tests detect failures in code that was not modified by this issue.
It will be researched.

@pro-akim pro-akim marked this pull request as draft July 11, 2023 08:18
@pro-akim pro-akim marked this pull request as ready for review July 11, 2023 13:37
@pro-akim pro-akim marked this pull request as draft July 11, 2023 13:37
@pro-akim
Copy link
Member Author

11/07/2023

The status code was 403 (certificate problems).
After a new run, unit tests have passed successfully.

@pro-akim pro-akim marked this pull request as ready for review July 11, 2023 13:42
src/wazuh_qa_framework/system/wazuh_handler.py Outdated Show resolved Hide resolved
src/wazuh_qa_framework/system/wazuh_handler.py Outdated Show resolved Hide resolved
src/wazuh_qa_framework/system/wazuh_handler.py Outdated Show resolved Hide resolved
src/wazuh_qa_framework/system/wazuh_handler.py Outdated Show resolved Hide resolved
src/wazuh_qa_framework/system/wazuh_handler.py Outdated Show resolved Hide resolved
src/wazuh_qa_framework/system/wazuh_handler.py Outdated Show resolved Hide resolved
src/wazuh_qa_framework/system/wazuh_handler.py Outdated Show resolved Hide resolved
src/wazuh_qa_framework/system/wazuh_handler.py Outdated Show resolved Hide resolved
src/wazuh_qa_framework/system/wazuh_handler.py Outdated Show resolved Hide resolved
@pro-akim
Copy link
Member Author

pro-akim commented Jul 13, 2023

Evidences

Running:

  1. wh.stop_agent("agent1", gracefully=True)

  2. wh.stop_agent("agent1", gracefully=False)

  3. wh.stop_agents(["agent1", "agent2"], gracefully=True , parallel=True)

  4. wh.stop_agents(["agent1", "agent2"], gracefully=False, parallel=True)

  5. wh.stop_agents(["agent1", "agent2"], gracefully=True, parallel=False)

  6. wh.stop_agents(["agent1", "agent2"], gracefully=False, parallel=False)

Results:

Wazuh agent_control. List of available agents:
   ID: 000, Name: ip-172-31-0-95 (server), IP: 127.0.0.1, Active/Local
   ID: 001, Name: ip-172-31-6-8, IP: any, Disconnected
   ID: 002, Name: EC2AMAZ-2BV3AJS, IP: any, Active

Wazuh agent_control. List of available agents:
   ID: 000, Name: ip-172-31-0-95 (server), IP: 127.0.0.1, Active/Local
   ID: 001, Name: ip-172-31-6-8, IP: any, Disconnected
   ID: 002, Name: EC2AMAZ-2BV3AJS, IP: any, Active
Wazuh agent_control. List of available agents:
   ID: 000, Name: ip-172-31-0-95 (server), IP: 127.0.0.1, Active/Local
   ID: 001, Name: ip-172-31-6-8, IP: any, Disconnected
   ID: 002, Name: EC2AMAZ-2BV3AJS, IP: any, Disconnected
Wazuh agent_control. List of available agents:
   ID: 000, Name: ip-172-31-0-95 (server), IP: 127.0.0.1, Active/Local
   ID: 001, Name: ip-172-31-6-8, IP: any, Disconnected
   ID: 002, Name: EC2AMAZ-2BV3AJS, IP: any, Disconnected

Stopped one by one

Wazuh agent_control. List of available agents:
   ID: 000, Name: ip-172-31-0-95 (server), IP: 127.0.0.1, Active/Local
   ID: 001, Name: ip-172-31-6-8, IP: any, Disconnected
   ID: 002, Name: EC2AMAZ-2BV3AJS, IP: any, Disconnected

Stopped one by one

Wazuh agent_control. List of available agents:
   ID: 000, Name: ip-172-31-0-95 (server), IP: 127.0.0.1, Active/Local
   ID: 001, Name: ip-172-31-6-8, IP: any, Disconnected
   ID: 002, Name: EC2AMAZ-2BV3AJS, IP: any, Disconnected

Unit tests seem to be ok

src/wazuh_qa_framework/system/wazuh_handler.py Outdated Show resolved Hide resolved
src/wazuh_qa_framework/system/wazuh_handler.py Outdated Show resolved Hide resolved
src/wazuh_qa_framework/system/wazuh_handler.py Outdated Show resolved Hide resolved
src/wazuh_qa_framework/system/wazuh_handler.py Outdated Show resolved Hide resolved
@pro-akim pro-akim requested a review from Rebits July 28, 2023 09:11
@pro-akim
Copy link
Member Author

Update

Changes done.
Ready to be reviewed.

@pro-akim pro-akim marked this pull request as draft November 15, 2023 15:03
@pro-akim pro-akim marked this pull request as ready for review November 15, 2023 15:04
Copy link
Member

@Rebits Rebits left a comment

Choose a reason for hiding this comment

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

Some minor final changes are requested

src/wazuh_qa_framework/system/host_manager.py Outdated Show resolved Hide resolved
src/wazuh_qa_framework/system/wazuh_handler.py Outdated Show resolved Hide resolved
src/wazuh_qa_framework/system/wazuh_handler.py Outdated Show resolved Hide resolved
@pro-akim
Copy link
Member Author

Update

Tested and fixed:

Evidences

Running:

  1. wh.stop_agent("agent1", gracefully=True)

  2. wh.stop_agent("agent1", gracefully=False)

  3. wh.stop_agents(["agent1", "agent2"], gracefully=True , parallel=True)

  4. wh.stop_agents(["agent1", "agent2"], gracefully=False, parallel=True)

  5. wh.stop_agents(["agent1", "agent2"], gracefully=True, parallel=False)

  6. wh.stop_agents(["agent1", "agent2"], gracefully=False, parallel=False)

Results:

Wazuh agent_control. List of available agents:
   ID: 000, Name: ip-172-31-9-178 (server), IP: 127.0.0.1, Active/Local
   ID: 001, Name: ip-172-31-3-59, IP: any, Disconnected
   ID: 002, Name: DESKTOP-AQ2R8SM, IP: any, Active

Wazuh agent_control. List of available agents:
   ID: 000, Name: ip-172-31-9-178 (server), IP: 127.0.0.1, Active/Local
   ID: 001, Name: ip-172-31-3-59, IP: any, Disconnected
   ID: 002, Name: DESKTOP-AQ2R8SM, IP: any, Active
Wazuh agent_control. List of available agents:
   ID: 000, Name: ip-172-31-9-178 (server), IP: 127.0.0.1, Active/Local
   ID: 001, Name: ip-172-31-3-59, IP: any, Disconnected
   ID: 002, Name: DESKTOP-AQ2R8SM, IP: any, Disconnected
Wazuh agent_control. List of available agents:
   ID: 000, Name: ip-172-31-9-178 (server), IP: 127.0.0.1, Active/Local
   ID: 001, Name: ip-172-31-3-59, IP: any, Disconnected
   ID: 002, Name: DESKTOP-AQ2R8SM, IP: any, Disconnected

Stopped one by one

Wazuh agent_control. List of available agents:
   ID: 000, Name: ip-172-31-9-178 (server), IP: 127.0.0.1, Active/Local
   ID: 001, Name: ip-172-31-3-59, IP: any, Disconnected
   ID: 002, Name: DESKTOP-AQ2R8SM, IP: any, Disconnected

Stopped one by one

Wazuh agent_control. List of available agents:
   ID: 000, Name: ip-172-31-9-178 (server), IP: 127.0.0.1, Active/Local
   ID: 001, Name: ip-172-31-3-59, IP: any, Disconnected
   ID: 002, Name: DESKTOP-AQ2R8SM, IP: any, Disconnected

Unit tests seem to be ok

@pro-akim pro-akim requested a review from Rebits November 16, 2023 17:52
src/wazuh_qa_framework/system/wazuh_handler.py Outdated Show resolved Hide resolved
src/wazuh_qa_framework/system/host_manager.py Outdated Show resolved Hide resolved
@pro-akim pro-akim requested a review from Rebits November 22, 2023 10:54
Copy link
Member

@Rebits Rebits left a comment

Choose a reason for hiding this comment

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

LGTM

@davidjiglesias davidjiglesias merged commit 340bd6d into system-refactor Nov 22, 2023
3 checks passed
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.

Wazuh Handler: Stop agent/s ungracefully
5 participants