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

feat: include crypto diagnostics in /debug/vars output #23948

Merged
merged 5 commits into from Dec 6, 2022

Conversation

gwossum
Copy link
Member

@gwossum gwossum commented Nov 23, 2022

Pulls crypto diagnostics and includes them in /debug/vars output. If no crypto diagnostics are available, then OSS crypto information will be shown instead.

closes: #23947

Context

Added to enhance supportability of Enterprise releases.

Affected areas (delete section if not relevant):

Extra crypto section is now included in /debug/vars

Severity (delete section if not relevant)

This is blocking the Enterprise FIPS release.

Note for reviewers:

Check the semantic commit type:

  • Feat: a feature with user-visible changes
  • Fix: a bug fix that we might tell a user “upgrade to get this fix for your issue”
  • Chore: version bumps, internal doc (e.g. README) changes, code comment updates, code formatting fixes… must not be user facing (except dependency version changes)
  • Build: build script changes, CI config changes, build tool updates
  • Refactor: non-user-visible refactoring
  • Check the PR title: we should be able to put this as a one-liner in the release notes

Pulls `crypto` diagnostics and includes them in `/debug/vars` output.
If no `crypto` diagnostics are available, then OSS crypto information will
be shown instead.

closes: #23947
@gwossum
Copy link
Member Author

gwossum commented Nov 23, 2022

See https://github.com/influxdata/plutonium/issues/3967 for more context.

@gwossum gwossum marked this pull request as ready for review December 5, 2022 17:30
Copy link
Contributor

@davidby-influx davidby-influx left a comment

Choose a reason for hiding this comment

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

We should check errors writing the diagnostics, but probably just log them locally if we have a logger handy

Copy link
Contributor

@davidby-influx davidby-influx left a comment

Choose a reason for hiding this comment

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

A few minor things. Apologies for my pickiness.

}

if !first {
fmt.Fprintln(w, ",")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm still in favor of an h.Logger.Error(err) if Fprintln fails here.

fmt.Fprintln(w, ",")
}
first = false
fmt.Fprintf(w, "\"crypto\": %s", data)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same, let's log Fprintf errors, as unlikely as they may be.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll go a step further and say the fact there are fmt.Printf calls to check when generating JSON is problematic. I don't understand why we don't build the sections into a map[string]interface{} and then serialize that. There's a lot more fmt.Printf's in there than just the ones I added.

Copy link
Contributor

Choose a reason for hiding this comment

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

Absolutely agree. But I didn't want to generate more work for you rewriting everything.

first = false
fmt.Fprintf(w, "\"crypto\": %s", data)
}

if val := expvar.Get("memstats"); val != nil {
if !first {
fmt.Fprintln(w, ",")
Copy link
Contributor

Choose a reason for hiding this comment

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

Same, let's log Fprintln errors.

exp := map[string]interface{}{
"crypto": map[string]interface{}{
"FIPS": true,
"ensureFIPS": nil,
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you want to omit this entirely, rather than having a nil entry?

Copy link
Member Author

Choose a reason for hiding this comment

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

The nil is intentional. Here's my reasoning:

Assumptions:

  • Seeing nil values means enterprise was not updated to generate the appropriate diagnostic values.
  • You should not see nil in release versions, because enterprise and OSS agree on the appropriate attributes.
  • Incomplete data is better than no data, as long as there's no misleading data.

Option 1: If enterprise doesn't provide an attribute value, GET /debug/vars will return a 500. This is what other sections like build do.
I don't like this option because OSS regression tests will pass, but enterprise currently has no tests for /debug/vars. Hopefully we'd catch this, but maybe not. We might have a situation where a customer can't pull /debug/vars, even though it has lots of other useful info.

Option 2: Leave the field out if enterprise doesn't set it.
Let's say in the future we add PAM support, and add PAMEnabled and PAMModules to OSS, but enterprise hasn't been updated yet. If we see /debug/vars without PAMEnabled and PAMModules, is that because the version is too old to have those fields, or does enterprise have a bug and isn't passing them through. If we see those fields as nil, we know something is wrong. This also applies to automated tests. If we forget to add fields to enterprise and hide them, our automated tests still pass so we don't realize we need to add something to enterprise.

Option 3: Missing fields are given a nil value.
Looks wrong because it is wrong, so a human will flag it when they see it. Once we add automated tests to enterprise, these tests will fail when suddenly there's a new field that enterprise doesn't set. Either way, hopefully we really would catch it during development time instead of RC or even release time.

Copy link
Contributor

@davidby-influx davidby-influx left a comment

Choose a reason for hiding this comment

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

LGTM

@gwossum gwossum merged commit ac35088 into master-1.x Dec 6, 2022
@jacobmarble jacobmarble deleted the gw_crypto_debug_vars branch January 2, 2024 22:48
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.

None yet

3 participants