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

SLS-3042: Respect DD_PROXY_HTTP/DD_PROXY_HTTPS for secrets manager and KMS clients #15574

Merged
merged 1 commit into from
Feb 14, 2023

Conversation

IvanTopolcic
Copy link
Contributor

@IvanTopolcic IvanTopolcic commented Feb 13, 2023

What does this PR do?

This PR makes the secrets manager and KMS decrypt functions in Serverless respect using DD_PROXY_HTTP(S) values. If those are set, it'll try to retrieve the secrets / the key via the proxy instead of a bare connection.

Motivation

Additional Notes

Possible Drawbacks / Trade-offs

Describe how to test/QA your changes

Reviewer's Checklist

  • If known, an appropriate milestone has been selected; otherwise the Triage milestone is set.
  • Use the major_change label if your change either has a major impact on the code base, is impacting multiple teams or is changing important well-established internals of the Agent. This label will be use during QA to make sure each team pay extra attention to the changed behavior. For any customer facing change use a releasenote.
  • A release note has been added or the changelog/no-changelog label has been applied.
  • Changed code has automated tests for its functionality.
  • Adequate QA/testing plan information is provided if the qa/skip-qa label is not applied.
  • At least one team/.. label has been applied, indicating the team(s) that should QA this change.
  • If applicable, docs team has been notified or an issue has been opened on the documentation repo.
  • If applicable, the need-change/operator and need-change/helm labels have been applied.
  • If applicable, the k8s/<min-version> label, indicating the lowest Kubernetes version compatible with this feature.
  • If applicable, the config template has been updated.

@IvanTopolcic IvanTopolcic requested a review from a team as a code owner February 13, 2023 19:45
@IvanTopolcic IvanTopolcic marked this pull request as draft February 13, 2023 19:45
@IvanTopolcic IvanTopolcic changed the base branch from main to ivan.topolcic/fix-aws-lambda-secrets-manager-crashes February 13, 2023 19:46
@IvanTopolcic IvanTopolcic changed the base branch from ivan.topolcic/fix-aws-lambda-secrets-manager-crashes to main February 13, 2023 19:46
Comment on lines +82 to +84
sess, err := session.NewSession(aws.NewConfig().WithHTTPClient(&http.Client{
Transport: datadogHttp.CreateHTTPTransport(),
}))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Difficult to add tests, and CreateHTTPTransport is already tested so I believe it would be redundant.

Comment on lines +109 to +111
sess, err := session.NewSession(aws.NewConfig().WithHTTPClient(&http.Client{
Transport: datadogHttp.CreateHTTPTransport(),
}))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Difficult to add tests, and CreateHTTPTransport is already tested so I believe it would be redundant.

@IvanTopolcic IvanTopolcic added this to the Triage milestone Feb 14, 2023
@IvanTopolcic IvanTopolcic added changelog/no-changelog [deprecated] qa/skip-qa - use other qa/ labels [DEPRECATED] Please use qa/done or qa/no-code-change to skip creating a QA card team/serverless labels Feb 14, 2023
@IvanTopolcic IvanTopolcic force-pushed the ivan.topolcic/secrets-manager-use-proxy branch from 33ab2e2 to f9380c6 Compare February 14, 2023 16:21
@IvanTopolcic IvanTopolcic marked this pull request as ready for review February 14, 2023 16:21
@@ -183,14 +185,13 @@ func runAgent(stopCh chan struct{}) (serverlessDaemon *daemon.Daemon, err error)
// execution to be stopped. TODO(remy): discuss with AWS if there is way
// of reporting non-critical init errors.
// serverless.ReportInitError(serverlessID, serverless.FatalNoAPIKey)
log.Error("No API key configured, exiting")
log.Error("No API key configured")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I figured this makes more sense, as we never actually exit

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we should exit(1) as there is no point of wasting cpu/memory?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we need to keep the extension running or else a process exit will cause the customer's function to crash. We could in theory refactor to accomplish this but I think we can probably worry about this later

Copy link
Contributor

@maxday maxday left a comment

Choose a reason for hiding this comment

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

🚀

@IvanTopolcic IvanTopolcic merged commit 1055fca into main Feb 14, 2023
@IvanTopolcic IvanTopolcic deleted the ivan.topolcic/secrets-manager-use-proxy branch February 14, 2023 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/no-changelog [deprecated] qa/skip-qa - use other qa/ labels [DEPRECATED] Please use qa/done or qa/no-code-change to skip creating a QA card team/serverless
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants