Skip to content
This repository has been archived by the owner on Apr 20, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/0.0.4'
Browse files Browse the repository at this point in the history
Release: com.io7m.waxmill 0.0.4
Change: Fix issue creating ZFS volumes (Ticket: #28)
  • Loading branch information
io7m committed Jul 28, 2020
2 parents c1d519e + d07360a commit eb160f5
Show file tree
Hide file tree
Showing 28 changed files with 557 additions and 54 deletions.
13 changes: 11 additions & 2 deletions README-CHANGES.xml
Expand Up @@ -11,7 +11,7 @@
<c:change date="2020-07-11T00:00:00+00:00" summary="Add the vm-kill command"/>
</c:changes>
</c:release>
<c:release date="2020-07-25T09:00:46+00:00" ticket-system="com.github.io7m.waxmill" version="0.0.3">
<c:release date="2020-07-25T00:00:00+00:00" ticket-system="com.github.io7m.waxmill" version="0.0.3">
<c:changes>
<c:change date="2020-07-25T00:00:00+00:00" summary="Add support for interface groups">
<c:tickets>
Expand All @@ -28,13 +28,22 @@
<c:ticket id="26"/>
</c:tickets>
</c:change>
<c:change date="2020-07-25T09:00:46+00:00" summary="Automatically create virtual machine filesystems">
<c:change date="2020-07-25T00:00:00+00:00" summary="Automatically create virtual machine filesystems">
<c:tickets>
<c:ticket id="23"/>
</c:tickets>
</c:change>
</c:changes>
</c:release>
<c:release date="2020-07-28T15:55:45+00:00" ticket-system="com.github.io7m.waxmill" version="0.0.4">
<c:changes>
<c:change date="2020-07-28T15:55:45+00:00" summary="Fix issue creating ZFS volumes">
<c:tickets>
<c:ticket id="28"/>
</c:tickets>
</c:change>
</c:changes>
</c:release>
</c:releases>
<c:ticket-systems>
<c:ticket-system default="true" id="com.github.io7m.waxmill" url="https://www.github.com/io7m/waxmill/issues/"/>
Expand Down
2 changes: 1 addition & 1 deletion com.io7m.waxmill.boot/pom.xml
Expand Up @@ -9,7 +9,7 @@
<parent>
<artifactId>com.io7m.waxmill</artifactId>
<groupId>com.io7m.waxmill</groupId>
<version>0.0.3</version>
<version>0.0.4</version>
</parent>

<artifactId>com.io7m.waxmill.boot</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion com.io7m.waxmill.client.api/pom.xml
Expand Up @@ -9,7 +9,7 @@
<parent>
<artifactId>com.io7m.waxmill</artifactId>
<groupId>com.io7m.waxmill</groupId>
<version>0.0.3</version>
<version>0.0.4</version>
</parent>

<artifactId>com.io7m.waxmill.client.api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion com.io7m.waxmill.client.vanilla/pom.xml
Expand Up @@ -9,7 +9,7 @@
<parent>
<artifactId>com.io7m.waxmill</artifactId>
<groupId>com.io7m.waxmill</groupId>
<version>0.0.3</version>
<version>0.0.4</version>
</parent>

<artifactId>com.io7m.waxmill.client.vanilla</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion com.io7m.waxmill.cmdline/pom.xml
Expand Up @@ -9,7 +9,7 @@
<parent>
<artifactId>com.io7m.waxmill</artifactId>
<groupId>com.io7m.waxmill</groupId>
<version>0.0.3</version>
<version>0.0.4</version>
</parent>

<artifactId>com.io7m.waxmill.cmdline</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion com.io7m.waxmill.database.api/pom.xml
Expand Up @@ -9,7 +9,7 @@
<parent>
<artifactId>com.io7m.waxmill</artifactId>
<groupId>com.io7m.waxmill</groupId>
<version>0.0.3</version>
<version>0.0.4</version>
</parent>

<artifactId>com.io7m.waxmill.database.api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion com.io7m.waxmill.database.vanilla/pom.xml
Expand Up @@ -9,7 +9,7 @@
<parent>
<artifactId>com.io7m.waxmill</artifactId>
<groupId>com.io7m.waxmill</groupId>
<version>0.0.3</version>
<version>0.0.4</version>
</parent>

<artifactId>com.io7m.waxmill.database.vanilla</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion com.io7m.waxmill.documentation/pom.xml
Expand Up @@ -9,7 +9,7 @@
<parent>
<artifactId>com.io7m.waxmill</artifactId>
<groupId>com.io7m.waxmill</groupId>
<version>0.0.3</version>
<version>0.0.4</version>
</parent>

<artifactId>com.io7m.waxmill.documentation</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion com.io7m.waxmill.exceptions/pom.xml
Expand Up @@ -9,7 +9,7 @@
<parent>
<artifactId>com.io7m.waxmill</artifactId>
<groupId>com.io7m.waxmill</groupId>
<version>0.0.3</version>
<version>0.0.4</version>
</parent>

<artifactId>com.io7m.waxmill.exceptions</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion com.io7m.waxmill.locks/pom.xml
Expand Up @@ -9,7 +9,7 @@
<parent>
<artifactId>com.io7m.waxmill</artifactId>
<groupId>com.io7m.waxmill</groupId>
<version>0.0.3</version>
<version>0.0.4</version>
</parent>

<artifactId>com.io7m.waxmill.locks</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion com.io7m.waxmill.machines/pom.xml
Expand Up @@ -9,7 +9,7 @@
<parent>
<artifactId>com.io7m.waxmill</artifactId>
<groupId>com.io7m.waxmill</groupId>
<version>0.0.3</version>
<version>0.0.4</version>
</parent>

<artifactId>com.io7m.waxmill.machines</artifactId>
Expand Down
Expand Up @@ -52,11 +52,25 @@ public static Path determineZFSVolumePath(

return machineDirectory
.resolve(machineId.toString())
.resolve(String.format(
"disk-%d_%d_%d",
Integer.valueOf(deviceID.busID()),
Integer.valueOf(deviceID.slotID()),
Integer.valueOf(deviceID.functionID())
));
.resolve(determineZFSVolumeName(deviceID));
}

/**
* Derive the ZFS volume name for the given device ID.
*
* @param deviceID The device ID
*
* @return The volume name
*/

public static String determineZFSVolumeName(
final WXMDeviceSlot deviceID)
{
return String.format(
"disk-%d_%d_%d",
Integer.valueOf(deviceID.busID()),
Integer.valueOf(deviceID.slotID()),
Integer.valueOf(deviceID.functionID())
);
}
}
2 changes: 1 addition & 1 deletion com.io7m.waxmill.parser.api/pom.xml
Expand Up @@ -9,7 +9,7 @@
<parent>
<artifactId>com.io7m.waxmill</artifactId>
<groupId>com.io7m.waxmill</groupId>
<version>0.0.3</version>
<version>0.0.4</version>
</parent>

