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

KIC 2.0: handle dump-config flag #1308

Closed
rainest opened this issue May 11, 2021 · 12 comments
Closed

KIC 2.0: handle dump-config flag #1308

rainest opened this issue May 11, 2021 · 12 comments
Assignees
Labels
area/maintenance Cleanup, refactoring, and other maintenance improvements that don't change functionality. priority/low size/medium

Comments

@rainest
Copy link
Contributor

rainest commented May 11, 2021

--dump-config enables a diagnostic dump of generated configuration. It is disabled by default.

@shaneutt shaneutt added area/maintenance Cleanup, refactoring, and other maintenance improvements that don't change functionality. size/medium labels Jun 2, 2021
@tharun208
Copy link
Contributor

tharun208 commented Jun 10, 2021

as #1408 is there. instead of writing to local files, can we expose the config in a separate URL /config ?.

thoughts @rainest @shaneutt

@rainest
Copy link
Contributor Author

rainest commented Jun 10, 2021

Yeah, that's the rough plan, probably under /debug/config-the filesystem dumps were a quick and easy way to get the files directly from the config sync loop, but my long-term plan was to instead expose a web interface, since copying stuff out is clunky.

The other thing I'd like to add is a short history of the last few generated configurations rather than only recording the latest good/bad config: we've found that one of the most common use cases for this is to figure out why the controller is updating configuration when we wouldn't expect it to. Getting several iterations of config updates with the single dumps is possible by just copying it out multiple times, but you have to time it manually, which is annoying.

@tharun208
Copy link
Contributor

tharun208 commented Jun 10, 2021

I like to work on this. I am thinking of providing the option to dump the config using the flag and also serving through an interface. and can we later deprecate the flag? WDYT @rainest

@rainest
Copy link
Contributor Author

rainest commented Jun 14, 2021

@tharun208 sure, go ahead.

We do want to leave the flag in place since enabling these can expose sensitive info within the config somewhere it wouldn't normally be accessible, and it should only be on temporarily when collecting diagnostic info though, so please don't remove that.

@tharun208
Copy link
Contributor

@rainest, is it okay to extend the UpdateKongAdminSimple as we are already calling deckgen.ToDeckContent ?
https:/Kong/kubernetes-ingress-controller/blob/next/pkg/sendconfig/common_workflows.go#L47

@rainest
Copy link
Contributor Author

rainest commented Jun 16, 2021

Yes with some caveats. UpdateKongAdminSimple() is where you'll add functionality to ship the dump elsewhere as the generated content doesn't leave it. It is roughly the 2.x equivalent of the 1.x OnUpdate(), where we handle config dumps currently.

You'll note that the dump handling there doesn't always use the original generated config. Dumping supports both a redacted mode (omitting credentials and certificates) and full/sensitive mode. The redacted mode needs to regenerate configuration by passing state.SanitizedCopy() instead of state. In sensitive mode, you do pass the original targetContent.

@tharun208
Copy link
Contributor

tharun208 commented Jul 4, 2021

started working on this.
One more question, I am thinking not to extend the signature of the UpdateKongAdminSimple with the dump config and dumpDir values. Instead, can I add these values to the kong config struct?

@rainest
Copy link
Contributor Author

rainest commented Jul 6, 2021

I don't see any particularly good place to stick it. Originally we added the dir to the user config struct and passed that (which already included the dump mode) to OnUpdate() (sort of the predecessor to UpdateKongAdminSimple()). OnUpdate() was also a method and had access to the controller config (sort of like the clientgoCachedProxyResolver struct).

They arguably shouldn't go into the Kong struct, since that holds connection information for the admin API, and the dump configuration doesn't fall into that category.

As-is, I think these should be new fields in clientgoCachedProxyResolver and should be arguments to UpdateKongAdminSimple().

The latter's signature is getting unwieldy at this point. @shaneutt do you think it'd make sense to refactor it to accept a new struct containing static config (probably ingressClassName, enableReverseSync, this dump configuration, and kongConfig, and possibly the cache, which don't change between invocations) and pass that instead?

@tharun208
Copy link
Contributor

@rainest, also I am planning to expose the config on the web interface, can I include the same in this pr or?

@rainest
Copy link
Contributor Author

rainest commented Jul 6, 2021

Yep, that's fine. It'd be an additional part of https:/Kong/kubernetes-ingress-controller/blob/next/railgun/internal/diagnostics/server.go

To implement that you'd presumably add a channel to ship the config blob from the update loop to the diagnostics server.

@rainest
Copy link
Contributor Author

rainest commented Jul 21, 2021

@tharun208 hey, checking in on this again. We'd like to put out a feature complete 2.x beta by the end of July, so we plan to take over development of this to get it out on time for that. Did you have any draft code for this already in progress that you wanted to publish for us to try and work on collaboratively, or was it as of yet not started?

@tharun208
Copy link
Contributor

@rainest I haven't started working on this. I am un-assigning myself from this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/maintenance Cleanup, refactoring, and other maintenance improvements that don't change functionality. priority/low size/medium
Projects
None yet
Development

No branches or pull requests

4 participants