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{
Force: true,
ExtraKernelArgs: extraKernelArgs,
Data: &userdata.InstallDevice{
Ephemeral: &userdata.InstallDevice{
Device: device,
Size: 16 * 1024 * 1024,
},

View File

@@ -1,5 +1,5 @@
---
title: User Data
title: User ephemeral
date: 2019-06-21T19:40:55-07:00
draft: false
weight: 20
@@ -369,7 +369,8 @@ install:
**Note** The asset name **must** be named `initramfs.xz`.
### Data
### Ephemeral
#### Device
``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
install:
data:
ephemeral:
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
install:
data:
ephemeral:
size: <size in bytes>
```

View File

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

View File

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

View File

@@ -33,7 +33,7 @@ func (suite *validateSuite) TestVerifyDevice() {
// defaults.
data.Install.Boot = nil
suite.Require().NoError(VerifyBootDevice(data))
data.Install.Data = &userdata.InstallDevice{
data.Install.Ephemeral = &userdata.InstallDevice{
Device: "/dev/sda",
}
suite.Require().NoError(VerifyDataDevice(data))
@@ -101,7 +101,7 @@ install:
boot:
device: /dev/sda
size: 1024000000
data:
ephemeral:
device: /dev/sda
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
// required.
if manifest.Targets[data.Install.Data.Device] == nil {
manifest.Targets[data.Install.Data.Device] = []*Target{}
if manifest.Targets[data.Install.Ephemeral.Device] == nil {
manifest.Targets[data.Install.Ephemeral.Device] = []*Target{}
}
var bootTarget *Target
@@ -89,12 +89,12 @@ func NewManifest(data *userdata.UserData) (manifest *Manifest) {
}
dataTarget := &Target{
Device: data.Install.Data.Device,
Label: constants.DataPartitionLabel,
Size: data.Install.Data.Size,
Device: data.Install.Ephemeral.Device,
Label: constants.EphemeralPartitionLabel,
Size: data.Install.Ephemeral.Size,
Force: data.Install.Force,
Test: false,
MountPoint: constants.DataMountPoint,
MountPoint: constants.EphemeralMountPoint,
}
for _, target := range []*Target{bootTarget, dataTarget} {
@@ -171,8 +171,8 @@ func (t *Target) Partition(bd *blockdevice.BlockDevice) (err error) {
// EFI System Partition
typeID := "C12A7328-F81F-11D2-BA4B-00A0C93EC93B"
opts = append(opts, partition.WithPartitionType(typeID), partition.WithPartitionName(t.Label), partition.WithLegacyBIOSBootableAttribute(true))
case constants.DataPartitionLabel:
// Data Partition
case constants.EphemeralPartitionLabel:
// Ephemeral Partition
typeID := "AF3DC60F-8384-7247-8E79-3D69D8477DE4"
opts = append(opts, partition.WithPartitionType(typeID), partition.WithPartitionName(t.Label))
default:

View File

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

View File

@@ -14,16 +14,16 @@ import (
// VerifyDataDevice verifies the supplied data device options.
func VerifyDataDevice(data *userdata.UserData) (err error) {
// Set data device to root device if not specified
if data.Install.Data == nil {
data.Install.Data = &userdata.InstallDevice{}
if data.Install.Ephemeral == nil {
data.Install.Ephemeral = &userdata.InstallDevice{}
}
if data.Install.Data.Device == "" {
return errors.New("a data device is required")
if data.Install.Ephemeral.Device == "" {
return errors.New("an ephemeral device is required")
}
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")
}
}
@@ -41,7 +41,7 @@ func VerifyBootDevice(data *userdata.UserData) (err error) {
// We can safely assume data device is defined at this point
// because VerifyDataDevice should have been called first in
// 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 {

View File

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

View File

@@ -188,7 +188,7 @@ func (p *Point) ResizePartition() (err error) {
}
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 {
return err
}

View File

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

View File

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

View File

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