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

Change reporting calls timings to ensure consistency #226

Open
wants to merge 5 commits into
base: development
Choose a base branch
from

Conversation

lucamrgs
Copy link
Collaborator

Added a sync.WaitGroup to the reporter module, which is used to ensure that the routine that reports the workflow end wg.Wait()-s before executing, allowing for all other reporting subroutines to record the progress correctly.

Note: I don't know if this can be unit-tested.

Copy link
Collaborator

@MaartendeKruijf MaartendeKruijf left a comment

Choose a reason for hiding this comment

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

I think we should solve this with an interface change which allows for the calling time to be added to the reporting time. So even when reporting would take 10 seconds the original time is used. If an endstep report fails we remain with the wait group with the proposed change

@lucamrgs lucamrgs changed the title add waitgroup to reporting calls to ensure consistency Change reporting calls timings to ensure consistency Oct 15, 2024
@lucamrgs lucamrgs force-pushed the bugfix/225-async-reporting-produces-ever-ongoing-steps branch from f3b4a7b to 49c1571 Compare October 15, 2024 08:35
Copy link

Sigrid maintainability feedback

↗️ You improved your code's maintainability towards your Sigrid objective of 4.0 stars

Sigrid compared your code against the baseline of 2024-10-14.

👍 What went well?

You fixed or improved 0 refactoring candidates.

👎 What could be better?

Unfortunately, 24 refactoring candidates were introduced or got worse.

Risk System property Location
🟠 Unit Size
(Worsened)
internal/executors/condition/condition.go
Executor.Execute(meta execution.Metadata, step cacao.Step, variables cacao.Variables)
🟠 Unit Interfacing
(Introduced)
internal/reporter/reporter.go
Reporter.ReportStepEnd(executionId uuid.UUID, step cacao.Step, returnVars cacao.Variables, stepError error, at time.Time)
🟠 Unit Interfacing
(Introduced)
internal/reporter/reporter.go
Reporter.reportStepEnd(executionId uuid.UUID, step cacao.Step, returnVars cacao.Variables, stepError error, at time.Time)
🟠 Unit Interfacing
(Introduced)
internal/reporter/downstream_reporter/cache/cache.go
Cache.upateEndExecutionStep(executionId uuid.UUID, stepId string, returnVars cacao.Variables, stepError error, acceptedStepStati []cache_report.Status, at time.Time)
🟠 Unit Interfacing
(Introduced)
internal/reporter/downstream_reporter/cache/cache.go
Cache.ReportStepEnd(executionId uuid.UUID, step cacao.Step, returnVars cacao.Variables, stepError error, at time.Time)
🟡 Unit Size
(Introduced)
internal/reporter/downstream_reporter/cache/cache.go
Cache.upateEndExecutionStep(executionId uuid.UUID, stepId string, returnVars cacao.Variables, stepError error, acceptedStepStati []cache_report.Status, at time.Time)
🟡 Unit Size
(Introduced)
internal/reporter/downstream_reporter/cache/cache.go
Cache.ReportWorkflowStart(executionId uuid.UUID, playbook cacao.Playbook, at time.Time)
🟡 Unit Size
(Introduced)
internal/reporter/downstream_reporter/cache/cache.go
Cache.ReportStepStart(executionId uuid.UUID, step cacao.Step, variables cacao.Variables, at time.Time)
🟡 Unit Size
(Introduced)
internal/reporter/downstream_reporter/cache/cache.go
Cache.upateEndExecutionWorkflow(executionId uuid.UUID, workflowError error, at time.Time)
🟡 Unit Complexity
(Worsened)
internal/executors/condition/condition.go
Executor.Execute(meta execution.Metadata, step cacao.Step, variables cacao.Variables)
🟡 Unit Interfacing
(Introduced)
internal/reporter/reporter.go
Reporter.reportWorkflowStart(executionId uuid.UUID, playbook cacao.Playbook, at time.Time)
🟡 Unit Interfacing
(Introduced)
internal/reporter/reporter.go
Reporter.reporStepStart(executionId uuid.UUID, step cacao.Step, returnVars cacao.Variables, at time.Time)
🟡 Unit Interfacing
(Introduced)
internal/reporter/reporter.go
Reporter.ReportWorkflowEnd(executionId uuid.UUID, playbook cacao.Playbook, workflowError error, at time.Time)
🟡 Unit Interfacing
(Introduced)
internal/reporter/reporter.go
Reporter.ReportWorkflowStart(executionId uuid.UUID, playbook cacao.Playbook, at time.Time)
🟡 Unit Interfacing
(Introduced)
internal/reporter/reporter.go
Reporter.reportWorkflowEnd(executionId uuid.UUID, playbook cacao.Playbook, workflowError error, at time.Time)
🟡 Unit Interfacing
(Introduced)
internal/reporter/reporter.go
Reporter.ReportStepStart(executionId uuid.UUID, step cacao.Step, returnVars cacao.Variables, at time.Time)
🟡 Unit Interfacing
(Introduced)
internal/reporter/downstream_reporter/cache/cache.go
Cache.ReportWorkflowEnd(executionId uuid.UUID, playbook cacao.Playbook, workflowError error, at time.Time)
🟡 Unit Interfacing
(Introduced)
internal/reporter/downstream_reporter/cache/cache.go
Cache.ReportWorkflowStart(executionId uuid.UUID, playbook cacao.Playbook, at time.Time)
🟡 Unit Interfacing
(Introduced)
internal/reporter/downstream_reporter/cache/cache.go
Cache.ReportStepStart(executionId uuid.UUID, step cacao.Step, variables cacao.Variables, at time.Time)
🟡 Unit Interfacing
(Introduced)
internal/reporter/downstream_reporter/cache/cache.go
Cache.upateEndExecutionWorkflow(executionId uuid.UUID, workflowError error, at time.Time)
🟡 Unit Interfacing
(Worsened)
internal/executors/condition/condition.go
Executor.Execute(meta execution.Metadata, step cacao.Step, variables cacao.Variables)
🟡 Unit Interfacing
(Introduced)
internal/executors/condition/condition.go
New(comparison comparison.IComparison, reporter reporter.IStepReporter, time timeUtil.ITime)
🟡 Unit Interfacing
(Introduced)
internal/executors/action/action.go
New(capabilities map [string ]capability.ICapability, reporter reporter.IStepReporter, time timeUtil.ITime)
🟡 Unit Interfacing
(Introduced)
internal/executors/playbook_action/playbook_action.go
New(controller decomposer_controller.IController, database database.IController, reporter reporter.IStepReporter, time timeUtil.ITime)

