Skip to content

Commit

Permalink
main: check if local storage has been mounted
Browse files Browse the repository at this point in the history
Since we are using local storage by default, Wwe should fail early if it
hasn't been mounted. Some undefined behaviour has been seen when local storage
volume hasn't been mounted and the `--local` flag has been provided.
  • Loading branch information
kingsleyzissou committed Mar 20, 2024
1 parent d294651 commit 56ce13b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions bib/cmd/bootc-image-builder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"strings"

"github.com/osbuild/bootc-image-builder/bib/internal/setup"
"github.com/osbuild/bootc-image-builder/bib/internal/util"
"github.com/osbuild/images/pkg/arch"
"github.com/osbuild/images/pkg/blueprint"
"github.com/osbuild/images/pkg/cloud/awscloud"
Expand All @@ -29,9 +30,10 @@ import (
var reposStr string

const (
distroName = "fedora-39"
modulePlatformID = "platform:f39"
releaseVersion = "39"
distroName = "fedora-39"
modulePlatformID = "platform:f39"
releaseVersion = "39"
containersStoragePath = "/var/lib/containers/storage"
)

type BuildConfig struct {
Expand Down Expand Up @@ -102,6 +104,12 @@ func loadConfig(path string) (*BuildConfig, error) {
}

func makeManifest(c *ManifestConfig, cacheRoot string) (manifest.OSBuildManifest, error) {
// if "/var/lib/containers/storage" hasn't been mounted and the `--local` flag has been provided,
// we should return an error. If it's not mounted, it can cause some undefined behaviour.
if c.Local && !util.IsMountpoint(containersStoragePath) {
return nil, fmt.Errorf("%s has not been mounted, but `--local` flag has been used", containersStoragePath)
}

// If --local wasn't given, always pull the container.
// If the user mount a container storage inside bib (without --local), the code will try to pull
// a newer version of the container even if an older one is already present. This doesn't match
Expand Down

0 comments on commit 56ce13b

Please sign in to comment.