Skip to content

Commit

Permalink
Allow growvols args to be overridden
Browse files Browse the repository at this point in the history
  • Loading branch information
olliewalsh committed Jun 15, 2023
1 parent 93a8f25 commit ce2a0d3
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 2 deletions.
3 changes: 3 additions & 0 deletions api/v1beta1/openstackbaremetalset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ type OpenStackBaremetalSetSpec struct {
// Note that subsequent TripleO deployment will overwrite these values
BootstrapDNS []string `json:"bootstrapDns,omitempty"`
DNSSearchDomains []string `json:"dnsSearchDomains,omitempty"`
// GrowvolsArgs - arguments to the growvols command to expand logical volumes after provisioning
// Note requires the command to exist on the base image
GrowvolsArgs []string `json:growvolsArgs, omitempty`

Check failure on line 59 in api/v1beta1/openstackbaremetalset_types.go

View workflow job for this annotation

GitHub Actions / github (govet, golint and gotest)

struct field tag `json:growvolsArgs, omitempty` not compatible with reflect.StructTag.Get: bad syntax for struct tag value
}

// OpenStackBaremetalSetStatus defines the observed state of OpenStackBaremetalSet
Expand Down
3 changes: 3 additions & 0 deletions api/v1beta1/openstackvmset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ type OpenStackVMSetSpec struct {
// Note that subsequent TripleO deployment will overwrite these values
BootstrapDNS []string `json:"bootstrapDns,omitempty"`
DNSSearchDomains []string `json:"dnsSearchDomains,omitempty"`
// GrowvolsArgs - arguments to the growvols command to expand logical volumes after provisioning
// Note requires the command to exist on the base image
GrowvolsArgs []string `json:growvolsArgs, omitempty`

Check failure on line 79 in api/v1beta1/openstackvmset_types.go

View workflow job for this annotation

GitHub Actions / github (govet, golint and gotest)

struct field tag `json:growvolsArgs, omitempty` not compatible with reflect.StructTag.Get: bad syntax for struct tag value
}

// OpenStackVMSetStatus defines the observed state of OpenStackVMSet
Expand Down
8 changes: 8 additions & 0 deletions controllers/openstackbaremetalset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,14 @@ func (r *OpenStackBaremetalSetReconciler) baremetalHostProvision(
templateParameters["Hostname"] = bmhStatus.Hostname
templateParameters["DomainName"] = osNetCfg.Spec.DomainName

if instance.Spec.GrowvolsArgs != nil && len(instance.Spec.GrowvolsArgs) > 0 {
templateParameters["GrowvolsArgs"] = instance.Spec.GrowvolsArgs

} else {
// use default for the role name
templateParameters["GrowvolsArgs"] = GetRoleGrowvolsArgs(instance.Spec.RoleName)

Check failure on line 916 in controllers/openstackbaremetalset_controller.go

View workflow job for this annotation

GitHub Actions / github (golangci)

undefined: GetRoleGrowvolsArgs (typecheck)
}

//
// use same NodeRootPassword paremater as tripleo have
//
Expand Down
8 changes: 8 additions & 0 deletions controllers/openstackvmset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,14 @@ func (r *OpenStackVMSetReconciler) Reconcile(ctx context.Context, req ctrl.Reque
//
templateParameters["DomainName"] = osNetCfg.Spec.DomainName

if instance.Spec.GrowvolsArgs != nil && len(instance.Spec.GrowvolsArgs) > 0 {

Check failure on line 353 in controllers/openstackvmset_controller.go

View workflow job for this annotation

GitHub Actions / github (golangci)

instance.Spec.GrowvolsArgs undefined (type "github.com/openstack-k8s-operators/osp-director-operator/api/v1beta2".OpenStackVMSetSpec has no field or method GrowvolsArgs) (typecheck)
templateParameters["GrowvolsArgs"] = instance.Spec.GrowvolsArgs

} else {
// use default for the role name
templateParameters["GrowvolsArgs"] = GetRoleGrowvolsArgs(instance.Spec.RoleName)
}

//
// check if PasswordSecret got specified and if it exists before creating the controlplane
//
Expand Down
33 changes: 33 additions & 0 deletions pkg/common/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,36 @@ const (
// TripleORolesDataFile -
TripleORolesDataFile = "roles_data.yaml"
)

func GetRoleGrowvolsArgs(role string) string[] {

Check failure on line 55 in pkg/common/const.go

View workflow job for this annotation

GitHub Actions / github (golangci)

expected type argument list (typecheck)

Check failure on line 55 in pkg/common/const.go

View workflow job for this annotation

GitHub Actions / github (govet, golint and gotest)

syntax error: unexpected ], expecting type
if role == "Controller" {
return string[]{

Check failure on line 57 in pkg/common/const.go

View workflow job for this annotation

GitHub Actions / github (golangci)

expected operand, found ']' (typecheck)

Check failure on line 57 in pkg/common/const.go

View workflow job for this annotation

GitHub Actions / github (govet, golint and gotest)

syntax error: unexpected ], expecting operand
"/=8GB",
"/tmp=1GB",
"/var/log=10GB",
"/var/log/audit=2GB",
"/home=1GB",
"/var=90%",
"/srv=10%"

Check failure on line 64 in pkg/common/const.go

View workflow job for this annotation

GitHub Actions / github (golangci)

missing ',' before newline in composite literal (typecheck)

Check failure on line 64 in pkg/common/const.go

View workflow job for this annotation

GitHub Actions / github (govet, golint and gotest)

syntax error: unexpected newline in composite literal; possibly missing comma or }
}
}
if role == "ObjectStorage" {
return string[]{

Check failure on line 68 in pkg/common/const.go

View workflow job for this annotation

GitHub Actions / github (golangci)

expected operand, found ']' (typecheck)

Check failure on line 68 in pkg/common/const.go

View workflow job for this annotation

GitHub Actions / github (govet, golint and gotest)

syntax error: unexpected ], expecting operand
"/=8GB",
"/tmp=1GB",
"/var/log=10GB",
"/var/log/audit=2GB",
"/home=1GB",
"/var=10%",
"/srv=90%"

Check failure on line 75 in pkg/common/const.go

View workflow job for this annotation

GitHub Actions / github (golangci)

missing ',' before newline in composite literal (typecheck)

Check failure on line 75 in pkg/common/const.go

View workflow job for this annotation

GitHub Actions / github (govet, golint and gotest)

syntax error: unexpected newline in composite literal; possibly missing comma or }
}
}
return string[]{

Check failure on line 78 in pkg/common/const.go

View workflow job for this annotation

GitHub Actions / github (golangci)

expected operand, found ']' (typecheck)

Check failure on line 78 in pkg/common/const.go

View workflow job for this annotation

GitHub Actions / github (govet, golint and gotest)

syntax error: unexpected ], expecting operand
"/=8GB",
"/tmp=1GB",
"/var/log=10GB",
"/var/log/audit=2GB",
"/home=1GB",
"/var=100%"

