Skip to content

Commit

Permalink
Merge pull request #276 from red-hat-storage/sync_us--devel
Browse files Browse the repository at this point in the history
Syncing latest changes from upstream devel for ceph-csi
  • Loading branch information
openshift-merge-bot[bot] committed Mar 21, 2024
2 parents 2084251 + cd18490 commit 47c4816
Show file tree
Hide file tree
Showing 20 changed files with 1,954 additions and 72 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ endif
GO_PROJECT=github.com/ceph/ceph-csi

CEPH_VERSION ?= $(shell . $(CURDIR)/build.env ; echo $${CEPH_VERSION})
GO_TAGS_LIST ?= $(CEPH_VERSION)
# TODO: ceph_preview tag required for FSQuiesce API
GO_TAGS_LIST ?= $(CEPH_VERSION) ceph_preview

# go build flags
LDFLAGS ?=
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ toolchain go1.21.5

require (
github.com/IBM/keyprotect-go-client v0.12.2
github.com/aws/aws-sdk-go v1.50.26
github.com/aws/aws-sdk-go v1.50.32
github.com/aws/aws-sdk-go-v2/service/sts v1.28.1
github.com/ceph/ceph-csi/api v0.0.0-00010101000000-000000000000
github.com/ceph/go-ceph v0.26.0
github.com/ceph/go-ceph v0.26.1-0.20240319113421-755481f8c243
github.com/container-storage-interface/spec v1.9.0
github.com/csi-addons/spec v0.2.1-0.20230606140122-d20966d2e444
github.com/gemalto/kmip-go v0.0.10
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -833,8 +833,8 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkY
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a h1:idn718Q4B6AGu/h5Sxe66HYVdqdGu2l9Iebqhi/AEoA=
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
github.com/aws/aws-sdk-go v1.44.164/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/aws/aws-sdk-go v1.50.26 h1:tuv8+dje59DBK1Pj65tSCdD36oamBxKYJgbng4bFylc=
github.com/aws/aws-sdk-go v1.50.26/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/aws/aws-sdk-go v1.50.32 h1:POt81DvegnpQKM4DMDLlHz1CO6OBnEoQ1gRhYFd7QRY=
github.com/aws/aws-sdk-go v1.50.32/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/aws/aws-sdk-go-v2 v1.25.2 h1:/uiG1avJRgLGiQM9X3qJM8+Qa6KRGK5rRPuXE0HUM+w=
github.com/aws/aws-sdk-go-v2 v1.25.2/go.mod h1:Evoc5AsmtveRt1komDwIsjHFyrP5tDuF1D1U+6z6pNo=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.2 h1:bNo4LagzUKbjdxE0tIcR9pMzLR2U/Tgie1Hq1HQ3iH8=
Expand Down Expand Up @@ -870,8 +870,8 @@ github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyY
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw=
github.com/ceph/go-ceph v0.26.0 h1:LZoATo25ZH5aeL5t85BwIbrNLKCDfcDM+e0qV0cmwHY=
github.com/ceph/go-ceph v0.26.0/go.mod h1:ISxb295GszZwtLPkeWi+L2uLYBVsqbsh0M104jZMOX4=
github.com/ceph/go-ceph v0.26.1-0.20240319113421-755481f8c243 h1:O99PJ2rNxY+XiN2swRSmJC24V3YInVt5Lk48Em1cdVE=
github.com/ceph/go-ceph v0.26.1-0.20240319113421-755481f8c243/go.mod h1:PS15ql+uqcnZN8uD3WuxlImxdaTYtxqJoaTmlFJYnbI=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
Expand Down
4 changes: 4 additions & 0 deletions internal/cephfs/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ type ControllerServer struct {
// A map storing all volumes/snapshots with ongoing operations.
OperationLocks *util.OperationLock

// A map storing all volumes with ongoing operations so that additional operations
// for that same volume (as defined by volumegroup ID/volumegroup name) return an Aborted error
VolumeGroupLocks *util.VolumeLocks

// Cluster name
ClusterName string

Expand Down
250 changes: 250 additions & 0 deletions internal/cephfs/core/quiesce.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
/*
Copyright 2024 The Ceph-CSI Authors.
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 core

import (
"context"

"github.com/ceph/ceph-csi/internal/util"
"github.com/ceph/ceph-csi/internal/util/log"

"github.com/ceph/go-ceph/cephfs/admin"
)

type QuiesceState string

const (
Released QuiesceState = "RELEASED"
Quiescing QuiesceState = "QUIESCING"
Quiesced QuiesceState = "QUIESCED"
)

// GetQuiesceState returns the quiesce state of the filesystem.
func GetQuiesceState(set admin.QuiesceState) QuiesceState {
var state QuiesceState
switch set.Name {
case "RELEASED":
state = Released
case "QUIESCING":
state = Quiescing
case "QUIESCED":
state = Quiesced
default:
state = QuiesceState(set.Name)
}

return state
}

type FSQuiesceClient interface {
// Destroy destroys the connection used for FSAdmin.
Destroy()
// FSQuiesce quiesces the subvolumes in the filesystem.
FSQuiesce(
ctx context.Context,
reserveName string,
) (*admin.QuiesceInfo, error)
// GetVolumes returns the list of volumes in the filesystem that are to be
// quiesced.
GetVolumes() []Volume
// FSQuiesceWithExpireTimeout quiesces the subvolumes in the filesystem
// with an expiration timeout. it should be used after FSQuiesce to reset
// the expire timeout. This helps in keeping the subvolumes in the
// filesystem in quiesced state until all snapshots are taken.
FSQuiesceWithExpireTimeout(ctx context.Context,
reserveName string,
) (*admin.QuiesceInfo, error)
// ResetFSQuiesce resets the quiesce timeout for the subvolumes in
// the filesystem.
ResetFSQuiesce(ctx context.Context,
reserveName string,
) (*admin.QuiesceInfo, error)
// ReleaseFSQuiesce releases the quiesce on the subvolumes in the
// filesystem.
ReleaseFSQuiesce(ctx context.Context,
reserveName string,
) (*admin.QuiesceInfo, error)
}

type Volume struct {
VolumeID string
ClusterID string
}

type fsQuiesce struct {
connection *util.ClusterConnection
fsName string
volumes []Volume
// subVolumeGroupMapping is a map of subvolumes to groups.
subVolumeGroupMapping map[string][]string
fsa *admin.FSAdmin
}

// NewFSQuiesce returns a new instance of fsQuiesce. It
// take the filesystem name, the list of volumes to be quiesced, the mapping of
// subvolumes to groups and the cluster connection as input.
func NewFSQuiesce(
fsName string,
volumes []Volume,
mapping map[string][]string,
conn *util.ClusterConnection,
) (FSQuiesceClient, error) {
fsa, err := conn.GetFSAdmin()
if err != nil {
return nil, err
}

return &fsQuiesce{
connection: conn,
fsName: fsName,
volumes: volumes,
subVolumeGroupMapping: mapping,
fsa: fsa,
}, nil
}

// Destroy destroys the connection used for FSAdmin.
func (fq *fsQuiesce) Destroy() {
if fq.connection != nil {
fq.connection.Destroy()
}
}

// GetVolumes returns the list of volumes in the filesystem that are to be
// quiesced.
func (fq *fsQuiesce) GetVolumes() []Volume {
return fq.volumes
}

// getMembers returns the list of names in the format
// group/subvolume that are to be quiesced. This is the format that the
// ceph fs quiesce expects.
// Example: ["group1/subvolume1", "group1/subvolume2", "group2/subvolume1"].
func (fq *fsQuiesce) getMembers() []string {
volName := []string{}
for svg, sb := range fq.subVolumeGroupMapping {
for _, s := range sb {
name := svg + "/" + s
volName = append(volName, name)
}
}

return volName
}

func (fq *fsQuiesce) FSQuiesce(
ctx context.Context,
reserveName string,
) (*admin.QuiesceInfo, error) {
opt := &admin.FSQuiesceOptions{
Timeout: 180,
AwaitFor: 0,
Expiration: 180,
}
log.DebugLog(ctx,
"FSQuiesce for reserveName %s: members:%v options:%v",
reserveName,
fq.getMembers(),
opt)
resp, err := fq.fsa.FSQuiesce(fq.fsName, admin.NoGroup, fq.getMembers(), reserveName, opt)
if resp != nil {
qInfo := resp.Sets[reserveName]

return &qInfo, nil
}

log.ErrorLog(ctx, "failed to quiesce filesystem %s", err)

return nil, err
}

func (fq *fsQuiesce) FSQuiesceWithExpireTimeout(ctx context.Context,
reserveName string,
) (*admin.QuiesceInfo, error) {
opt := &admin.FSQuiesceOptions{
Timeout: 180,
AwaitFor: 0,
Expiration: 180,
}
log.DebugLog(ctx,
"FSQuiesceWithExpireTimeout for reserveName %s: members:%v options:%v",
reserveName,
fq.getMembers(),
opt)
resp, err := fq.fsa.FSQuiesce(fq.fsName, admin.NoGroup, fq.getMembers(), reserveName, opt)
if resp != nil {
qInfo := resp.Sets[reserveName]

return &qInfo, nil
}

log.ErrorLog(ctx, "failed to quiesce filesystem with expire timeout %s", err)

return nil, err
}

func (fq *fsQuiesce) ResetFSQuiesce(ctx context.Context,
reserveName string,
) (*admin.QuiesceInfo, error) {
opt := &admin.FSQuiesceOptions{
Reset: true,
AwaitFor: 0,
Timeout: 180,
Expiration: 180,
}
// Reset the filesystem quiesce so that the timer will be reset, and we can
// reuse the same reservation if it has already failed or timed out.
log.DebugLog(ctx,
"ResetFSQuiesce for reserveName %s: members:%v options:%v",
reserveName,
fq.getMembers(),
opt)
resp, err := fq.fsa.FSQuiesce(fq.fsName, admin.NoGroup, fq.getMembers(), reserveName, opt)
if resp != nil {
qInfo := resp.Sets[reserveName]

return &qInfo, nil
}

log.ErrorLog(ctx, "failed to reset timeout for quiesce filesystem %s", err)

return nil, err
}

func (fq *fsQuiesce) ReleaseFSQuiesce(ctx context.Context,
reserveName string,
) (*admin.QuiesceInfo, error) {
opt := &admin.FSQuiesceOptions{
AwaitFor: 0,
Release: true,
}
log.DebugLog(ctx,
"ReleaseFSQuiesce for reserveName %s: members:%v options:%v",
reserveName,
fq.getMembers(),
opt)
resp, err := fq.fsa.FSQuiesce(fq.fsName, admin.NoGroup, []string{}, reserveName, opt)
if resp != nil {
qInfo := resp.Sets[reserveName]

return &qInfo, nil
}

log.ErrorLog(ctx, "failed to release quiesce of filesystem %s", err)

return nil, err
}
10 changes: 10 additions & 0 deletions internal/cephfs/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func NewControllerServer(d *csicommon.CSIDriver) *ControllerServer {
DefaultControllerServer: csicommon.NewDefaultControllerServer(d),
VolumeLocks: util.NewVolumeLocks(),
SnapshotLocks: util.NewVolumeLocks(),
VolumeGroupLocks: util.NewVolumeLocks(),
OperationLocks: util.NewOperationLock(),
}
}
Expand Down Expand Up @@ -124,6 +125,10 @@ func (fs *Driver) Run(conf *util.Config) {
store.VolJournal = journal.NewCSIVolumeJournalWithNamespace(CSIInstanceID, fsutil.RadosNamespace)

store.SnapJournal = journal.NewCSISnapshotJournalWithNamespace(CSIInstanceID, fsutil.RadosNamespace)

store.VolumeGroupJournal = journal.NewCSIVolumeGroupJournalWithNamespace(
CSIInstanceID,
fsutil.RadosNamespace)
// Initialize default library driver

fs.cd = csicommon.NewCSIDriver(conf.DriverName, util.DriverVersion, conf.NodeID)
Expand All @@ -146,6 +151,10 @@ func (fs *Driver) Run(conf *util.Config) {
csi.VolumeCapability_AccessMode_SINGLE_NODE_MULTI_WRITER,
csi.VolumeCapability_AccessMode_SINGLE_NODE_SINGLE_WRITER,
})

fs.cd.AddGroupControllerServiceCapabilities([]csi.GroupControllerServiceCapability_RPC_Type{
csi.GroupControllerServiceCapability_RPC_CREATE_DELETE_GET_VOLUME_GROUP_SNAPSHOT,
})
}
// Create gRPC servers

Expand Down Expand Up @@ -192,6 +201,7 @@ func (fs *Driver) Run(conf *util.Config) {
IS: fs.is,
CS: fs.cs,
NS: fs.ns,
GS: fs.cs,
}
server.Start(conf.Endpoint, srv)

Expand Down
3 changes: 3 additions & 0 deletions internal/cephfs/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ var (

// ErrVolumeHasSnapshots is returned when a subvolume has snapshots.
ErrVolumeHasSnapshots = coreError.New("volume has snapshots")

// ErrQuiesceInProgress is returned when quiesce operation is in progress.
ErrQuiesceInProgress = coreError.New("quiesce operation is in progress")
)

// IsCloneRetryError returns true if the clone error is pending,in-progress
Expand Down
Loading

0 comments on commit 47c4816

Please sign in to comment.