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

Revert default config #2822

Merged
merged 2 commits into from
Mar 27, 2024
Merged

Conversation

eleftherias
Copy link
Contributor

@eleftherias eleftherias commented Mar 27, 2024

Summary

Revert the change which takes into account the {} default value in a config field.
We were running into an issue where the SQL port was defaulted to 0, rather than the expected 5432 value.
https://github.com/stacklok/minder/blob/6186d553c6bb6eb83aedd9679bdb2b744ad7ddb8/internal/config/common.go#L38

Change Type

Mark the type of change your PR introduces:

  • Bug fix (resolves an issue without affecting existing features)
  • Feature (adds new functionality without breaking changes)
  • Breaking change (may impact existing functionalities or require documentation updates)
  • Documentation (updates or additions to documentation)
  • Refactoring or test improvements (no bug fixes or new functionality)

Testing

Outline how the changes were tested, including steps to reproduce and any relevant configurations.
Attach screenshots if helpful.

Review Checklist:

  • Reviewed my own code for quality and clarity.
  • Added comments to complex or tricky code sections.
  • Updated any affected documentation.
  • Included tests that validate the fix or feature.
  • Checked that related changes are merged.

@eleftherias eleftherias requested a review from a team as a code owner March 27, 2024 10:31
@coveralls
Copy link

Coverage Status

coverage: 47.698% (-0.004%) from 47.702%
when pulling c70bf93 on eleftherias:revert-default-config
into f31c850 on stacklok:main.

@eleftherias eleftherias merged commit 6186d55 into mindersec:main Mar 27, 2024
22 checks passed
@eleftherias eleftherias deleted the revert-default-config branch March 27, 2024 10:43
@Vyom-Yadav
Copy link
Collaborator

I get that this was done to maybe fix production immediately. But isn't the logically correct thing to remove default:"{}" from wherever it was causing an issue? https://github.com/stacklok/minder/blob/66179b892f89e053aa0766916b03f5088e686b5f/internal/config/server/events.go#L47-L51

What's the point of having default:"{}" if it's not honoured? That's just leaving a bug in.

@evankanderson
Copy link
Member

The symptom (which we apparently don't have test coverage for) was that the DatabaseConfig.port for Minder was being zeroed in staging and production, which caused Minder to fail to start.

I think we need to figure out a different way to configure this, and add a test that will prevent the misconfiguration from causing crashing servers.

We also have an action item to investigate why our alerting didn't immediately complain when we had crashing servers, so we only noticed it several hours later.

@evankanderson
Copy link
Member

(But, as it is, the values in EventConfig are dangerous in combination with the code to not initialize items with default:"{}" tags.)

@evankanderson
Copy link
Member

I think the right answer is to remove those (ignored) defaults, and then add a complaint if they sneak back in...

@evankanderson
Copy link
Member

Going through this code again, I think the exciting thing that got missed in #2633 is that if you skip calling setViperStructDefaults on the sub-message, fields don't merge properly between configs if you have multiple layers, and can't be set using environment variables. (See the comment at the top of setViperStructDefaults.)

Since this just bit us, I'll be working on a set of patches to roll this safely forward again. Did you need the ability to clear out the defaults from the structs that you added in #2633, or were you just trying to be complete?

@Vyom-Yadav
Copy link
Collaborator

Vyom-Yadav commented Mar 28, 2024

I think the exciting thing that got missed in #2633 is that if you skip calling setViperStructDefaults on the sub-message, fields don't merge properly between configs if you have multiple layers, and can't be set using environment variables

Right, with that, we dropped the ability to set things using env variables for struct fields with default:"{}".

For testing, if possible, I'd suggest having a test that replicates non-confidential server configuration options to ensure that the input configuration gives the expected complete (all options) output. That way, we can bridge some gaps between SAAS and OSS.

Did you need the ability to clear out the defaults from the structs that you added in #2633, or were you just trying to be complete?

I sort of needed that. The problem is that types like db connection are shared by multiple fields, and having the same defaults doesn't make sense. So zeroing them using default:"{}" looked like a better option. The user explicitly specifies that using config. Also, now that you mentioned env vars above, I think validation in #2638 doesn't check env vars. It gives an error based on just the config file. I'll fix that portion.

@JAORMX
Copy link
Contributor

JAORMX commented Mar 28, 2024

The symptom (which we apparently don't have test coverage for) was that the DatabaseConfig.port for Minder was being zeroed in staging and production, which caused Minder to fail to start.

I think we need to figure out a different way to configure this, and add a test that will prevent the misconfiguration from causing crashing servers.

We also have an action item to investigate why our alerting didn't immediately complain when we had crashing servers, so we only noticed it several hours later.

Another issue was the EEA, which ended configured with a zero value in the aggregator interval. Which ended up effectively disabling the lock. We really need better testing in general.

@evankanderson
Copy link
Member

See #2836 for a fix to flag the default:"{}" and remove them, and then #2839 to enable this case:

For testing, if possible, I'd suggest having a test that replicates non-confidential server configuration options to ensure that the input configuration gives the expected complete (all options) output. That way, we can bridge some gaps between SAAS and OSS.

I think the test added in #2836 effectively does this, for EEA. I'm not sure that testing each option's pass-through in all configurations is going to be a good use of effort -- as an example, Coveralls currently reports 60% coverage for internal/config. At the same time, we do need a mechanism to check that a prototypical configuration produces a reasonable outcome.

Maybe it makes sense to extend the --dump_config option to dump something more human-readable and then have a test that runs go run ./cmd/server serve --dump_config $OTHER_FLAGS and compares the output to what we expect?

Did you need the ability to clear out the defaults from the structs that you added in #2633, or were you just trying to be complete?

I sort of needed that. The problem is that types like db connection are shared by multiple fields, and having the same defaults doesn't make sense. So zeroing them using default:"{}" looked like a better option. The user explicitly specifies that using config. Also, now that you mentioned env vars above, I think validation in #2638 doesn't check env vars. It gives an error based on just the config file. I'll fix that portion.

I think the two PRs above (particularly #2839) should cover your use case.

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.

6 participants