Check failure on line 84 in pkg/common/const.go

View workflow job for this annotation

GitHub Actions / github (golangci)

missing ',' before newline in composite literal (typecheck)

Check failure on line 84 in pkg/common/const.go

View workflow job for this annotation

GitHub Actions / github (govet, golint and gotest)

syntax error: unexpected newline in composite literal; possibly missing comma or }
}
}
2 changes: 1 addition & 1 deletion templates/baremetalset/cloudinit/userdata
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ bootcmd:
- set -x; if [ -e /boot/loader/entries/ffffffffffffffffffffffffffffffff-* ]; then MACHINEID=$(cat /etc/machine-id) && rename "ffffffffffffffffffffffffffffffff" "$MACHINEID" /boot/loader/entries/ffffffffffffffffffffffffffffffff-* ; fi
runcmd:
# grow volumes on hardened image if command exists
- if [ -e /usr/local/sbin/growvols ]; then /usr/local/sbin/growvols --yes /=8GB /tmp=1GB /var/log=10GB /var/log/audit=2GB /home=1GB /var=100%; fi
- if [ -e /usr/local/sbin/growvols ]; then /usr/local/sbin/growvols --yes {{ range .GrowvolsArgs}}{{.|trim}} {{end}}; fi
2 changes: 1 addition & 1 deletion templates/vmset/cloudinit/userdata
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ runcmd:
# Disable IPv6 autoconf per default, we only want the ooo static IP config
- set -x; echo 'IPV6_AUTOCONF=no' >> /etc/sysconfig/network
# grow volumes on hardened image if command exists
- if [ -e /usr/local/sbin/growvols ]; then /usr/local/sbin/growvols --yes /=8GB /tmp=1GB /var/log=10GB /var/log/audit=2GB /home=1GB /var=100%; fi
- if [ -e /usr/local/sbin/growvols ]; then /usr/local/sbin/growvols --yes {{ range .GrowvolsArgs}}{{.|trim}} {{end}}; fi
{{- end }}

0 comments on commit ce2a0d3

Please sign in to comment.