mirror of
https://github.com/siderolabs/talos.git
synced 2025-10-28 06:51:34 +01:00
chore: allow not preallocated disks for QEMU cluster
Preallocation still done by default for correct max usage estimates, but in development environment it could be beneficial not to use up that space, so I added a flag to disable preallocation Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com> Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
This commit is contained in:
parent
0bddfea818
commit
4575dd8e74
@ -76,6 +76,7 @@ const (
|
||||
networkCIDRFlag = "cidr"
|
||||
nameserversFlag = "nameservers"
|
||||
clusterDiskSizeFlag = "disk"
|
||||
clusterDiskPreallocateFlag = "disk-preallocate"
|
||||
clusterDisksFlag = "user-disk"
|
||||
customCNIUrlFlag = "custom-cni-url"
|
||||
talosVersionFlag = "talos-version"
|
||||
@ -124,6 +125,7 @@ var (
|
||||
controlPlaneMemory int
|
||||
workersMemory int
|
||||
clusterDiskSize int
|
||||
clusterDiskPreallocate bool
|
||||
clusterDisks []string
|
||||
extraDisks int
|
||||
extraDiskSize int
|
||||
@ -796,7 +798,8 @@ func create(ctx context.Context, flags *pflag.FlagSet) error {
|
||||
// append extra disks
|
||||
for i := 0; i < extraDisks; i++ {
|
||||
disks = append(disks, &provision.Disk{
|
||||
Size: uint64(extraDiskSize) * 1024 * 1024,
|
||||
Size: uint64(extraDiskSize) * 1024 * 1024,
|
||||
SkipPreallocate: !clusterDiskPreallocate,
|
||||
})
|
||||
}
|
||||
|
||||
@ -997,7 +1000,8 @@ func getDisks() ([]*provision.Disk, error) {
|
||||
// should have at least a single primary disk
|
||||
disks := []*provision.Disk{
|
||||
{
|
||||
Size: uint64(clusterDiskSize) * 1024 * 1024,
|
||||
Size: uint64(clusterDiskSize) * 1024 * 1024,
|
||||
SkipPreallocate: !clusterDiskPreallocate,
|
||||
},
|
||||
}
|
||||
|
||||
@ -1042,8 +1046,9 @@ func getDisks() ([]*provision.Disk, error) {
|
||||
|
||||
disks = append(disks, &provision.Disk{
|
||||
// add 1 MB to make extra room for GPT and alignment
|
||||
Size: diskSize + 2*1024*1024,
|
||||
Partitions: diskPartitions,
|
||||
Size: diskSize + 2*1024*1024,
|
||||
Partitions: diskPartitions,
|
||||
SkipPreallocate: !clusterDiskPreallocate,
|
||||
})
|
||||
}
|
||||
|
||||
@ -1091,6 +1096,7 @@ func init() {
|
||||
createCmd.Flags().IntVar(&controlPlaneMemory, "memory", 2048, "the limit on memory usage in MB (each control plane/VM)")
|
||||
createCmd.Flags().IntVar(&workersMemory, "memory-workers", 2048, "the limit on memory usage in MB (each worker/VM)")
|
||||
createCmd.Flags().IntVar(&clusterDiskSize, clusterDiskSizeFlag, 6*1024, "default limit on disk size in MB (each VM)")
|
||||
createCmd.Flags().BoolVar(&clusterDiskPreallocate, clusterDiskPreallocateFlag, true, "whether disk space should be preallocated")
|
||||
createCmd.Flags().StringSliceVar(&clusterDisks, clusterDisksFlag, []string{}, "list of disks to create for each VM in format: <mount_point1>:<size1>:<mount_point2>:<size2>")
|
||||
createCmd.Flags().IntVar(&extraDisks, "extra-disks", 0, "number of extra disks to create for each worker VM")
|
||||
createCmd.Flags().IntVar(&extraDiskSize, "extra-disks-size", 5*1024, "default limit on disk size in MB (each VM)")
|
||||
|
||||
@ -42,8 +42,10 @@ func (p *Provisioner) CreateDisks(state *State, nodeReq provision.NodeRequest) (
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = syscall.Fallocate(int(diskF.Fd()), 0, 0, int64(disk.Size)); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "WARNING: failed to preallocate disk space for %q (size %d): %s", diskPath, disk.Size, err)
|
||||
if !disk.SkipPreallocate {
|
||||
if err = syscall.Fallocate(int(diskF.Fd()), 0, 0, int64(disk.Size)); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "WARNING: failed to preallocate disk space for %q (size %d): %s", diskPath, disk.Size, err)
|
||||
}
|
||||
}
|
||||
|
||||
diskPaths[i] = diskPath
|
||||
|
||||
@ -150,6 +150,8 @@ func (reqs NodeRequests) PXENodes() (nodes []NodeRequest) {
|
||||
type Disk struct {
|
||||
// Size in bytes.
|
||||
Size uint64
|
||||
// Whether to skip preallocating the disk space.
|
||||
SkipPreallocate bool
|
||||
// Partitions represents the list of partitions.
|
||||
Partitions []*v1alpha1.DiskPartition
|
||||
}
|
||||
|
||||
@ -112,6 +112,7 @@ talosctl cluster create [flags]
|
||||
--disk int default limit on disk size in MB (each VM) (default 6144)
|
||||
--disk-encryption-key-types stringArray encryption key types to use for disk encryption (uuid, kms) (default [uuid])
|
||||
--disk-image-path string disk image to use
|
||||
--disk-preallocate whether disk space should be preallocated (default true)
|
||||
--dns-domain string the dns domain to use for cluster (default "cluster.local")
|
||||
--docker-disable-ipv6 skip enabling IPv6 in containers (Docker only)
|
||||
--docker-host-ip string Host IP to forward exposed ports to (Docker provisioner only) (default "0.0.0.0")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user