<artifactId>com.io7m.waxmill.parser.api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion com.io7m.waxmill.process.api/pom.xml
Expand Up @@ -9,7 +9,7 @@
<parent>
<artifactId>com.io7m.waxmill</artifactId>
<groupId>com.io7m.waxmill</groupId>
<version>0.0.3</version>
<version>0.0.4</version>
</parent>

<artifactId>com.io7m.waxmill.process.api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion com.io7m.waxmill.process.posix/pom.xml
Expand Up @@ -9,7 +9,7 @@
<parent>
<artifactId>com.io7m.waxmill</artifactId>
<groupId>com.io7m.waxmill</groupId>
<version>0.0.3</version>
<version>0.0.4</version>
</parent>

<artifactId>com.io7m.waxmill.process.posix</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion com.io7m.waxmill.realize/pom.xml
Expand Up @@ -9,7 +9,7 @@
<parent>
<artifactId>com.io7m.waxmill</artifactId>
<groupId>com.io7m.waxmill</groupId>
<version>0.0.3</version>
<version>0.0.4</version>
</parent>

<artifactId>com.io7m.waxmill.realize</artifactId>
Expand Down
Expand Up @@ -16,6 +16,8 @@

package com.io7m.waxmill.realize;

import com.io7m.waxmill.exceptions.WXMException;

/**
* A realization operation.
*/
Expand All @@ -29,5 +31,6 @@ public interface WXMRealizationType
* @return A list of instructions
*/

WXMRealizationInstructions evaluate();
WXMRealizationInstructions evaluate()
throws WXMException;
}
Expand Up @@ -18,6 +18,7 @@

