DataDog / ansible-datadog

Ansible role for Datadog Agent
Apache License 2.0
298 stars 222 forks source link

Datadog Agent Disable Fails on Windows Due to Win Process Dependency Order #328

Open erikhjensen opened 3 years ago

erikhjensen commented 3 years ago

https://github.com/DataDog/ansible-datadog/blob/949bdb7668b4eb14c23467ab3465957c9b174583/tasks/agent-win.yml#L65

Conditions: Server had Trace Agent and DD Agent. Set datadog_enabled to false.

Issue: List given to the stop task should be re ordered (in the reverse order for example) to stop trace and process before the DD agent otherwise the following error is received.

Error Message: failed: [SERVERNAME.DOMAIN.EXT] (item=datadogagent) => {"ansible_loop_var": "item", "can_pause_and_continue": false, "changed": false, "depended_by": ["datadog-process-agent", "datadog-trace-agent"], "dependencies": [], "description": "Send metrics to Datadog", "desktop_interact": false, "display_name": "Datadog Agent", "exists": true, "item": "datadogagent", "msg": "Cannot stop service 'Datadog Agent (datadogagent)' because it has dependent services. It can only be stopped if the Force flag is set.", "name": "datadogagent", "path": "\"C:\Program Files\Datadog\Datadog Agent\bin\agent.exe\"", "start_mode": "auto", "state": "running", "username": ".\ddagentuser"}

erikhjensen commented 3 years ago

Additionally, it seems that this task just sets the state of the agent to stopped. As such, it isn't so much "disable" as the opposite of "datadog_enabled" would suggest. The agent would start once again after a reboot.

erikhjensen commented 3 years ago

I would like to push a branch for my testing and later consideration for PR. it seems this is not possible due to the current permissions model. What kind of workflow would you recommend? While I can push a copy of the source code to our own organization I see there are some contributors to issues within your org, lmk if this is open to your customers.

KSerrania commented 3 years ago

Hey @erikhjensen,

Thanks for reporting this issue! Indeed, we should either change the order of services (to stop the datadogagent service last), or pass the Force flag to stop the services.

The workflow to propose changes is to create a fork of this repository (under your own name or the organization of your choice), make & test the changes there and then open a PR against our repository.

erikhjensen commented 3 years ago

Noted. Will do so.

Erik

Get Outlook for iOShttps://aka.ms/o0ukef


From: Kylian Serrania @.> Sent: Tuesday, March 16, 2021 5:37:42 AM To: DataDog/ansible-datadog @.> Cc: Jensen, Erik @.>; Mention @.> Subject: Re: [DataDog/ansible-datadog] Datadog Agent Disable Fails on Windows Due to Win Process Dependency Order (#328)

Hey @erikhjensenhttps://github.com/erikhjensen,

Thanks for reporting this issue! Indeed, we should either change the order of services (to stop the datadogagent service last), or pass the Force flag to stop the services.

The workflow to propose changes is to create a fork of this repository (under your own name or the organization of your choice), make & test the changes there and then open a PR against our repository.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/DataDog/ansible-datadog/issues/328#issuecomment-800184746, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AID7KRE5A63NILSNOMDC6FLTD47INANCNFSM4ZGXDGYA.



If you wish to no longer receive electronic messages from this sender, please respond and advise accordingly in your return email.

This email and its contents are private and confidential, for the sole use of the addressees. If you are not an intended recipient, copying, forwarding or other distribution of this email or its contents by any means is prohibited. If you believe that you received this email in error please notify the original sender and delete this communication and any copies immediately.

Petro-Canada is a Suncor Energy business.

150 – 6th Avenue S.W., Calgary, Alberta, Canada, T2P 3E3 (Corporate Head Office) / www.suncor.com


Si vous ne voulez plus recevoir de messages électroniques de cet expéditeur, veuillez l’en aviser en répondant à ce courriel.

Ce courriel et son contenu sont privés et confidentiels, et sont destinés à l’usage exclusif des destinataires. Si vous n'êtes pas le destinataire prévu, toute reproduction, transfert ou autre forme de diffusion de ce courriel ou de son contenu par quelque moyen que ce soit est interdit. Si vous croyez avoir reçu ce courriel par erreur, veuillez en aviser l’expéditeur original et supprimer cette communication et toutes ses copies immédiatement.

Petro-Canada est une entreprise de Suncor Énergie.

150 – 6th Avenue S.W., Calgary, Alberta, Canada, T2P 3E3 (siège social) / www.suncor.com

serhiichernukha commented 1 year ago

Facing the same issue. Is there any update on this one? image

serhiichernukha commented 1 year ago

The following worked for me: added sysprobe service to the loop because it's dependent on datadogagent service:

with_list:
    - datadog-trace-agent
    - datadog-process-agent
    - datadog-system-probe
    - datadogagent

image

image

To leverage this hack as a fix, it must be augmented with additional updates to the role. For example, datadog-system-probe service must be added to these kinds of tasks to manage it in the same way: image

Alternatively, the same can be achieved by simply adding force_dependent_services: true