Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

configure number of parallel scanners from the API #147

Merged
merged 2 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions api/models/models.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,12 @@ components:
$ref: '#/components/schemas/ScanScopeType'
scheduled:
$ref: '#/components/schemas/RuntimeScheduleScanConfigType'
maxParallelScanners:
type: 'integer'
minimum: 1
maximum: 20
default: 2
description: "The maximum number of scanners that can run in parallel for each scan"

ScanConfigRelationship:
type: object
Expand All @@ -965,6 +971,8 @@ components:
readOnly: true
scheduled:
readOnly: true
maxParallelScanners:
readOnly: true
required: ['id']

ScanConfig:
Expand Down
167 changes: 84 additions & 83 deletions api/server/server.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions backend/pkg/database/demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,16 +384,18 @@ func createScanConfigs() []models.ScanConfig {

return []models.ScanConfig{
{
Name: "demo scan 1",
ScanFamiliesConfig: scanFamiliesConfig1,
Scheduled: &scheduled1,
Scope: &scanScopeType1,
Name: "demo scan 1",
ScanFamiliesConfig: scanFamiliesConfig1,
Scheduled: &scheduled1,
Scope: &scanScopeType1,
MaxParallelScanners: utils.PointerTo(2),
},
{
Name: "demo scan 2",
ScanFamiliesConfig: scanFamiliesConfig2,
Scheduled: &scanConfig2Scheduled,
Scope: &scanScopeType2,
Name: "demo scan 2",
ScanFamiliesConfig: scanFamiliesConfig2,
Scheduled: &scanConfig2Scheduled,
Scope: &scanScopeType2,
MaxParallelScanners: utils.PointerTo(3),
},
}
}
Expand Down
6 changes: 6 additions & 0 deletions backend/pkg/database/gorm/odata.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,9 @@ var schemaMetas = map[string]odatasql.SchemaMeta{
ComplexFieldSchemas: []string{"AwsScanScope"},
DiscriminatorProperty: "objectType",
},
"maxParallelScanners": odatasql.FieldMeta{
FieldType: odatasql.PrimitiveFieldType,
},
},
},
"ScanConfigData": {
Expand All @@ -416,6 +419,9 @@ var schemaMetas = map[string]odatasql.SchemaMeta{
ComplexFieldSchemas: []string{"AwsScanScope"},
DiscriminatorProperty: "objectType",
},
"maxParallelScanners": odatasql.FieldMeta{
FieldType: odatasql.PrimitiveFieldType,
},
},
},
"ScanFamiliesConfig": {
Expand Down
3 changes: 2 additions & 1 deletion runtime_scan/pkg/scanner/job_managment.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ const (
func (s *Scanner) jobBatchManagement(ctx context.Context) {
s.Lock()
targetIDToScanData := s.targetIDToScanData
numberOfWorkers := 2 // TODO: create this in the API
// Since this value has a default in the API, I assume it is safe to dereference it.
akpsgit marked this conversation as resolved.
Show resolved Hide resolved
numberOfWorkers := *s.scanConfig.MaxParallelScanners
s.Unlock()

// queue of scan data
Expand Down