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

Fix: Check for missing client config in secure socks proxy check #1179

Merged
merged 5 commits into from
Jan 8, 2025

Conversation

kevinwcyu
Copy link
Contributor

What this PR does / why we need it:

When I was adding PDC support for some AWS data sources, it didn't look like p.opts was ever nil when checking whether the secure socks proxy should be enabled. It looks like it's always set, at least for the path that our data sources goes through.

This PR checks for the presence of a clientCfg in addition to checking if the proxy options are available as the clientCfg doesn't get set if secure socks proxy is not enabled in Grafana.

I was running into an edge case where I enabled the secure socks proxy in my custom.ini as described here, then enabled the secure socks proxy for my data source, then disabled the secure socks proxy in my custom.ini again. Since the data source still had the secure socks proxy setting enabled, I was hitting this error because p.opts was never nil and the data source's settings still had the secure socks proxy setting enabled.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

@kevinwcyu kevinwcyu requested a review from a team as a code owner December 20, 2024 22:09
@kevinwcyu kevinwcyu requested review from wbrowne, andresmgot and oshirohugo and removed request for a team December 20, 2024 22:09
kevinwcyu and others added 3 commits January 6, 2025 10:16
Copy link
Member

@wbrowne wbrowne left a comment

Choose a reason for hiding this comment

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

LGTM other than comment

Copy link
Member

@wbrowne wbrowne left a comment

Choose a reason for hiding this comment

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

Thanks a lot @kevinwcyu! Feel free to merge as I will cut a release of the SDK soon 😄

// it cannot be enabled if it's not enabled on Grafana
if p.opts == nil {
// the secure proxy can only be used if it's enabled on both the datasource connection and the client (Grafana server)
if p.opts == nil || !p.opts.Enabled || p.opts.ClientCfg == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: you can now change the line 91 to simply return true. Also, I'd move extra comment to the function comment (so it's more discoverable that ClientCfg is also checked)

@kevinwcyu kevinwcyu merged commit 5364a9d into main Jan 8, 2025
3 checks passed
@kevinwcyu kevinwcyu deleted the kevinwcyu/fix-secure-socks-proxy-enabled-check branch January 8, 2025 15:07
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.

3 participants