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

⚠️ always use up-to-date context #310

Merged
merged 2 commits into from
Sep 15, 2023

Conversation

pranavgaikwad
Copy link
Contributor

@pranavgaikwad pranavgaikwad commented Aug 30, 2023

We were using stale context. I observed it when looking at tracer output, some spans were being recorded in the scope of main context, instead of their provider specific context.

⚠️ changes provider api

@pranavgaikwad pranavgaikwad marked this pull request as ready for review August 30, 2023 16:10
Copy link
Member

@djzager djzager left a comment

Choose a reason for hiding this comment

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

VISACK

@@ -41,6 +42,9 @@ const javaProjectPom = `<?xml version="1.0" encoding="UTF-8"?>
// creates new java project and puts the java files in the tree of the project
// returns path to exploded archive, path to java project, and an error when encountered
func decompileJava(ctx context.Context, log logr.Logger, archivePath string) (explodedPath, projectPath string, err error) {
ctx, span := tracing.StartNewSpan(ctx, "decompile")
Copy link
Member

Choose a reason for hiding this comment

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

Nice.

Copy link
Contributor

@shawn-hurley shawn-hurley left a comment

Choose a reason for hiding this comment

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

We don't want the ctx that the service clients have for initialization to be the same as the ctx for a specific call to Evaluate or Dep or do we?

@pranavgaikwad
Copy link
Contributor Author

@shawn-hurley there is only one root context we initialize in main.go. All other contexts are derived from it eventually somewhere in the entire call tree, so a cancelled root context will correctly pass down to every child...Is there any other reason to use different contexts in service initialization

@shawn-hurley
Copy link
Contributor

Could there be a time when the engine is run multiple times? I think that is the use case?

@pranavgaikwad
Copy link
Contributor Author

@shawn-hurley I don't think I completely understand, as long as we pass the same context to engine and all providers here

if err := s.Start(ctx); err != nil {
and here
eng := engine.CreateRuleEngine(ctx,
. shouldn't that be fine?

@shawn-hurley
Copy link
Contributor

Yeah, but could there be a time when the engine is running on its own, and rules come in, and the providers are instantiated when the rules come in (if not set)? Stoping one call to then engine then is different than stopping the full engine.

You are not wrong that right now, this will work exactly as you expect, I think keeping them separate prevents some hard debugging in future IMO

If we don't think that this is ever a concern that it is not a huge deal.

@pranavgaikwad
Copy link
Contributor Author

@shawn-hurley Okay, I understand now. Thanks for explanation. I think your concern is valid, in that case, I think we should split our root context into two different contexts, one that goes into the init call, and another that goes to engine to use in evaluate() calls for each incoming rule. We can do that in future when needed even with this change.

@shawn-hurley
Copy link
Contributor

makes sense, then I am good with this change

@shawn-hurley
Copy link
Contributor

@pranavgaikwad can you rebase?

@pranavgaikwad
Copy link
Contributor Author

@shawn-hurley rebased.

@pranavgaikwad
Copy link
Contributor Author

pranavgaikwad commented Sep 14, 2023

@shawn-hurley this is interesting, since external provider update in this PR is dependent on the change in the PR itself, and now we dont have the replace in the go.mod of external provider, the build is failing

Fixed now: added a step in the CI to replace dep

@pranavgaikwad pranavgaikwad force-pushed the fixContext branch 2 times, most recently from 381f538 to 0142612 Compare September 14, 2023 20:04
@shawn-hurley
Copy link
Contributor

Sorry need another rebase, I am sorry I tried to reduce this

@pranavgaikwad pranavgaikwad merged commit 94f0459 into konveyor:main Sep 15, 2023
6 checks passed
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.

3 participants