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

feat: make API and controller changes to support manual disk selection #229

Merged
merged 12 commits into from
Aug 31, 2022
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions api/v1alpha1/lvmcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ limitations under the License.
package v1alpha1

import (
conditionsv1 "github.com/openshift/custom-resource-status/conditions/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

const (
// ConditionLVMClusterValid communicates if LVMCluster CR is invalid
ConditionLVMClusterValid conditionsv1.ConditionType = "LVMClusterValid"
)

// LVMClusterSpec defines the desired state of LVMCluster
type LVMClusterSpec struct {
// Important: Run "make" to regenerate code after modifying this file
Expand Down Expand Up @@ -90,6 +96,12 @@ type DeviceSelector struct {
// MinSize is the minimum size of the device which needs to be included. Defaults to `1Gi` if empty
// +optional
// MinSize *resource.Quantity `json:"minSize,omitempty"`

// A list of device paths which would be chosen for creating Volume Group.
// For example "/dev/disk/by-path/pci-0000:04:00.0-nvme-1"
// We discourage using the device names as they can change over node restarts.
// +optional
Paths []string `json:"paths,omitempty"`
iamniting marked this conversation as resolved.
Show resolved Hide resolved
}

// type DeviceClassConfig struct {
Expand All @@ -108,6 +120,11 @@ type LVMClusterStatus struct {
// Ready describes if the LVMCluster is ready.
// +optional
Ready bool `json:"ready,omitempty"`

// Conditions describes the state of the resource.
// +optional
Conditions []conditionsv1.Condition `json:"conditions,omitempty"`

// DeviceClassStatuses describes the status of all deviceClasses
DeviceClassStatuses []DeviceClassStatus `json:"deviceClassStatuses,omitempty"`
}
Expand All @@ -132,6 +149,8 @@ type NodeStatus struct {
Node string `json:"node,omitempty"`
// Status is the status of the VG on the node
Status VGStatusType `json:"status,omitempty"`
// Reason provides more detail on the VG creation status
Reason string `json:"reason,omitempty"`
// Devices is the list of devices used by the deviceclass
Devices []string `json:"devices,omitempty"`
}
Expand Down
17 changes: 15 additions & 2 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions bundle/manifests/lvm.topolvm.io_lvmclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ spec:
deviceSelector:
description: DeviceSelector is a set of rules that should
match for a device to be included in the LVMCluster
properties:
paths:
description: A list of device paths which would be chosen
for creating Volume Group. For example "/dev/disk/by-path/pci-0000:04:00.0-nvme-1"
We discourage using the device names as they can change
over node restarts.
items:
type: string
type: array
type: object
name:
description: 'Name of the class, the VG and possibly the
Expand Down Expand Up @@ -220,6 +229,33 @@ spec:
status:
description: LVMClusterStatus defines the observed state of LVMCluster
properties:
conditions:
description: Conditions describes the state of the resource.
items:
description: Condition represents the state of the operator's reconciliation
functionality.
properties:
lastHeartbeatTime:
format: date-time
type: string
lastTransitionTime:
format: date-time
type: string
message:
type: string
reason:
type: string
status:
type: string
type:
description: ConditionType is the state of the operator's reconciliation
functionality.
type: string
required:
- status
- type
type: object
type: array
deviceClassStatuses:
description: DeviceClassStatuses describes the status of all deviceClasses
items:
Expand All @@ -245,6 +281,10 @@ spec:
node:
description: Node is the name of the node
type: string
reason:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like something that can be part of the make bundle commit.

description: Reason provides more detail on the VG creation
status
type: string
status:
description: Status is the status of the VG on the node
type: string
Expand Down
9 changes: 9 additions & 0 deletions bundle/manifests/lvm.topolvm.io_lvmvolumegroups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ spec:
deviceSelector:
description: DeviceSelector is a set of rules that should match for
a device to be included in this TopoLVMCluster
properties:
paths:
description: A list of device paths which would be chosen for
creating Volume Group. For example "/dev/disk/by-path/pci-0000:04:00.0-nvme-1"
We discourage using the device names as they can change over
node restarts.
items:
type: string
type: array
type: object
nodeSelector:
description: NodeSelector chooses nodes
Expand Down
40 changes: 40 additions & 0 deletions config/crd/bases/lvm.topolvm.io_lvmclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ spec:
deviceSelector:
description: DeviceSelector is a set of rules that should
match for a device to be included in the LVMCluster
properties:
paths:
description: A list of device paths which would be chosen
for creating Volume Group. For example "/dev/disk/by-path/pci-0000:04:00.0-nvme-1"
We discourage using the device names as they can change
over node restarts.
items:
type: string
type: array
type: object
name:
description: 'Name of the class, the VG and possibly the
Expand Down Expand Up @@ -222,6 +231,33 @@ spec:
status:
description: LVMClusterStatus defines the observed state of LVMCluster
properties:
conditions:
description: Conditions describes the state of the resource.
items:
description: Condition represents the state of the operator's reconciliation
functionality.
properties:
lastHeartbeatTime:
format: date-time
type: string
lastTransitionTime:
format: date-time
type: string
message:
type: string
reason:
type: string
status:
type: string
type:
description: ConditionType is the state of the operator's reconciliation
functionality.
type: string
required:
- status
- type
type: object
type: array
deviceClassStatuses:
description: DeviceClassStatuses describes the status of all deviceClasses
items:
Expand All @@ -247,6 +283,10 @@ spec:
node:
description: Node is the name of the node
type: string
reason:
description: Reason provides more detail on the VG creation
status
type: string
status:
description: Status is the status of the VG on the node
type: string
Expand Down
9 changes: 9 additions & 0 deletions config/crd/bases/lvm.topolvm.io_lvmvolumegroups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ spec:
deviceSelector:
description: DeviceSelector is a set of rules that should match for
a device to be included in this TopoLVMCluster
properties:
paths:
description: A list of device paths which would be chosen for
creating Volume Group. For example "/dev/disk/by-path/pci-0000:04:00.0-nvme-1"
We discourage using the device names as they can change over
node restarts.
items:
type: string
type: array
type: object
nodeSelector:
description: NodeSelector chooses nodes
Expand Down
35 changes: 35 additions & 0 deletions controllers/conditions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
Copyright 2022.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package controllers

import (
conditionsv1 "github.com/openshift/custom-resource-status/conditions/v1"
corev1 "k8s.io/api/core/v1"

lvmv1alpha1 "github.com/red-hat-storage/lvm-operator/api/v1alpha1"
)

func setLVMClusterCRvalidCondition(conditions *[]conditionsv1.Condition,
status corev1.ConditionStatus, reason string, message string) {

conditionsv1.SetStatusCondition(conditions, conditionsv1.Condition{
Type: lvmv1alpha1.ConditionLVMClusterValid,
Status: status,
Reason: reason,
Message: message,
})
}
11 changes: 9 additions & 2 deletions controllers/lvm_volumegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,15 @@ func (c lvmVG) ensureCreated(r *LVMClusterReconciler, ctx context.Context, lvmCl
lvmVolumeGroups := c.getLvmVolumeGroups(r, lvmCluster)

for _, volumeGroup := range lvmVolumeGroups {
result, err := cutil.CreateOrUpdate(ctx, r.Client, volumeGroup, func() error {
// no need to mutate any field
existingVolumeGroup := &lvmv1alpha1.LVMVolumeGroup{
ObjectMeta: metav1.ObjectMeta{
Name: volumeGroup.Name,
Namespace: volumeGroup.Namespace,
},
}
result, err := cutil.CreateOrUpdate(ctx, r.Client, existingVolumeGroup, func() error {
existingVolumeGroup.Finalizers = volumeGroup.Finalizers
existingVolumeGroup.Spec = volumeGroup.Spec
return nil
})

Expand Down
Loading