fix(image-scan): let a server set the scanner memory limit

Grype was killed at the fixed 1 GiB container limit on large images.

- Add the per-server setting image_scan_memory_mb (1, 2, 4 or 8 GB,
  default 1 GB) on the Vulnerabilities page and in the
  /servers/{uuid}/image-scanning API.
- Set GOMEMLIMIT to 85% of the limit, so Go collects garbage before
  the container limit kills the scanner.
- The out-of-memory error now tells the user to raise the limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Andras Bacsai
2026-11-09 17:09:31 +01:00
co-authored by Claude Opus 5.5
parent ae1147003b
commit dc7a5946e9
14 changed files with 291 additions and 28 deletions
+9
View File
@@ -108,9 +108,16 @@ class ServerSetting extends Model
*/
public const string DEFAULT_AXIOM_DOMAIN = 'us-east-1.aws.edge.axiom.co';
/** Memory limit of each scanner container (Syft, Grype, regctl), in MB. */
public const int DEFAULT_IMAGE_SCAN_MEMORY_MB = 1024;
/** @var list<int> */
public const array IMAGE_SCAN_MEMORY_OPTIONS_MB = [1024, 2048, 4096, 8192];
protected $fillable = [
'server_id',
'is_image_scan_enabled',
'image_scan_memory_mb',
'image_candidate_scans_today',
'image_candidate_scans_date',
'is_swarm_manager',
@@ -196,6 +203,7 @@ class ServerSetting extends Model
protected $attributes = [
'is_traffic_analytics_enabled' => false,
'is_image_scan_enabled' => false,
'image_scan_memory_mb' => self::DEFAULT_IMAGE_SCAN_MEMORY_MB,
'image_candidate_scans_today' => 0,
];
@@ -230,6 +238,7 @@ class ServerSetting extends Model
'is_auto_security_updates_enabled' => 'boolean',
'is_logdrain_cloudwatch_enabled' => 'boolean',
'is_image_scan_enabled' => 'boolean',
'image_scan_memory_mb' => 'integer',
'image_candidate_scans_today' => 'integer',
'image_candidate_scans_date' => 'date',
'ssh_host_key_trusted_at' => 'datetime',