Skip to content
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
7 changes: 3 additions & 4 deletions api/v1alpha1/lvmcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ import (
type LVMClusterSpec struct {
// Important: Run "make" to regenerate code after modifying this file

// Tolerations to apply to nodes to act on
// +optional
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
// DeviceClasses are a rules that assign local storage devices to volumegroups that are used for creating lvm based PVs
// +Optional
DeviceClasses []DeviceClass `json:"deviceClasses,omitempty"`
Expand All @@ -50,10 +53,6 @@ type DeviceClass struct {
// +optional
NodeSelector *corev1.NodeSelector `json:"nodeSelector,omitempty"`

// Tolerations to apply to nodes to act on
// +optional
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`

// TODO: add support for various LVM settings
// // Config for this deviceClass, lvm settings are a field here
// // +optional
Expand Down
14 changes: 7 additions & 7 deletions api/v1alpha1/zz_generated.deepcopy.go

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

82 changes: 40 additions & 42 deletions config/crd/bases/lvm.topolvm.io_lvmclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,48 +138,46 @@ spec:
required:
- nodeSelectorTerms
type: object
tolerations:
description: Tolerations to apply to nodes to act on
items:
description: The pod this Toleration is attached to tolerates
any taint that matches the triple <key,value,effect> using
the matching operator <operator>.
properties:
effect:
description: Effect indicates the taint effect to match.
Empty means match all taint effects. When specified,
allowed values are NoSchedule, PreferNoSchedule and
NoExecute.
type: string
key:
description: Key is the taint key that the toleration
applies to. Empty means match all taint keys. If the
key is empty, operator must be Exists; this combination
means to match all values and all keys.
type: string
operator:
description: Operator represents a key's relationship
to the value. Valid operators are Exists and Equal.
Defaults to Equal. Exists is equivalent to wildcard
for value, so that a pod can tolerate all taints of
a particular category.
type: string
tolerationSeconds:
description: TolerationSeconds represents the period of
time the toleration (which must be of effect NoExecute,
otherwise this field is ignored) tolerates the taint.
By default, it is not set, which means tolerate the
taint forever (do not evict). Zero and negative values
will be treated as 0 (evict immediately) by the system.
format: int64
type: integer
value:
description: Value is the taint value the toleration matches
to. If the operator is Exists, the value should be empty,
otherwise just a regular string.
type: string
type: object
type: array
type: object
type: array
tolerations:
description: Tolerations to apply to nodes to act on
items:
description: The pod this Toleration is attached to tolerates any
taint that matches the triple <key,value,effect> using the matching
operator <operator>.
properties:
effect:
description: Effect indicates the taint effect to match. Empty
means match all taint effects. When specified, allowed values
are NoSchedule, PreferNoSchedule and NoExecute.
type: string
key:
description: Key is the taint key that the toleration applies
to. Empty means match all taint keys. If the key is empty,
operator must be Exists; this combination means to match all
values and all keys.
type: string
operator:
description: Operator represents a key's relationship to the
value. Valid operators are Exists and Equal. Defaults to Equal.
Exists is equivalent to wildcard for value, so that a pod
can tolerate all taints of a particular category.
type: string
tolerationSeconds:
description: TolerationSeconds represents the period of time
the toleration (which must be of effect NoExecute, otherwise
this field is ignored) tolerates the taint. By default, it
is not set, which means tolerate the taint forever (do not
evict). Zero and negative values will be treated as 0 (evict
immediately) by the system.
format: int64
type: integer
value:
description: Value is the taint value the toleration matches
to. If the operator is Exists, the value should be empty,
otherwise just a regular string.
type: string
type: object
type: array
type: object
Expand Down
2 changes: 1 addition & 1 deletion controllers/topolvm_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func getNodeDaemonSet(lvmCluster *lvmv1alpha1.LVMCluster, namespace string) *app
// Affinity and tolerations
nodeSelector, tolerations := extractNodeSelectorAndTolerations(lvmCluster)

topolvmNodeTolerations := []corev1.Toleration{{Operator: corev1.TolerationOpExists}}
topolvmNodeTolerations := []corev1.Toleration{}
if tolerations != nil {
topolvmNodeTolerations = tolerations
}
Expand Down
6 changes: 4 additions & 2 deletions controllers/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ import (
// extractNodeSelectorAndTolerations combines and extracts scheduling parameters from the multiple deviceClass entries in an lvmCluster
func extractNodeSelectorAndTolerations(lvmCluster *lvmv1alpha1.LVMCluster) (*corev1.NodeSelector, []corev1.Toleration) {
var nodeSelector *corev1.NodeSelector
var tolerations []corev1.Toleration

tolerations := lvmCluster.Spec.Tolerations
Copy link
Contributor

@sp98 sp98 Jan 17, 2022

Choose a reason for hiding this comment

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

how about just returning lvmCluster.Spec.Tolerations from this method and not saving it in a variable first. The variable is never used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

While that is a valid comment,I would like to address that in a separate PR


terms := make([]corev1.NodeSelectorTerm, 0)
matchAllNodes := false
for _, deviceClass := range lvmCluster.Spec.DeviceClasses {
tolerations = append(tolerations, deviceClass.Tolerations...)

if deviceClass.NodeSelector != nil {
terms = append(terms, deviceClass.NodeSelector.NodeSelectorTerms...)
} else {
Expand Down