Skip to content

improve build volumes handling#75

Merged
bennyz merged 1 commit into
centos-automotive-suite:mainfrom
bennyz:fix-memory-volumes
Feb 5, 2026
Merged

improve build volumes handling#75
bennyz merged 1 commit into
centos-automotive-suite:mainfrom
bennyz:fix-memory-volumes

Conversation

@bennyz

@bennyz bennyz commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

we were using memory volumes by default for too many paths. Instead we should use disk, unless explictly asked by the config.

Summary by CodeRabbit

  • New Features

    • Added a useMemoryContainerStorage option to enable memory-backed storage for container-specific paths (default: false — disk-backed).
  • Documentation

    • Clarified that memoryVolumeSize applies only when either memory-backed option is enabled.
    • Updated CRD, sample configuration, and field descriptions to include useMemoryContainerStorage and explicit defaults for memory-backed options.

@coderabbitai

coderabbitai Bot commented Feb 5, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Added a new UseMemoryContainerStorage boolean to OSBuilds and BuildConfig, updated CRD/schema and sample docs, and changed Tekton task generation and controller flow to conditionally mark container-storage, run-dir, run-osbuild and var-tmp volumes as memory-backed when the flag is enabled.

Changes

Cohort / File(s) Summary
API Type Definitions
api/v1alpha1/operatorconfig_types.go
Added UseMemoryContainerStorage (bool) to BuildConfig and OSBuildsConfig with JSON tags and docs; adjusted UseMemoryVolumes default annotation and updated MemoryVolumeSize docs.
CRD / Manifests
bundle/manifests/automotive.sdv.cloud.redhat.com_operatorconfigs.yaml, config/crd/bases/automotive.sdv.cloud.redhat.com_operatorconfigs.yaml
Added useMemoryContainerStorage boolean to CRD schema under spec.osBuilds; updated descriptions for useMemoryVolumes (explicit default) and memoryVolumeSize to reference both memory-backed options.
Samples / Docs
config/samples/automotive_v1_operatorconfig.yaml
Inserted commented sample useMemoryContainerStorage with explanatory comments; updated guidance about when memoryVolumeSize applies (either memory-backed volumes or container storage).
Task Generation
internal/common/tasks/tasks.go
Added UseMemoryContainerStorage to BuildConfig; changed default EmptyDir volumes to disk-backed and added conditional logic to set EmptyDir.medium=Memory and SizeLimit when UseMemoryContainerStorage (and/or UseMemoryVolumes) is true; updated function signature for Prepare task.
Controller
internal/controller/operatorconfig/controller.go
Populate new BuildConfig.UseMemoryContainerStorage from OperatorConfig OSBuilds spec; pass buildConfig to updated GeneratePrepareBuilderTask call sites.

Sequence Diagram

sequenceDiagram
    participant User as User/Config
    participant Controller as OperatorConfig Controller
    participant TaskGen as Task Generator
    participant Tekton as Tekton

    User->>Controller: Submit OperatorConfig (useMemoryContainerStorage flag)
    Controller->>Controller: Read OSBuilds -> build BuildConfig (UseMemoryContainerStorage)
    Controller->>TaskGen: Call GeneratePrepareBuilderTask(namespace, buildConfig)
    TaskGen->>TaskGen: Inspect BuildConfig.UseMemoryContainerStorage
    alt UseMemoryContainerStorage true
        TaskGen->>TaskGen: Set EmptyDir.medium=Memory for container-storage, run-dir, run-osbuild, var-tmp
        TaskGen->>TaskGen: Apply memoryVolumeSize as SizeLimit if provided
    else
        TaskGen->>TaskGen: Leave volumes as disk-backed EmptyDir
    end
    TaskGen->>Tekton: Emit configured Tekton Task
    Tekton->>Tekton: Run Task with configured volumes
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I nibble code and tweak a flag,

EmptyDirs no longer lag.
Memory paths now softly hum,
Tasks hop on — preparations done.
A tiny hop for builds to run!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'improve build volumes handling' is related to the main changes in the PR but lacks specificity about what the improvement entails.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 Fix all issues with AI agents
In `@api/v1alpha1/operatorconfig_types.go`:
- Around line 31-35: The docstring for the optional boolean field
UseMemoryContainerStorage incorrectly states "Default: true" while the actual
omitted/default value is false; update that comment to "Default: false
(disk-backed)" and adjust any matching doc comments for other similar optional
memory-backed storage booleans in this file to reflect disk-backed default, and
ensure the CRD/sample manifests are kept in sync with the corrected default
text; locate the field named UseMemoryContainerStorage in
operatorconfig_types.go and the other analogous boolean fields nearby and change
their Default: text and sample/CRD docs accordingly.

In `@bundle/manifests/automotive.sdv.cloud.redhat.com_operatorconfigs.yaml`:
- Around line 542-547: The CRD field useMemoryContainerStorage's description
currently states the default is true; update the description for
useMemoryContainerStorage to reflect the new default behavior (default: false)
and that disk-backed volumes are used by default for
/var/lib/containers/storage, /run/osbuild, and /var/tmp; keep the existing
explanation about SELinux xattr and memory tradeoffs but flip the default value
text and adjust phrasing to indicate memory-backed volumes are optional when set
to true.

