feat: rename DATA partition to EPHEMERAL

This changes the data partition name to something more appropriate. We
chose ephemeral to make it very clear that the disk should not be used
for application data.

Signed-off-by: Andrew Rynhard <andrew@andrewrynhard.com>
This commit is contained in:
Andrew Rynhard
2019-08-15 12:12:22 +00:00
parent 92452ab981
commit a116145c1b
13 changed files with 39 additions and 42 deletions

View File

@@ -37,7 +37,7 @@ var installCmd = &cobra.Command{
Install: &userdata.Install{ Install: &userdata.Install{
Force: true, Force: true,
ExtraKernelArgs: extraKernelArgs, ExtraKernelArgs: extraKernelArgs,
Data: &userdata.InstallDevice{ Ephemeral: &userdata.InstallDevice{
Device: device, Device: device,
Size: 16 * 1024 * 1024, Size: 16 * 1024 * 1024,
}, },

View File

@@ -1,5 +1,5 @@
--- ---
title: User Data title: User ephemeral
date: 2019-06-21T19:40:55-07:00 date: 2019-06-21T19:40:55-07:00
draft: false draft: false
weight: 20 weight: 20
@@ -369,7 +369,8 @@ install:
**Note** The asset name **must** be named `initramfs.xz`. **Note** The asset name **must** be named `initramfs.xz`.
### Data ### Ephemeral
#### Device #### Device
``Device`` specifies the device name to use for the `/var` partition. This should be specified as the ``Device`` specifies the device name to use for the `/var` partition. This should be specified as the
@@ -377,7 +378,7 @@ unpartitioned block device. If this parameter is omitted, the value of `install.
```yaml ```yaml
install: install:
data: ephemeral:
device: <name of device to use> device: <name of device to use>
``` ```
@@ -388,7 +389,7 @@ value of 1GB will be used. This partition will auto extend to consume the remain
```yaml ```yaml
install: install:
data: ephemeral:
size: <size in bytes> size: <size in bytes>
``` ```

View File

@@ -51,7 +51,7 @@ func (i *ISO) UserData() (data *userdata.UserData, err error) {
Size: 512 * 1000 * 1000, Size: 512 * 1000 * 1000,
}, },
}, },
Data: &userdata.InstallDevice{ Ephemeral: &userdata.InstallDevice{
Device: "/dev/sda", Device: "/dev/sda",
Size: 2048 * 1000 * 1000, Size: 2048 * 1000 * 1000,
}, },

View File

@@ -127,7 +127,7 @@ func (i *Installer) Install() (err error) {
if err = syslinux.Prepare(target.Device); err != nil { if err = syslinux.Prepare(target.Device); err != nil {
return err return err
} }
case constants.DataPartitionLabel: case constants.EphemeralPartitionLabel:
continue continue
} }

View File

@@ -33,7 +33,7 @@ func (suite *validateSuite) TestVerifyDevice() {
// defaults. // defaults.
data.Install.Boot = nil data.Install.Boot = nil
suite.Require().NoError(VerifyBootDevice(data)) suite.Require().NoError(VerifyBootDevice(data))
data.Install.Data = &userdata.InstallDevice{ data.Install.Ephemeral = &userdata.InstallDevice{
Device: "/dev/sda", Device: "/dev/sda",
} }
suite.Require().NoError(VerifyDataDevice(data)) suite.Require().NoError(VerifyDataDevice(data))
@@ -101,7 +101,7 @@ install:
boot: boot:
device: /dev/sda device: /dev/sda
size: 1024000000 size: 1024000000
data: ephemeral:
device: /dev/sda device: /dev/sda
size: 1024000000 size: 1024000000
` `

View File

@@ -62,8 +62,8 @@ func NewManifest(data *userdata.UserData) (manifest *Manifest) {
// Initialize any slices we need. Note that a boot paritition is not // Initialize any slices we need. Note that a boot paritition is not
// required. // required.
if manifest.Targets[data.Install.Data.Device] == nil { if manifest.Targets[data.Install.Ephemeral.Device] == nil {
manifest.Targets[data.Install.Data.Device] = []*Target{} manifest.Targets[data.Install.Ephemeral.Device] = []*Target{}
} }
var bootTarget *Target var bootTarget *Target
@@ -89,12 +89,12 @@ func NewManifest(data *userdata.UserData) (manifest *Manifest) {
} }
dataTarget := &Target{ dataTarget := &Target{
Device: data.Install.Data.Device, Device: data.Install.Ephemeral.Device,
Label: constants.DataPartitionLabel, Label: constants.EphemeralPartitionLabel,
Size: data.Install.Data.Size, Size: data.Install.Ephemeral.Size,
Force: data.Install.Force, Force: data.Install.Force,
Test: false, Test: false,
MountPoint: constants.DataMountPoint, MountPoint: constants.EphemeralMountPoint,
} }
for _, target := range []*Target{bootTarget, dataTarget} { for _, target := range []*Target{bootTarget, dataTarget} {
@@ -171,8 +171,8 @@ func (t *Target) Partition(bd *blockdevice.BlockDevice) (err error) {
// EFI System Partition // EFI System Partition
typeID := "C12A7328-F81F-11D2-BA4B-00A0C93EC93B" typeID := "C12A7328-F81F-11D2-BA4B-00A0C93EC93B"
opts = append(opts, partition.WithPartitionType(typeID), partition.WithPartitionName(t.Label), partition.WithLegacyBIOSBootableAttribute(true)) opts = append(opts, partition.WithPartitionType(typeID), partition.WithPartitionName(t.Label), partition.WithLegacyBIOSBootableAttribute(true))
case constants.DataPartitionLabel: case constants.EphemeralPartitionLabel:
// Data Partition // Ephemeral Partition
typeID := "AF3DC60F-8384-7247-8E79-3D69D8477DE4" typeID := "AF3DC60F-8384-7247-8E79-3D69D8477DE4"
opts = append(opts, partition.WithPartitionType(typeID), partition.WithPartitionName(t.Label)) opts = append(opts, partition.WithPartitionType(typeID), partition.WithPartitionName(t.Label))
default: default:

View File

@@ -147,7 +147,7 @@ install:
boot: boot:
device: /dev/sda device: /dev/sda
size: 1024000000 size: 1024000000
data: ephemeral:
device: /dev/sda device: /dev/sda
size: 1024000000 size: 1024000000
` `

View File

@@ -14,16 +14,16 @@ import (
// VerifyDataDevice verifies the supplied data device options. // VerifyDataDevice verifies the supplied data device options.
func VerifyDataDevice(data *userdata.UserData) (err error) { func VerifyDataDevice(data *userdata.UserData) (err error) {
// Set data device to root device if not specified // Set data device to root device if not specified
if data.Install.Data == nil { if data.Install.Ephemeral == nil {
data.Install.Data = &userdata.InstallDevice{} data.Install.Ephemeral = &userdata.InstallDevice{}
} }
if data.Install.Data.Device == "" { if data.Install.Ephemeral.Device == "" {
return errors.New("a data device is required") return errors.New("an ephemeral device is required")
} }
if !data.Install.Force { if !data.Install.Force {
if err = VerifyDiskAvailability(constants.DataPartitionLabel); err != nil { if err = VerifyDiskAvailability(constants.EphemeralPartitionLabel); err != nil {
return errors.Wrap(err, "failed to verify disk availability") return errors.Wrap(err, "failed to verify disk availability")
} }
} }
@@ -41,7 +41,7 @@ func VerifyBootDevice(data *userdata.UserData) (err error) {
// We can safely assume data device is defined at this point // We can safely assume data device is defined at this point
// because VerifyDataDevice should have been called first in // because VerifyDataDevice should have been called first in
// in the chain // in the chain
data.Install.Boot.Device = data.Install.Data.Device data.Install.Boot.Device = data.Install.Ephemeral.Device
} }
if data.Install.Boot.Size == 0 { if data.Install.Boot.Size == 0 {

View File

@@ -21,11 +21,11 @@ import (
// filesystems. // filesystems.
func MountPointsForDevice(devpath string) (mountpoints *mount.Points, err error) { func MountPointsForDevice(devpath string) (mountpoints *mount.Points, err error) {
mountpoints = mount.NewMountPoints() mountpoints = mount.NewMountPoints()
for _, name := range []string{constants.DataPartitionLabel, constants.BootPartitionLabel} { for _, name := range []string{constants.EphemeralPartitionLabel, constants.BootPartitionLabel} {
var target string var target string
switch name { switch name {
case constants.DataPartitionLabel: case constants.EphemeralPartitionLabel:
target = constants.DataMountPoint target = constants.EphemeralMountPoint
case constants.BootPartitionLabel: case constants.BootPartitionLabel:
target = constants.BootMountPoint target = constants.BootMountPoint
} }
@@ -51,12 +51,12 @@ func MountPointsForDevice(devpath string) (mountpoints *mount.Points, err error)
// we want to grow the data filesystem. // we want to grow the data filesystem.
func MountPointsFromLabels() (mountpoints *mount.Points, err error) { func MountPointsFromLabels() (mountpoints *mount.Points, err error) {
mountpoints = mount.NewMountPoints() mountpoints = mount.NewMountPoints()
for _, name := range []string{constants.DataPartitionLabel, constants.BootPartitionLabel} { for _, name := range []string{constants.EphemeralPartitionLabel, constants.BootPartitionLabel} {
opts := []mount.Option{} opts := []mount.Option{}
var target string var target string
switch name { switch name {
case constants.DataPartitionLabel: case constants.EphemeralPartitionLabel:
target = constants.DataMountPoint target = constants.EphemeralMountPoint
opts = append(opts, mount.WithResize(true)) opts = append(opts, mount.WithResize(true))
case constants.BootPartitionLabel: case constants.BootPartitionLabel:
target = constants.BootMountPoint target = constants.BootMountPoint

View File

@@ -188,7 +188,7 @@ func (p *Point) ResizePartition() (err error) {
} }
for _, partition := range pt.Partitions() { for _, partition := range pt.Partitions() {
if partition.(*gptpartition.Partition).Name == constants.DataPartitionLabel { if partition.(*gptpartition.Partition).Name == constants.EphemeralPartitionLabel {
if err := pt.Resize(partition); err != nil { if err := pt.Resize(partition); err != nil {
return err return err
} }

View File

@@ -44,13 +44,13 @@ const (
// the boot path. // the boot path.
BootMountPoint = "/boot" BootMountPoint = "/boot"
// DataPartitionLabel is the label of the partition to use for mounting at // EphemeralPartitionLabel is the label of the partition to use for
// the data path. // mounting at the data path.
DataPartitionLabel = "DATA" EphemeralPartitionLabel = "EPHEMERAL"
// DataMountPoint is the label of the partition to use for mounting at // EphemeralMountPoint is the label of the partition to use for mounting at
// the data path. // the data path.
DataMountPoint = "/var" EphemeralMountPoint = "/var"
// RootMountPoint is the label of the partition to use for mounting at // RootMountPoint is the label of the partition to use for mounting at
// the root path. // the root path.

View File

@@ -7,7 +7,7 @@ package userdata
// Install represents the installation options for preparing a node. // Install represents the installation options for preparing a node.
type Install struct { type Install struct {
Boot *BootDevice `yaml:"boot,omitempty"` Boot *BootDevice `yaml:"boot,omitempty"`
Data *InstallDevice `yaml:"data,omitempty"` Ephemeral *InstallDevice `yaml:"ephemeral,omitempty"`
ExtraDevices []*ExtraDevice `yaml:"extraDevices,omitempty"` ExtraDevices []*ExtraDevice `yaml:"extraDevices,omitempty"`
ExtraKernelArgs []string `yaml:"extraKernelArgs,omitempty"` ExtraKernelArgs []string `yaml:"extraKernelArgs,omitempty"`
Wipe bool `yaml:"wipe"` Wipe bool `yaml:"wipe"`

View File

@@ -141,11 +141,7 @@ install:
force: true force: true
device: /dev/sda device: /dev/sda
size: 1024000000 size: 1024000000
root: ephemeral:
force: true
device: /dev/sda
size: 1024000000
data:
force: true force: true
device: /dev/sda device: /dev/sda
size: 1024000000 size: 1024000000