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

Cataloger interface should accept context.Context #2521

Closed
willmurphyscode opened this issue Jan 19, 2024 · 0 comments · Fixed by #2528
Closed

Cataloger interface should accept context.Context #2521

willmurphyscode opened this issue Jan 19, 2024 · 0 comments · Fixed by #2528
Assignees
Labels
breaking-change Change is not backwards compatible enhancement New feature or request
Milestone

Comments

@willmurphyscode
Copy link
Contributor

willmurphyscode commented Jan 19, 2024

What would you like to be added:
We should also pass context down via the cataloger interface: https://github.com/anchore/syft/blob/main/syft/pkg/cataloger.go#L15.

Why is this needed:
In #2487, we added the ability to cancel the AllLocations iterator on the various file resolvers to prevent a go-routine leak. However, the context passed in here is generally created within a cataloger. Pass in context into the catalogers from the top. This paves the way for enabling cancellation and timeouts, and for long-running processes to more easily consume syft as a library.

Before we freeze the exported API for 1.0, we should pass context down.

Context should be added at this line: https://github.com/anchore/syft/blob/3046d43a8a225902590ae012a58b04836590ce54/internal/task/package_task_factory.go#L103C33-L103C40. Context is already passed down that far. This issue can be closed when it is passed down from there into the catalogers.

Also, search the codebase for context.Background() and wire it up to the catalogers context.

Additional context:
Originally requested as comment: #2487 (comment)

@willmurphyscode willmurphyscode added the enhancement New feature or request label Jan 19, 2024
@willmurphyscode willmurphyscode added this to the Syft 1.0 milestone Jan 19, 2024
@wagoodman wagoodman self-assigned this Jan 22, 2024
@wagoodman wagoodman added the breaking-change Change is not backwards compatible label Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Change is not backwards compatible enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants