Skip to content

Commit

Permalink
Merge pull request #1007 from coreos/pr/azure-iso
Browse files Browse the repository at this point in the history
Azure: support both udf and iso9660 filesystems types for custom-data
  • Loading branch information
Ben Howard committed Jun 25, 2020
2 parents d11fff9 + 766e318 commit 0c0ec63
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion internal/providers/azure/azure.go
Expand Up @@ -25,6 +25,7 @@ import (

"github.com/coreos/ignition/v2/config/v3_2_experimental/types"
"github.com/coreos/ignition/v2/internal/distro"
execUtil "github.com/coreos/ignition/v2/internal/exec/util"
"github.com/coreos/ignition/v2/internal/log"
"github.com/coreos/ignition/v2/internal/providers/util"
"github.com/coreos/ignition/v2/internal/resource"
Expand Down Expand Up @@ -52,6 +53,14 @@ const (
CDS_DISC_OK
)

// These constants are the types of CDROM filesystems that might
// be used to present a custom-data volume. Azure proper uses a
// udf volume, while Azure Stack might use udf or iso9660.
const (
CDS_FSTYPE_UDF = "udf"
CDS_FSTYPE_ISO9660 = "iso9660"
)

func FetchConfig(f *resource.Fetcher) (types.Config, report.Report, error) {
devicePath := filepath.Join(distro.DiskByIDDir(), configDeviceID)

Expand All @@ -65,9 +74,17 @@ func FetchConfig(f *resource.Fetcher) (types.Config, report.Report, error) {
}
defer os.Remove(mnt)

fs, err := execUtil.GetFilesystemInfo(devicePath, false)
if err != nil {
return types.Config{}, report.Report{}, fmt.Errorf("failed to get config fs type %s: %v", devicePath, err)
}
if !(fs.Type == CDS_FSTYPE_UDF || fs.Type == CDS_FSTYPE_ISO9660) {
return types.Config{}, report.Report{}, fmt.Errorf("found unsupported filesystem %s on %s", fs.Type, devicePath)
}

logger.Debug("mounting config device")
if err := logger.LogOp(
func() error { return unix.Mount(devicePath, mnt, "udf", unix.MS_RDONLY, "") },
func() error { return unix.Mount(devicePath, mnt, fs.Type, unix.MS_RDONLY, "") },
"mounting %q at %q", devicePath, mnt,
); err != nil {
return types.Config{}, report.Report{}, fmt.Errorf("failed to mount device %q at %q: %v", devicePath, mnt, err)
Expand Down

0 comments on commit 0c0ec63

Please sign in to comment.