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

Fix lost diags across different mutators #2057

Merged
merged 1 commit into from
Dec 31, 2024
Merged

Conversation

denik
Copy link
Contributor

@denik denik commented Dec 31, 2024

Changes

Fix cases where accumulated diagnostics are lost instead of being propagated further. In some cases it's not possible, add a comment there.

Tests

Existing tests

@denik denik temporarily deployed to test-trigger-is December 31, 2024 09:59 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 31, 2024 09:59 — with GitHub Actions Inactive
@denik denik marked this pull request as ready for review December 31, 2024 10:55
@denik denik force-pushed the denik/do-not-lose-diags branch from 6681198 to 94dbac2 Compare December 31, 2024 11:58
@denik denik temporarily deployed to test-trigger-is December 31, 2024 11:58 — with GitHub Actions Inactive
Copy link

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/cli

Inputs:

  • PR number: 2057
  • Commit SHA: 94dbac2314c535fc57bfed1186cdb418ac7ac804

Checks will be approved automatically on success.

@denik denik temporarily deployed to test-trigger-is December 31, 2024 11:58 — with GitHub Actions Inactive
@@ -40,6 +40,7 @@ func (m *resolveResourceReferences) Apply(ctx context.Context, b *bundle.Bundle)
})
}

// Note, diags are lost from all goroutines except the first one to return diag
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we fix it instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know of an easy way - one would need to synchronize access to some common data structure - and I'd rather not invest a lot of time there - as this won't be necessary if move away from returning diags.

Copy link
Contributor

Choose a reason for hiding this comment

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

can't it just be as simple as

mu.Lock()
diags = diags.Append(...)
mu.Unlock()

inside the goroutine?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe - we can discuss offline. I'd consider this out of scope for this PR though (it does not need to be perfect, just incrementally better).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are more cases of using errgroup and diags together. So if we want to solve it properly, we should probably have some sort of abstraction that makes the usage foolproof.

However, like I said above, I'd rather not invest there because at this point it seems that the best abstraction is to call a function as soon as you have a diagnostic message, not accumulate them.

@denik denik requested a review from andrewnester December 31, 2024 13:19
@denik denik added this pull request to the merge queue Dec 31, 2024
Merged via the queue into main with commit 3f523b4 Dec 31, 2024
9 checks passed
@denik denik deleted the denik/do-not-lose-diags branch December 31, 2024 14:09
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.

2 participants