📚 Remaining technical debt

9 refactoring candidates didn't get better or worse, but are still present in the code you touched.

Risk System property Location
🟠 Unit Size
(Unchanged)
internal/executors/action/action.go
Executor.ExecuteActionStep(metadata execution.Metadata, command cacao.Command, authentication cacao.AuthenticationInformation, target cacao.AgentTarget, variables cacao.Variables, agent cacao.AgentTarget)
🟠 Unit Size
(Unchanged)
internal/executors/action/action.go
Executor.Execute(meta execution.Metadata, metadata PlaybookStepMetadata)
🟠 Unit Interfacing
(Unchanged)
internal/executors/action/action.go
Executor.ExecuteActionStep(metadata execution.Metadata, command cacao.Command, authentication cacao.AuthenticationInformation, target cacao.AgentTarget, variables cacao.Variables, agent cacao.AgentTarget)
🟡 Unit Size
(Unchanged)
internal/reporter/downstream_reporter/cache/cache.go
Cache.addExecutionFIFO(newExecutionEntry cache_report.ExecutionEntry)
🟡 Unit Size
(Unchanged)
internal/reporter/downstream_reporter/cache/cache.go
Cache.addStartExecutionStep(executionId uuid.UUID, newStepData cache_report.StepResult)
🟡 Unit Size
(Unchanged)
internal/executors/playbook_action/playbook_action.go
PlaybookAction.Execute(metadata execution.Metadata, step cacao.Step, variables cacao.Variables)
🟡 Unit Complexity
(Unchanged)
internal/executors/action/action.go
Executor.ExecuteActionStep(metadata execution.Metadata, command cacao.Command, authentication cacao.AuthenticationInformation, target cacao.AgentTarget, variables cacao.Variables, agent cacao.AgentTarget)
🟡 Unit Complexity
(Unchanged)
internal/executors/action/action.go
Executor.Execute(meta execution.Metadata, metadata PlaybookStepMetadata)
🟡 Unit Interfacing
(Unchanged)
internal/executors/playbook_action/playbook_action.go
PlaybookAction.Execute(metadata execution.Metadata, step cacao.Step, variables cacao.Variables)

Sigrid ratings

System property System on 2024-10-14 Before changes New/changed code
Volume 5.5 N/A N/A
Duplication 4.3 4.4 5.5
Unit Size 2.4 2.3 2.3
Unit Complexity 2.4 2.4 2.8
Unit Interfacing 2.2 0.9 0.5
Module Coupling 3.7 5.5 5.5
Component Independence 5.4 N/A N/A
Component Entanglement 2.4 N/A N/A
Maintainability 3.6 3.4 3.6

View this system in Sigrid


Did you find this feedback helpful?

We would like to know your thoughts to make Sigrid better.
Your username will remain confidential throughout the process.

@lucamrgs
Copy link
Collaborator Author

Why is sigrid bullying me tho

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.

async reporting produces ever ongoing step
2 participants