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

Implement managed debug mode for tf5server and tf6server #137

Merged
merged 5 commits into from
Jan 12, 2022

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Jan 7, 2022

Closes #134

This will allow providers and downstream SDK implementations to opt into a fully managed debug server, which manages reattach configuration handling and stop signals, rather than requiring duplicate logic that can be unclear and/or verbose to implement.

The tf5server and tf6server implementations could use some refactoring to reduce their duplicated code (e.g. a shared internal package), however that is left for future handling, especially with other in flight changes at the moment.

Reference: #134

This will allow providers and downstream SDK implementations to opt into a fully managed debug server, which manages reattach configuration handling and stop signals, rather than requiring duplicate logic that can be unclear to implement.

The `tf5server` and `tf6server` implementations could use some refactoring to reduce _their_ duplicated code (e.g. a shared internal package), however that is left for future handling, especially with other in flight changes at the moment.
@bflad bflad added the enhancement New feature or request label Jan 7, 2022
@bflad bflad added this to the v0.6.0 milestone Jan 7, 2022
@bflad bflad requested a review from a team January 7, 2022 23:03
@bflad bflad self-assigned this Jan 7, 2022
@bflad
Copy link
Contributor Author

bflad commented Jan 10, 2022

Verification notes (ensuring providers could be debugged successfully via VS Code):

  • In terraform-provider-kubernetes, a muxed provider, the main function debug implementation simplified to only:
if *debugFlag {
	opts = append(opts, tf5server.WithManagedDebug())
}
// Serve serves a provider, blocking until the context is canceled.
func Serve(ctx context.Context, providerFunc func() Provider, opts ServeOpts) error {
	var tf6serverOpts []tf6server.ServeOpt

	if opts.Debug {
		tf6serverOpts = append(tf6serverOpts, tf6server.WithManagedDebug())
	}

	return tf6server.Serve(opts.Name, func() tfprotov6.ProviderServer {
		return &server{
			p: providerFunc(),
		}
	}, tf6serverOpts...)
}
  • In terraform-plugin-sdk, it would require some slight rework before being able to reduce the code, so didn't spend time there.

README.md Outdated Show resolved Hide resolved
Co-authored-by: Kit Ewbank <Kit_Ewbank@hotmail.com>
Copy link

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

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

LGTM 🚀.

@bflad bflad merged commit 1014e7b into main Jan 12, 2022
@bflad bflad deleted the bflad-server-managed-debug branch January 12, 2022 19:21
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support/Document Debugger Processes
2 participants