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 cleanup for Windows env vars #694

Merged
merged 4 commits into from
Feb 27, 2020

Conversation

julien-lebot
Copy link
Contributor

When the windows_package[Datadog Agent] fails, it does not cleanup the environment variables containing the credentials for the installer.
This PR aims to fix that by setting a hanlder that runs after the recipe.

Comment on lines 145 to 151
windows_env 'DDAGENTUSER_NAME' do
action :delete
end

windows_env 'DDAGENTUSER_PASSWORD' do
action :delete
end
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can still keep these deletes, so the env vars are cleaned earlier than at run_completed or run_failed.

Eg: if a run takes long and you kill it, on_failed might not get called, so it's better to delete the env vars earlier when we know we don't need them anymore.

Comment on lines 6 to 13
def do_cleanup(context)
Chef::Log.info 'Cleanup started.'
resource = context.resource_collection.lookup("windows_env[DDAGENTUSER_NAME]")
resource.run_action(:delete) if resource
resource = context.resource_collection.lookup("windows_env[DDAGENTUSER_PASSWORD]")
resource.run_action(:delete) if resource
Chef::Log.info 'Cleanup finished.'
end
Copy link
Contributor

Choose a reason for hiding this comment

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

I would go for compact code and keep this helper function in recipes/_install-windows.rb instead of having several small files, but no strong opinion in case you prefer it this way.

@julien-lebot julien-lebot merged commit fa40d3d into master Feb 27, 2020
kbogtob added a commit that referenced this pull request Mar 3, 2020
…ials_leak"

This reverts commit fa40d3d, reversing
changes made to 018ff8b.
kbogtob added a commit that referenced this pull request Mar 3, 2020
* Revert "Merge pull request #694 from DataDog/julien.lebot/fix_credentials_leak"

This reverts commit fa40d3d, reversing
changes made to 018ff8b.

* Revert "Set windows installer as sensitive resource and use env var to specify win credentials (#691)"

This reverts commit 07d3a62.

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

Successfully merging this pull request may close these issues.

2 participants