import com.io7m.junreachable.UnimplementedCodeException;
import com.io7m.waxmill.client.api.WXMClientConfiguration;
import com.io7m.waxmill.exceptions.WXMException;
import com.io7m.waxmill.machines.WXMDeviceAHCIDisk;
import com.io7m.waxmill.machines.WXMDeviceType;
import com.io7m.waxmill.machines.WXMDeviceVirtioBlockStorage;
Expand Down Expand Up @@ -84,6 +85,7 @@ public static WXMRealizationType create(

@Override
public WXMRealizationInstructions evaluate()
throws WXMException
{
final var builder = WXMRealizationInstructions.builder();

Expand Down Expand Up @@ -129,6 +131,7 @@ public WXMRealizationInstructions evaluate()
private void evaluateAHCIDisk(
final WXMRealizationInstructions.Builder builder,
final WXMDeviceAHCIDisk device)
throws WXMException
{
final var backend = device.backend();
switch (backend.kind()) {
Expand Down Expand Up @@ -163,6 +166,7 @@ private void evaluateFile(
private void evaluateVirtioBlock(
final WXMRealizationInstructions.Builder builder,
final WXMDeviceVirtioBlockStorage device)
throws WXMException
{
final var backend = device.backend();
switch (backend.kind()) {
Expand All @@ -184,6 +188,7 @@ private void evaluateZFSVolume(
final WXMRealizationInstructions.Builder builder,
final WXMDeviceType device,
final WXMStorageBackendZFSVolume zfs)
throws WXMException
{
builder.addSteps(
new WXMZFSVolumeCheck(
Expand Down
Expand Up @@ -96,12 +96,11 @@ public void execute(

LOG.info("checking if {} is a directory", path);

if (Files.isDirectory(path)) {
LOG.info("{} is a directory", path);
return;
}

if (Files.exists(path)) {
if (Files.isDirectory(path)) {
LOG.info("{} is a directory", path);
return;
}
throw new WXMException(this.notADirectory(path));
}

Expand Down
Expand Up @@ -18,6 +18,7 @@

import com.io7m.waxmill.client.api.WXMClientConfiguration;
import com.io7m.waxmill.exceptions.WXMException;
import com.io7m.waxmill.exceptions.WXMExceptionUnsatisfiedRequirement;
import com.io7m.waxmill.machines.WXMDeviceSlot;
import com.io7m.waxmill.machines.WXMDryRun;
import com.io7m.waxmill.machines.WXMStorageBackendZFSVolume;
Expand All @@ -31,9 +32,11 @@

import java.io.IOException;
import java.math.BigInteger;
import java.nio.file.FileStore;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
Expand All @@ -52,6 +55,7 @@ public final class WXMZFSVolumeCheck implements WXMRealizationStepType
private final WXMRealizeMessages messages;
private final WXMStorageBackendZFSVolume zfsVolume;
private final Path volumePath;
private final String volumeCreate;
private List<WXMProcessDescription> processList;

public WXMZFSVolumeCheck(
Expand All @@ -61,6 +65,7 @@ public WXMZFSVolumeCheck(
final UUID inMachineId,
final WXMDeviceSlot inSlot,
final WXMStorageBackendZFSVolume inZFSVolume)
throws WXMException
{
this.clientConfiguration =
Objects.requireNonNull(inClientConfiguration, "clientConfiguration");
Expand All @@ -75,6 +80,9 @@ public WXMZFSVolumeCheck(
final var machineId =
Objects.requireNonNull(inMachineId, "machineId");

this.volumeCreate =
this.determineVolumeCreatePath(machineId);

this.volumePath =
WXMStorageBackends.determineZFSVolumePath(
this.clientConfiguration.virtualMachineRuntimeDirectory(),
Expand All @@ -86,6 +94,40 @@ public WXMZFSVolumeCheck(
this.processList = this.processOpt.map(List::of).orElseGet(List::of);
}

private String determineVolumeCreatePath(
final UUID machineId)
throws WXMException
{
final var base =
this.clientConfiguration.virtualMachineRuntimeDirectory()
.resolve(machineId.toString());

final FileStore store;
try {
store = Files.getFileStore(base);
} catch (final IOException e) {
throw new WXMException(e);
}

final var type = store.type();
if (!"ZFS".equals(type.toUpperCase(Locale.ROOT))) {
throw new WXMExceptionUnsatisfiedRequirement(
this.messages.format(
"errorNotZFS",
machineId,
base,
type
)
);
}

return String.format(
"%s/%s",
store.name(),
WXMStorageBackends.determineZFSVolumeName(this.slot)
);
}

private Optional<WXMProcessDescription> makeProcesses()
{
return this.zfsVolume.expectedSize()
Expand All @@ -94,7 +136,7 @@ private Optional<WXMProcessDescription> makeProcesses()
.addArguments("create")
.addArguments("-V")
.addArguments(size.toString())
.addArguments(this.volumePath.toString())
.addArguments(this.volumeCreate)
.build()
);
}
Expand All @@ -105,7 +147,7 @@ public String description()
final var expectedSize = this.zfsVolume.expectedSize();
return this.messages.format(
"zfsVolumeCheck",
this.volumePath,
this.volumeCreate,
expectedSize.map(WXMZFSVolumeCheck::formatSize)
.orElse("<unspecified>"),
this.slot
Expand Down
Expand Up @@ -44,4 +44,11 @@
]]>
</entry>

<entry key="errorNotZFS"><![CDATA[The specified directory is not a ZFS filesystem.
Machine: {0}
Path: {1}
Filesystem Type: {2}
]]>
</entry>

</properties>
2 changes: 1 addition & 1 deletion com.io7m.waxmill.serializer.api/pom.xml
Expand Up @@ -8,7 +8,7 @@
<parent>
<artifactId>com.io7m.waxmill</artifactId>
<groupId>com.io7m.waxmill</groupId>
<version>0.0.3</version>
<version>0.0.4</version>
</parent>

<artifactId>com.io7m.waxmill.serializer.api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion com.io7m.waxmill.strings.api/pom.xml
Expand Up @@ -9,7 +9,7 @@
<parent>
<artifactId>com.io7m.waxmill</artifactId>
<groupId>com.io7m.waxmill</groupId>
<version>0.0.3</version>
<version>0.0.4</version>
</parent>

<artifactId>com.io7m.waxmill.strings.api</artifactId>
Expand Down

0 comments on commit eb160f5

Please sign in to comment.