-
Notifications
You must be signed in to change notification settings - Fork 752
Open
Labels
enhancementNew feature or requestNew feature or request
Description
What would you like to be added:
It seems that syft.CreateSBOM(context.Context, source.Source, *CreateSBOMConfig) accepts the Go context as the first argument, but when I pass a cancellable context it's ignored and cataloguers' tasks continue running nevertheless.
ctx := context.Background()
scanCtx, cancelScan := context.WithCancelCause(ctx)
defer cancelScan(nil)
go func() {
// periodically check for memory pressure against soft memory limit ...
// if memory is above the watermark
cancelScan(memory.ErrMemoryPressure)
}()
syftJson, err := syft.CreateSBOM(scanCtx, ...)Why is this needed:
I'm facing some high memory usage issues with Syft running in a container as a Kubernetes Pod. To bound somehow the upper memory limit before I get OOMKill errors I just want to cancel SBOM generation in idiomatic Go way, i.e. by cancelling the context passed to Syft library method.
Additional context:
- It seems that the cancellation request is respected by functions that pull down sources from remote registry, but once cataloguer tasks start I cannot stop Syft from running anymore.
- https://go.dev/doc/database/cancel-operations
dvdlevanon-miggo, dvdlevanon, shanimiggo and AustinAbro321shanimiggo
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Type
Projects
Status
Ready