Skip to content

Commit

Permalink
Allow configuration of max snapshots during install (#851)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Mazzotti <andrea.mazzotti@suse.com>
  • Loading branch information
anmazzotti authored Sep 25, 2024
1 parent 7ba0a1e commit 3df501d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
11 changes: 9 additions & 2 deletions .obs/chartfile/elemental-operator-crds-helm/templates/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -867,12 +867,19 @@ spec:
type: boolean
snapshotter:
default:
maxSnaps: 2
type: loopdevice
properties:
maxSnaps:
default: 2
description: MaxSnaps sets the maximum amount of snapshots
to keep
minimum: 2
type: integer
type:
default: loopdevice
description: Type sets the snapshotter type a new
installation, available options are 'loopdevice'
description: Type sets the snapshotter type for a
new installation, available options are 'loopdevice'
and 'btrfs'
type: string
type: object
Expand Down
9 changes: 7 additions & 2 deletions api/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,20 @@ type Install struct {
// +optional
ConfigDir string `json:"config-dir,omitempty" yaml:"config-dir,omitempty"`
// +optional
// +kubebuilder:default:={"type": "loopdevice"}
// +kubebuilder:default:={"type": "loopdevice", "maxSnaps": 2}
Snapshotter SnapshotterConfig `json:"snapshotter,omitempty" yaml:"snapshotter,omitempty"`
}

type SnapshotterConfig struct {
// Type sets the snapshotter type a new installation, available options are 'loopdevice' and 'btrfs'
// Type sets the snapshotter type for a new installation, available options are 'loopdevice' and 'btrfs'
// +optional
// +kubebuilder:default:=loopdevice
Type string `json:"type,omitempty" yaml:"type,omitempty"`
// MaxSnaps sets the maximum amount of snapshots to keep
// +optional
// +kubebuilder:default:=2
// +kubebuilder:validation:Minimum:=2
MaxSnaps int `json:"maxSnaps,omitempty" yaml:"maxSnaps,omitempty"`
}

type Reset struct {
Expand Down
11 changes: 9 additions & 2 deletions config/crd/bases/elemental.cattle.io_machineregistrations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,19 @@ spec:
type: boolean
snapshotter:
default:
maxSnaps: 2
type: loopdevice
properties:
maxSnaps:
default: 2
description: MaxSnaps sets the maximum amount of snapshots
to keep
minimum: 2
type: integer
type:
default: loopdevice
description: Type sets the snapshotter type a new
installation, available options are 'loopdevice'
description: Type sets the snapshotter type for a
new installation, available options are 'loopdevice'
and 'btrfs'
type: string
type: object
Expand Down
1 change: 1 addition & 0 deletions pkg/elementalcli/elementalcli.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func mapToInstallEnv(conf elementalv1.Install) []string {
variables = append(variables, formatEV("ELEMENTAL_REBOOT", strconv.FormatBool(conf.Reboot)))
variables = append(variables, formatEV("ELEMENTAL_EJECT_CD", strconv.FormatBool(conf.EjectCD)))
variables = append(variables, formatEV("ELEMENTAL_SNAPSHOTTER_TYPE", conf.Snapshotter.Type))
variables = append(variables, formatEV("ELEMENTAL_SNAPSHOTTER_MAX_SNAPS", fmt.Sprintf("%d", conf.Snapshotter.MaxSnaps)))
variables = append(variables, formatEV("ELEMENTAL_CLOUD_INIT_PATHS", TempCloudInitDir))
return variables
}
Expand Down

0 comments on commit 3df501d

Please sign in to comment.