-
Notifications
You must be signed in to change notification settings - Fork 148
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 skip audit/unenroll flag to uninstall command #6206
base: main
Are you sure you want to change the base?
Conversation
This pull request does not have a backport label. Could you fix it @Rohit-code14? 🙏
|
|
/test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Rohit-code14 Could you please add tests relevant to what you are doing here? One suggestion is to inject notifyFleetAuditUninstall
function. You can create a function type and create a mock with it using mockery which you can use in your test.
Hi @kaanyalti , Even if we inject notifyFleetAuditUninstall into Uninstall and try mocking the same to test it. To test it we need to directly invoke Uninstall function by passing the mock notify function during the test run. Which is not hard to do. I think we can refactor the pre-validations that are done to before invoking notifyFleetAuditUninstall function into a separate function and have a test case that mocks the new refactored function.
Please share your opinion on this |
@Rohit-code14 I am having a hard time visualizing your suggestion based on the example you provided. Can you either implement your suggestion or provide a more concrete example so it is clearer? |
@kaanyalti I have added changes and testcase, kindly review the same. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested this on mac and linux, works well. Changes look good to me.
/test |
Hi @kaanyalti , I cannot see the reasons for these failures, Can you please help me with this? |
Hey @Rohit-code14 this is the failure 🙂
|
Hey, I don't think its due to my changes. What should i do now🤔 |
I don’t believe this is caused by your changes either, but let me double-check with the team and get back to you. 🙂 |
Thanks! |
It's acceptable to merge / rebase |
@Rohit-code14 Could you please resolve the merge conflicts? |
Done! |
/test |
Quality Gate failedFailed conditions |
Should anything be done from my side for this? |
@Rohit-code14 I'm going to look into why sonarqube is complaining, you may have to increase code coverage, although right now what you have implemented looks good to me. |
Okay let me know once you have checked the it. |
What does this PR do?
Added a flag to skip fleet audit/unenroll while uninstalling elastic-agent.
Why is it important?
While uninstalling elastic-agent it tries to notify fleet server about the uninstall. But in somecases users might know that the fleet server is unreachable and this notification logs multiple failures continuously. Therefore having an option to skip this would enhance the end user experience.
Checklist
[ ] I have made corresponding change to the default configuration files./changelog/fragments
using the changelog tool[ ] I have added an integration test or an E2E testDisruptive User Impact
No disruptive user impact
How to test this PR locally
SNAPSHOT=true PLATFORMS=linux/arm64 PACKAGES=tar.gz mage -v package
sudo elastic-agent uninstall
[== ] notify Fleet: network error: fail to notify audit/unenroll on fleet-server: all hosts failed: requester 0/1 to host https://192.168.1.10:8220/ errored: Post "https://192.168.1.10:8220/api/fleet/agents/a4888371-ef7b-4cc6-8df7-cc92b6c25990/audit/unenroll?": dial tcp 192.168.1.10:8220: connect:
sudo elastic-agent uninstall --skip-fleet-audit
. The audit/unenroll call will be skipped and agent uninstall will happen without any errors.Related issues