Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPLAT-1811: Add vSphere multi disk support #1290

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions cmd/machineset/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func main() {

// Sets up feature gates
defaultMutableGate := feature.DefaultMutableFeatureGate
gateOpts, err := features.NewFeatureGateOptions(defaultMutableGate, apifeatures.SelfManaged, apifeatures.FeatureGateVSphereStaticIPs, apifeatures.FeatureGateMachineAPIMigration)
gateOpts, err := features.NewFeatureGateOptions(defaultMutableGate, apifeatures.SelfManaged, apifeatures.FeatureGateVSphereStaticIPs, apifeatures.FeatureGateMachineAPIMigration, apifeatures.FeatureGateVSphereMultiDisk)
if err != nil {
klog.Fatalf("Error setting up feature gates: %v", err)
}
Expand Down Expand Up @@ -186,7 +186,7 @@ func main() {
log.Fatal(err)
}

machineValidator, err := mapiwebhooks.NewMachineValidator(mgr.GetClient())
machineValidator, err := mapiwebhooks.NewMachineValidator(mgr.GetClient(), defaultMutableGate)
if err != nil {
log.Fatal(err)
}
Expand All @@ -196,7 +196,7 @@ func main() {
log.Fatal(err)
}

machineSetValidator, err := mapiwebhooks.NewMachineSetValidator(mgr.GetClient())
machineSetValidator, err := mapiwebhooks.NewMachineSetValidator(mgr.GetClient(), defaultMutableGate)
if err != nil {
log.Fatal(err)
}
Expand Down
17 changes: 10 additions & 7 deletions cmd/vsphere/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func main() {

// Sets up feature gates
defaultMutableGate := feature.DefaultMutableFeatureGate
gateOpts, err := features.NewFeatureGateOptions(defaultMutableGate, apifeatures.SelfManaged, apifeatures.FeatureGateVSphereStaticIPs, apifeatures.FeatureGateMachineAPIMigration)
gateOpts, err := features.NewFeatureGateOptions(defaultMutableGate, apifeatures.SelfManaged, apifeatures.FeatureGateVSphereStaticIPs, apifeatures.FeatureGateMachineAPIMigration, apifeatures.FeatureGateVSphereMultiDisk)
if err != nil {
klog.Fatalf("Error setting up feature gates: %v", err)
}
Expand Down Expand Up @@ -153,6 +153,9 @@ func main() {
staticIPFeatureGateEnabled := defaultMutableGate.Enabled(featuregate.Feature(apifeatures.FeatureGateVSphereStaticIPs))
klog.Infof("FeatureGateVSphereStaticIPs initialised: %t", staticIPFeatureGateEnabled)

multiDiskFeatureGateEnabled := defaultMutableGate.Enabled(featuregate.Feature(apifeatures.FeatureGateVSphereMultiDisk))
klog.Infof("FeatureGateVSphereMultiDisk initialised: %t", multiDiskFeatureGateEnabled)

// Setup a Manager
mgr, err := manager.New(cfg, opts)
if err != nil {
Expand All @@ -165,12 +168,12 @@ func main() {

// Initialize machine actuator.
machineActuator := machine.NewActuator(machine.ActuatorParams{
Client: mgr.GetClient(),
APIReader: mgr.GetAPIReader(),
EventRecorder: mgr.GetEventRecorderFor("vspherecontroller"),
TaskIDCache: taskIDCache,
StaticIPFeatureGateEnabled: staticIPFeatureGateEnabled,
OpenshiftConfigNamespace: vsphere.OpenshiftConfigNamespace,
Client: mgr.GetClient(),
APIReader: mgr.GetAPIReader(),
EventRecorder: mgr.GetEventRecorderFor("vspherecontroller"),
TaskIDCache: taskIDCache,
FeatureGates: defaultMutableGate,
OpenshiftConfigNamespace: vsphere.OpenshiftConfigNamespace,
})

if err := configv1.Install(mgr.GetScheme()); err != nil {
Expand Down
6 changes: 6 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,9 @@ require (
sigs.k8s.io/kustomize/kyaml v0.17.1 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
)

replace github.com/openshift/api => github.com/vr4manta/api v0.0.0-20241114135651-e09483b43320

replace github.com/openshift/library-go => github.com/vr4manta/library-go v0.0.0-20240910183943-6bfccc981bf1

// replace k8s.io/cloud-provider-vsphere => github.com/vr4manta/cloud-provider-vsphere v0.0.0-20240926163731-40cee92a0401
12 changes: 8 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -371,16 +371,12 @@ github.com/onsi/ginkgo/v2 v2.20.2 h1:7NVCeyIWROIAheY21RLS+3j2bb52W0W82tkberYytp4
github.com/onsi/ginkgo/v2 v2.20.2/go.mod h1:K9gyxPIlb+aIvnZ8bd9Ak+YP18w3APlR+5coaZoE2ag=
github.com/onsi/gomega v1.34.2 h1:pNCwDkzrsv7MS9kpaQvVb1aVLahQXyJ/Tv5oAZMI3i8=
github.com/onsi/gomega v1.34.2/go.mod h1:v1xfxRgk0KIsG+QOdm7p8UosrOzPYRo60fd3B/1Dukc=
github.com/openshift/api v0.0.0-20240924155631-232984653385 h1:P6O191HwBj0ahEfea2wkvxhmW2fzXhvCh8hwHDvUozM=
github.com/openshift/api v0.0.0-20240924155631-232984653385/go.mod h1:OOh6Qopf21pSzqNVCB5gomomBXb8o5sGKZxG2KNpaXM=
github.com/openshift/client-go v0.0.0-20240918182115-6a8ead8397fd h1:Gd0+bYdcfGIsDOJ8BwTJJjQeXoziyIsTwqp/s38rKyM=
github.com/openshift/client-go v0.0.0-20240918182115-6a8ead8397fd/go.mod h1:EB7GeA/vpf9AHklMgnnT0+uG6l/3f8cChtCFbJFrk4g=
github.com/openshift/cluster-api-actuator-pkg/testutils v0.0.0-20241007145816-7038c320d36c h1:9A/0QoTZo2xh5j6nmh5CGNVBG8Ql1RmXmCcrikBnG+w=
github.com/openshift/cluster-api-actuator-pkg/testutils v0.0.0-20241007145816-7038c320d36c/go.mod h1:EN1Sv7kcVtaLUiXpZ8V0iSiJxNPPz1H3ZhCmNRpJWZM=
github.com/openshift/cluster-control-plane-machine-set-operator v0.0.0-20240909043600-373ac49835bf h1:mfMmaD9+vZIZQq3MGXsS/AGHXekj4wIn3zc1Cs1EY8M=
github.com/openshift/cluster-control-plane-machine-set-operator v0.0.0-20240909043600-373ac49835bf/go.mod h1:2fZsjZ3QSPkoMUc8QntXfeBb8AnvW+WIYwwQX8vmgvQ=
github.com/openshift/library-go v0.0.0-20240919205913-c96b82b3762b h1:y2DduJug7UZqTu0QTkRPAu73nskuUbFA66fmgxVf/fI=
github.com/openshift/library-go v0.0.0-20240919205913-c96b82b3762b/go.mod h1:f8QcnrooSwGa96xI4UaKbKGJZskhTCGeimXKyc4t/ZU=
github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw=
github.com/otiai10/copy v1.14.0 h1:dCI/t1iTdYGtkvCuBG2BgR6KZa83PTclw4U5n2wAllU=
github.com/otiai10/copy v1.14.0/go.mod h1:ECfuL02W+/FkTWZWgQqXPWZgW9oeKCSQ5qVfSc4qc4w=
Expand Down Expand Up @@ -521,8 +517,16 @@ github.com/uudashr/gocognit v1.1.3 h1:l+a111VcDbKfynh+airAy/DJQKaXh2m9vkoysMPSZy
github.com/uudashr/gocognit v1.1.3/go.mod h1:aKH8/e8xbTRBwjbCkwZ8qt4l2EpKXl31KMHgSS+lZ2U=
github.com/vmware/govmomi v0.43.0 h1:7Kg3Bkdly+TrE67BYXzRq7ZrDnn7xqpKX95uEh2f9Go=
github.com/vmware/govmomi v0.43.0/go.mod h1:IOv5nTXCPqH9qVJAlRuAGffogaLsNs8aF+e7vLgsHJU=
github.com/vr4manta/api v0.0.0-20241114135651-e09483b43320 h1:N/ky0twZyGxlVN4y2UIiyoW4/XhkE9pQuQb0DPpL/ko=
github.com/vr4manta/api v0.0.0-20241114135651-e09483b43320/go.mod h1:Shkl4HanLwDiiBzakv+con/aMGnVE2MAGvoKp5oyYUo=
github.com/vr4manta/library-go v0.0.0-20240910183943-6bfccc981bf1 h1:1gyQPwD2jHfHESPJxs4/R7yxCLwiT2hJuavRvIksyWY=
github.com/vr4manta/library-go v0.0.0-20240910183943-6bfccc981bf1/go.mod h1:HRCtk80UWFVTW7UShIFimUV0smpP7LGcQJw5mHuAmIw=
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
github.com/vr4manta/api v0.0.0-20240924150740-ec5392903387 h1:WDXPgFYRTEmlo3wKeo3/9idb42JbckSd75GyfjpgLPU=
github.com/vr4manta/api v0.0.0-20240924150740-ec5392903387/go.mod h1:OOh6Qopf21pSzqNVCB5gomomBXb8o5sGKZxG2KNpaXM=
github.com/vr4manta/library-go v0.0.0-20240910183943-6bfccc981bf1 h1:1gyQPwD2jHfHESPJxs4/R7yxCLwiT2hJuavRvIksyWY=
github.com/vr4manta/library-go v0.0.0-20240910183943-6bfccc981bf1/go.mod h1:HRCtk80UWFVTW7UShIFimUV0smpP7LGcQJw5mHuAmIw=
github.com/xen0n/gosmopolitan v1.2.2 h1:/p2KTnMzwRexIW8GlKawsTWOxn7UHA+jCMF/V8HHtvU=
github.com/xen0n/gosmopolitan v1.2.2/go.mod h1:7XX7Mj61uLYrj0qmeN0zi7XDon9JRAEhYQqAPLVNTeg=
github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ=
Expand Down
86 changes: 44 additions & 42 deletions pkg/controller/vsphere/actuator.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"fmt"
"time"

"k8s.io/component-base/featuregate"

machinev1 "github.com/openshift/api/machine/v1beta1"
machinecontroller "github.com/openshift/machine-api-operator/pkg/controller/machine"
corev1 "k8s.io/api/core/v1"
Expand All @@ -27,33 +29,33 @@ const (

// Actuator is responsible for performing machine reconciliation.
type Actuator struct {
client runtimeclient.Client
apiReader runtimeclient.Reader
eventRecorder record.EventRecorder
TaskIDCache map[string]string
StaticIPFeatureGateEnabled bool
openshiftConfigNamespace string
client runtimeclient.Client
apiReader runtimeclient.Reader
eventRecorder record.EventRecorder
TaskIDCache map[string]string
FeatureGates featuregate.MutableFeatureGate
openshiftConfigNamespace string
}

// ActuatorParams holds parameter information for Actuator.
type ActuatorParams struct {
Client runtimeclient.Client
APIReader runtimeclient.Reader
EventRecorder record.EventRecorder
TaskIDCache map[string]string
StaticIPFeatureGateEnabled bool
OpenshiftConfigNamespace string
Client runtimeclient.Client
APIReader runtimeclient.Reader
EventRecorder record.EventRecorder
TaskIDCache map[string]string
FeatureGates featuregate.MutableFeatureGate
OpenshiftConfigNamespace string
}

// NewActuator returns an actuator.
func NewActuator(params ActuatorParams) *Actuator {
return &Actuator{
client: params.Client,
apiReader: params.APIReader,
eventRecorder: params.EventRecorder,
TaskIDCache: params.TaskIDCache,
StaticIPFeatureGateEnabled: params.StaticIPFeatureGateEnabled,
openshiftConfigNamespace: params.OpenshiftConfigNamespace,
client: params.Client,
apiReader: params.APIReader,
eventRecorder: params.EventRecorder,
TaskIDCache: params.TaskIDCache,
FeatureGates: params.FeatureGates,
openshiftConfigNamespace: params.OpenshiftConfigNamespace,
}
}

Expand All @@ -72,12 +74,12 @@ func (a *Actuator) Create(ctx context.Context, machine *machinev1.Machine) error
klog.Infof("%s: actuator creating machine", machine.GetName())

scope, err := newMachineScope(machineScopeParams{
Context: ctx,
client: a.client,
machine: machine,
apiReader: a.apiReader,
StaticIPFeatureGateEnabled: a.StaticIPFeatureGateEnabled,
openshiftConfigNameSpace: a.openshiftConfigNamespace,
Context: ctx,
client: a.client,
machine: machine,
apiReader: a.apiReader,
featureGates: a.FeatureGates,
openshiftConfigNameSpace: a.openshiftConfigNamespace,
})
if err != nil {
fmtErr := fmt.Errorf(scopeFailFmt, machine.GetName(), err)
Expand Down Expand Up @@ -116,12 +118,12 @@ func (a *Actuator) Create(ctx context.Context, machine *machinev1.Machine) error
func (a *Actuator) Exists(ctx context.Context, machine *machinev1.Machine) (bool, error) {
klog.Infof("%s: actuator checking if machine exists", machine.GetName())
scope, err := newMachineScope(machineScopeParams{
Context: ctx,
client: a.client,
machine: machine,
apiReader: a.apiReader,
StaticIPFeatureGateEnabled: a.StaticIPFeatureGateEnabled,
openshiftConfigNameSpace: a.openshiftConfigNamespace,
Context: ctx,
client: a.client,
machine: machine,
apiReader: a.apiReader,
featureGates: a.FeatureGates,
openshiftConfigNameSpace: a.openshiftConfigNamespace,
})
if err != nil {
return false, fmt.Errorf(scopeFailFmt, machine.GetName(), err)
Expand All @@ -135,12 +137,12 @@ func (a *Actuator) Update(ctx context.Context, machine *machinev1.Machine) error
delete(a.TaskIDCache, machine.Name)

scope, err := newMachineScope(machineScopeParams{
Context: ctx,
client: a.client,
machine: machine,
apiReader: a.apiReader,
StaticIPFeatureGateEnabled: a.StaticIPFeatureGateEnabled,
openshiftConfigNameSpace: a.openshiftConfigNamespace,
Context: ctx,
client: a.client,
machine: machine,
apiReader: a.apiReader,
featureGates: a.FeatureGates,
openshiftConfigNameSpace: a.openshiftConfigNamespace,
})
if err != nil {
fmtErr := fmt.Errorf(scopeFailFmt, machine.GetName(), err)
Expand Down Expand Up @@ -177,12 +179,12 @@ func (a *Actuator) Delete(ctx context.Context, machine *machinev1.Machine) error
delete(a.TaskIDCache, machine.Name)

scope, err := newMachineScope(machineScopeParams{
Context: ctx,
client: a.client,
machine: machine,
apiReader: a.apiReader,
StaticIPFeatureGateEnabled: a.StaticIPFeatureGateEnabled,
openshiftConfigNameSpace: a.openshiftConfigNamespace,
Context: ctx,
client: a.client,
machine: machine,
apiReader: a.apiReader,
featureGates: a.FeatureGates,
openshiftConfigNameSpace: a.openshiftConfigNamespace,
})
if err != nil {
fmtErr := fmt.Errorf(scopeFailFmt, machine.GetName(), err)
Expand Down
8 changes: 8 additions & 0 deletions pkg/controller/vsphere/actuator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"testing"
"time"

testutils "github.com/openshift/machine-api-operator/pkg/util/testing"

. "github.com/onsi/gomega"
configv1 "github.com/openshift/api/config/v1"
machinev1 "github.com/openshift/api/machine/v1beta1"
Expand Down Expand Up @@ -363,13 +365,19 @@ func TestMachineEvents(t *testing.T) {
}
gs.Eventually(getNode, timeout).Should(Succeed())

gate, err := testutils.NewDefaultMutableFeatureGate()
if err != nil {
t.Errorf("Unexpected error setting up feature gates: %v", err)
}

taskIDCache := make(map[string]string)
params := ActuatorParams{
Client: k8sClient,
EventRecorder: eventRecorder,
APIReader: k8sClient,
TaskIDCache: taskIDCache,
OpenshiftConfigNamespace: openshiftConfigNamespaceForTest,
FeatureGates: gate,
}

actuator := NewActuator(params)
Expand Down
42 changes: 22 additions & 20 deletions pkg/controller/vsphere/machine_scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"errors"
"fmt"

"k8s.io/component-base/featuregate"

machinev1 "github.com/openshift/api/machine/v1beta1"
machinecontroller "github.com/openshift/machine-api-operator/pkg/controller/machine"
"github.com/openshift/machine-api-operator/pkg/controller/vsphere/session"
Expand All @@ -23,11 +25,11 @@ const (
// machineScopeParams defines the input parameters used to create a new MachineScope.
type machineScopeParams struct {
context.Context
client runtimeclient.Client
apiReader runtimeclient.Reader
machine *machinev1.Machine
StaticIPFeatureGateEnabled bool
openshiftConfigNameSpace string
client runtimeclient.Client
apiReader runtimeclient.Reader
machine *machinev1.Machine
featureGates featuregate.MutableFeatureGate
openshiftConfigNameSpace string
}

// machineScope defines a scope defined around a machine and its cluster.
Expand All @@ -42,11 +44,11 @@ type machineScope struct {
// vSphere cloud-provider config
vSphereConfig *vsphere.Config
// machine resource
machine *machinev1.Machine
providerSpec *machinev1.VSphereMachineProviderSpec
providerStatus *machinev1.VSphereMachineProviderStatus
machineToBePatched runtimeclient.Patch
staticIPFeatureGateEnabled bool
machine *machinev1.Machine
providerSpec *machinev1.VSphereMachineProviderSpec
providerStatus *machinev1.VSphereMachineProviderStatus
machineToBePatched runtimeclient.Patch
featureGates featuregate.MutableFeatureGate
}

// newMachineScope creates a new machineScope from the supplied parameters.
Expand Down Expand Up @@ -88,16 +90,16 @@ func newMachineScope(params machineScopeParams) (*machineScope, error) {
}

return &machineScope{
Context: params.Context,
client: params.client,
apiReader: params.apiReader,
session: authSession,
machine: params.machine,
providerSpec: providerSpec,
providerStatus: providerStatus,
vSphereConfig: vSphereConfig,
staticIPFeatureGateEnabled: params.StaticIPFeatureGateEnabled,
machineToBePatched: runtimeclient.MergeFrom(params.machine.DeepCopy()),
Context: params.Context,
client: params.client,
apiReader: params.apiReader,
session: authSession,
machine: params.machine,
providerSpec: providerSpec,
providerStatus: providerStatus,
vSphereConfig: vSphereConfig,
featureGates: params.featureGates,
machineToBePatched: runtimeclient.MergeFrom(params.machine.DeepCopy()),
}, nil
}

Expand Down
Loading