In `@config/crd/bases/automotive.sdv.cloud.redhat.com_operatorconfigs.yaml`:
- Around line 542-547: The CRD description for the boolean field
useMemoryContainerStorage is inaccurate (says "Default: true") — update the
description text for useMemoryContainerStorage to reflect that the field is
optional and defaults to false unless explicitly set (e.g., change "Default:
true" to "Default: false" and/or add "optional" wording) so the documentation
matches the actual default behavior.

In `@config/samples/automotive_v1_operatorconfig.yaml`:
- Around line 23-27: Update the sample comments to reflect the new disk-backed
default by changing the descriptive line to "Default: false (disk-backed, lower
memory usage)" and clarify trade-offs; also add an explicit example showing how
to opt in to memory-backed storage by including the commented key with a clear
note (useMemoryContainerStorage: true) so users know to uncomment/set it to opt
in. Reference the useMemoryContainerStorage sample entry and the surrounding
explanatory comment block so you update the default text and add the opt-in
example in the same comment section.

In `@internal/common/tasks/tasks.go`:
- Around line 406-412: The code incorrectly defaults useMemoryContainerStorage
to true when buildConfig is nil; update the initialization of
useMemoryContainerStorage (the variable used in the container storage branch) to
default to false and only set it to buildConfig.UseMemoryContainerStorage when
buildConfig != nil; apply this same change at both occurrences where
useMemoryContainerStorage is initialized (the block around the earlier branch
and the later block near the second occurrence, lines referenced by the variable
usage) so disk storage becomes the default unless explicitly enabled via
buildConfig.

Comment thread api/v1alpha1/operatorconfig_types.go
Comment thread config/samples/automotive_v1_operatorconfig.yaml Outdated
Comment thread internal/common/tasks/tasks.go
@bennyz bennyz force-pushed the fix-memory-volumes branch from f975fd0 to 41620ea Compare February 5, 2026 07:47

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@internal/common/tasks/tasks.go`:
- Around line 406-428: When UseMemoryContainerStorage is true we currently set
EmptyDir.Medium but never apply the configured size limit; update the loop in
which useMemoryContainerStorage is read (and the analogous block at the other
location) to set EmptyDir.SizeLimit using buildConfig.MemoryVolumeSize whenever
you create or mutate an EmptyDir for the memory-backed volumes. Concretely:
inside the loop over task.Spec.Volumes, for volumes named "container-storage",
"run-dir" (and "var-tmp" if present in the other block) ensure vol.EmptyDir is
non-nil, set vol.EmptyDir.Medium = corev1.StorageMediumMemory if not already,
and set vol.EmptyDir.SizeLimit = &buildConfig.MemoryVolumeSize (or parse the
string into a resource.Quantity if MemoryVolumeSize is a string) so the limit is
applied; apply the same changes to the other block that handles memory volumes
(the block around lines 1230-1246).

Comment thread internal/common/tasks/tasks.go
we were using memory volumes by default for too many paths. Instead we should use disk,
unless explictly asked by the config.

Signed-off-by: Benny Zlotnik <bzlotnik@redhat.com>
@bennyz bennyz force-pushed the fix-memory-volumes branch from 41620ea to f6aef24 Compare February 5, 2026 07:59

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@api/v1alpha1/operatorconfig_types.go`:
- Around line 167-177: The generated deepcopy code is missing the new
OSBuildsConfig fields; run the code generator (e.g., execute "make generate
manifests") to regenerate zz_generated.deepcopy.go so DeepCopyInto for
OSBuildsConfig includes copying UseMemoryContainerStorage and MemoryVolumeSize
(ensure the regenerated DeepCopyInto method for OSBuildsConfig explicitly
handles these two fields).
🧹 Nitpick comments (1)
internal/common/tasks/tasks.go (1)

420-423: Consider removing redundant nil check (optional).

The buildConfig != nil check is redundant since useMemoryContainerStorage can only be true if buildConfig was non-nil (see lines 409-411 and 1231-1233). The code is correct but could be simplified.

♻️ Optional simplification
 	if useMemoryContainerStorage {
 		for i := range task.Spec.Volumes {
 			vol := &task.Spec.Volumes[i]

 			if vol.Name == "container-storage" || vol.Name == "run-dir" {
 				vol.EmptyDir = &corev1.EmptyDirVolumeSource{
 					Medium: corev1.StorageMediumMemory,
 				}
-				if buildConfig != nil && buildConfig.MemoryVolumeSize != "" {
+				if buildConfig.MemoryVolumeSize != "" {
 					sizeLimit := resource.MustParse(buildConfig.MemoryVolumeSize)
 					vol.EmptyDir.SizeLimit = &sizeLimit
 				}
 			}
 		}
 	}

Apply the same pattern at line 1242.

Also applies to: 1242-1245

Comment thread api/v1alpha1/operatorconfig_types.go
@bennyz bennyz merged commit 72cc1c5 into centos-automotive-suite:main Feb 5, 2026
4 checks passed
@bennyz bennyz deleted the fix-memory-volumes branch February 5, 2026 08:43
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.

1 participant