Skip to content

Commit

Permalink
Add support for ReadWriteOncePod access mode
Browse files Browse the repository at this point in the history
Signed-off-by: William Phetsinorath <william.phetsinorath@shikanime.studio>
  • Loading branch information
shikanime committed Oct 24, 2024
1 parent e7db6e7 commit e2dbdf3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
5 changes: 4 additions & 1 deletion datastore/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -1015,8 +1015,11 @@ func NewPVManifest(size int64, pvName, volumeName, storageClassName, fsType stri
// NewPVCManifestForVolume returns a new PersistentVolumeClaim object for a longhorn volume
func NewPVCManifestForVolume(v *longhorn.Volume, pvName, ns, pvcName, storageClassName string) *corev1.PersistentVolumeClaim {
accessMode := corev1.ReadWriteOnce
if v.Spec.AccessMode == longhorn.AccessModeReadWriteMany {
switch v.Spec.AccessMode {
case longhorn.AccessModeReadWriteMany:
accessMode = corev1.ReadWriteMany
case longhorn.AccessModeReadWriteOncePod:
accessMode = corev1.ReadWriteOncePod
}

return NewPVCManifest(v.Spec.Size, pvName, ns, pvcName, storageClassName, accessMode)
Expand Down
5 changes: 3 additions & 2 deletions k8s/pkg/apis/longhorn/v1beta1/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ const (
type AccessMode string

const (
AccessModeReadWriteOnce = AccessMode("rwo")
AccessModeReadWriteMany = AccessMode("rwx")
AccessModeReadWriteOnce = AccessMode("rwo")
AccessModeReadWriteOncePod = AccessMode("rwop")
AccessModeReadWriteMany = AccessMode("rwx")
)

type ReplicaAutoBalance string
Expand Down
5 changes: 3 additions & 2 deletions k8s/pkg/apis/longhorn/v1beta2/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ const (
type AccessMode string

const (
AccessModeReadWriteOnce = AccessMode("rwo")
AccessModeReadWriteMany = AccessMode("rwx")
AccessModeReadWriteOnce = AccessMode("rwo")
AccessModeReadWriteOncePod = AccessMode("rwop")
AccessModeReadWriteMany = AccessMode("rwx")
)

// +kubebuilder:validation:Enum=ignored;disabled;least-effort;best-effort
Expand Down
2 changes: 1 addition & 1 deletion types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ func ValidateDataLocality(mode longhorn.DataLocality) error {
}

func ValidateAccessMode(mode longhorn.AccessMode) error {
if mode != longhorn.AccessModeReadWriteMany && mode != longhorn.AccessModeReadWriteOnce {
if mode != longhorn.AccessModeReadWriteMany && mode != longhorn.AccessModeReadWriteOnce && mode != longhorn.AccessModeReadWriteOncePod {
return fmt.Errorf("invalid access mode: %v", mode)
}
return nil
Expand Down

0 comments on commit e2dbdf3

Please sign in to comment.