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

Log the human readable plan to debug log #227

Merged
merged 4 commits into from
Mar 20, 2025
Merged

Conversation

corymhall
Copy link
Contributor

Follow up to #222 to add the human readable plan to the debug log
output.

fixes #216

@corymhall
Copy link
Contributor Author

This change is part of the following stack:

Change managed by git-spice.

@corymhall corymhall requested review from t0yv0 and a team March 19, 2025 14:51
@corymhall corymhall mentioned this pull request Mar 19, 2025
@@ -73,5 +73,11 @@ func (t *Tofu) planWithOptions(ctx context.Context, logger Logger, refreshOnly b
return nil, fmt.Errorf("error running show plan: %w", err)
}

humanPlan, err := t.tf.ShowPlanFileRaw(ctx, planFile, tfexec.JSONNumber(true))
Copy link
Member

Choose a reason for hiding this comment

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

Can probably run in parallel with ShowPlanFile right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated!

Base automatically changed from corymhall/fix-logging-option1 to main March 19, 2025 20:05
@corymhall corymhall force-pushed the corymhall/debug-plan branch from a758987 to 69ee467 Compare March 19, 2025 20:32
plan, err := t.tf.ShowPlanFile(ctx, planFile, tfexec.JSONNumber(true))
if err != nil {
return nil, fmt.Errorf("error running show plan: %w", err)
var wg sync.WaitGroup
Copy link
Member

Choose a reason for hiding this comment

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

Go makes this kind of parallelism really awkward. You have a lot of machinery in use here, it's probably fine but heavy. A bit of Go golf, you really need only one WaitGroup or one chan, and can do a fork-join pattern. Can also leave micro-optimization for later with a comment, sorry for picking here.

func fx() (int, error) {
	return 2, fmt.Errorf("f-failed")
}

func gx() (int, error) {
	return 1, fmt.Errorf("g-failed")
}

func par() (int, error) {

	var (
		fr   int
		ferr error
		fch  chan bool = make(chan bool)
	)

	// fork
	go func() {
		defer close(fch)
		fr, ferr = fx()
	}()

	gr, gerr := gx()

	// join
	<-fch

	err := errors.Join(ferr, gerr)
	if err != nil {
		return 0, err
	}

	return fr + gr, nil
}

@corymhall corymhall force-pushed the corymhall/debug-plan branch from 69ee467 to 1d7bc62 Compare March 20, 2025 13:02
Follow up to #222 to add the human readable plan to the debug log
output.

fixes #216
@corymhall corymhall force-pushed the corymhall/debug-plan branch from 1d7bc62 to 64432ce Compare March 20, 2025 13:03
@corymhall corymhall merged commit ea88cb0 into main Mar 20, 2025
11 checks passed
@t0yv0 t0yv0 deleted the corymhall/debug-plan branch March 21, 2025 04:22
@pulumi-bot
Copy link
Contributor

This PR has been shipped in release v0.0.6.

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.

Surface log details for a more complete error message output
3 participants