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
58 changes: 55 additions & 3 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
strategy:
max-parallel: 2
matrix:
test-name: [operations, sidecars, scaling, multi-dcs, backup-restore, nodetool]
test-name: [operations, sidecars, scaling, multi-dcs, backup-restore, nodetool, storage-upsize]
steps:
- id: lower-repo
shell: pwsh
Expand All @@ -105,13 +105,65 @@ jobs:
ref: ${{ steps.get-branch.outputs.branch }}

- uses: rinx/setup-k3d@v0.0.4
if: matrix.test-name != 'storage-upsize'
with:
version: v5.4.0
options: --image rancher/k3s:v1.24.13-k3s1

- uses: azure/setup-helm@v1
- name: Create kind config with LVM mounts
if: matrix.test-name == 'storage-upsize'
run: |
mkdir -p kindAndLvm
cat <<EOF > kindAndLvm/kind-lvm-config.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
extraMounts:
- hostPath: /tmp/kind-worker1-lvm
containerPath: /mnt/disks
- role: worker
extraMounts:
- hostPath: /tmp/kind-worker2-lvm
containerPath: /mnt/disks
EOF

mkdir -p /tmp/kind-worker1-lvm /tmp/kind-worker2-lvm

- name: Setup kind cluster
if: matrix.test-name == 'storage-upsize'
uses: helm/kind-action@v1.8.0
with:
version: v3.8.1
cluster_name: lvm-test
config: kindAndLvm/kind-lvm-config.yaml
wait: 300s

- name: Setup LVM on worker nodes
if: matrix.test-name == 'storage-upsize'
run: |
WORKER_NODES=$(kubectl get nodes -o name | grep worker | sed 's|node/||')

for NODE in $WORKER_NODES; do
echo "Setting up LVM on $NODE..."
docker exec $NODE bash -c '
apt-get update -qq && apt-get install -y -qq lvm2 thin-provisioning-tools > /dev/null 2>&1
mkdir -p /mnt/disks
truncate -s 10G /mnt/disks/disk.img
LOOP_DEVICE=$(losetup -f)
losetup $LOOP_DEVICE /mnt/disks/disk.img
pvcreate $LOOP_DEVICE
vgcreate lvmvg $LOOP_DEVICE
vgs
'
done

- name: Install OpenEBS LVM LocalPV
if: matrix.test-name == 'storage-upsize'
run: |
kubectl apply -f https://openebs.github.io/charts/lvm-operator.yaml
kubectl wait --for=condition=ready pod -l app=openebs-lvm-controller -n kube-system --timeout=300s
kubectl rollout status daemonset/openebs-lvm-node -n kube-system --timeout=300s

- name: Restore Kuttl
id: cache-kuttl
Expand Down
30 changes: 30 additions & 0 deletions api/v2/cassandracluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ var (

ActionCorrectCRDConfig = ClusterStateInfo{11, "CorrectCRDConfig"} //The Operator has correct a bad CRD configuration

ActionStorageUpsize = ClusterStateInfo{12, "StorageUpsize"}

regexDCRackName = regexp.MustCompile("^[a-z]([-a-z0-9]*[a-z0-9])?$")
)

Expand Down Expand Up @@ -232,6 +234,10 @@ func (cc *CassandraCluster) GetDCName(dc int) string {
return cc.Spec.Topology.DC[dc].Name
}

func (cc *CassandraCluster) GetDCNameStrongType(dc int) DcName {
return DcName(cc.GetDCName(dc))
}

func (cc *CassandraCluster) getDCNodesPerRacksFromIndex(dc int) int32 {
if dc >= cc.GetDCSize() {
return cc.Spec.NodesPerRacks
Expand Down Expand Up @@ -462,6 +468,11 @@ func (cc *CassandraCluster) GetDataCapacityForDC(dcName string) string {
return cc.GetDataCapacityFromDCName(dcName)
}

// GetDataCapacityForDC sends back the data capacity of cassandra nodes for the given strongly-typed dcName
func (cc *CassandraCluster) GetDataCapacityForDCName(dcName DcName) string {
return cc.GetDataCapacityFromDCName(dcName.String())
}

// GetDataCapacityFromDCName send DataCapacity used for the given dcName
func (cc *CassandraCluster) GetDataCapacityFromDCName(dcName string) string {
dcIndex := cc.GetDCIndexFromDCName(dcName)
Expand All @@ -480,6 +491,11 @@ func (cc *CassandraCluster) GetDataStorageClassForDC(dcName string) string {
return cc.GetDataStorageClassFromDCName(dcName)
}

// GetDataStorageClassForDCName send DataStorageClass used for the given strongly-typed dcName
func (cc *CassandraCluster) GetDataStorageClassForDCName(dcName DcName) string {
return cc.GetDataStorageClassFromDCName(dcName.String())
}

// GetDataCapacityFromDCName send DataStorageClass used for the given dcName
func (cc *CassandraCluster) GetDataStorageClassFromDCName(dcName string) string {
dcIndex := cc.GetDCIndexFromDCName(dcName)
Expand Down Expand Up @@ -539,6 +555,11 @@ func (cc *CassandraCluster) GetNodesPerRacks(dcRackName string) int32 {
return nodesPerRacks
}

// GetNodesPerRacks sends back the number of cassandra nodes to uses for this strongly-typed dc-rack
func (cc *CassandraCluster) GetNodesPerRacksStrongType(dcRackName DcRackName) int32 {
return cc.GetNodesPerRacks(dcRackName.String())
}

// GetDCNodesPerRacksFromDCRackName send NodesPerRack used for the given dcRackName
func (cc *CassandraCluster) GetDCRackNames() []string {
dcsize := cc.GetDCSize()
Expand Down Expand Up @@ -931,6 +952,11 @@ type BackRestSidecar struct {
VolumeMounts []v1.VolumeMount `json:"volumeMount,omitempty"`
}

// GetCassandraRackStatus returns CassandraRackStatus for a given strongly-typed dcRack
func (in *CassandraClusterStatus) GetCassandraRackStatus(dcRackName DcRackName) *CassandraRackStatus {
return in.CassandraRackStatus[dcRackName.String()]
}

// CassandraRackStatus defines states of Cassandra for 1 rack (1 statefulset)
type CassandraRackStatus struct {
// Phase indicates the state this Cassandra cluster jumps in.
Expand All @@ -943,6 +969,10 @@ type CassandraRackStatus struct {

// PodLastOperation manage status for Pod Operation (nodetool cleanup, upgradesstables..)
PodLastOperation PodLastOperation `json:"podLastOperation,omitempty"`

// StatefulSetSnapshotBeforeStorageResize is the StatefulSet snapshot taken before storage resize
// The purpose is to isolate the storage resize operation from other operations
StatefulSetSnapshotBeforeStorageResize string `json:"statefulSetSnapshotBeforeStorageResize,omitempty"`
}

// CassandraClusterStatus defines Global state of CassandraCluster
Expand Down
25 changes: 25 additions & 0 deletions api/v2/names.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package v2

type DcName string

func (n DcName) String() string {
return string(n)
}

type RackName string

func (n RackName) String() string {
return string(n)
}

type DcRackName string

func (n DcRackName) String() string {
return string(n)
}

type CompleteRackName struct {
DcName DcName
RackName RackName
DcRackName DcRackName
}
15 changes: 15 additions & 0 deletions api/v2/zz_generated.deepcopy.go

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

5 changes: 5 additions & 0 deletions charts/casskop/crds/db.orange.com_cassandraclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2308,6 +2308,11 @@ spec:
format: date-time
status:
type: string
statefulSetSnapshotBeforeStorageResize:
description: |-
StatefulSetSnapshotBeforeStorageResize is the StatefulSet snapshot taken before storage resize
The purpose is to isolate the storage resize operation from other operations
type: string
lastClusterAction:
description: Store last action at cluster level
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2308,6 +2308,11 @@ spec:
format: date-time
status:
type: string
statefulSetSnapshotBeforeStorageResize:
description: |-
StatefulSetSnapshotBeforeStorageResize is the StatefulSet snapshot taken before storage resize
The purpose is to isolate the storage resize operation from other operations
type: string
lastClusterAction:
description: Store last action at cluster level
type: string
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/db.orange.com_cassandraclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2308,6 +2308,11 @@ spec:
format: date-time
status:
type: string
statefulSetSnapshotBeforeStorageResize:
description: |-
StatefulSetSnapshotBeforeStorageResize is the StatefulSet snapshot taken before storage resize
The purpose is to isolate the storage resize operation from other operations
type: string
lastClusterAction:
description: Store last action at cluster level
type: string
Expand Down
Loading
Loading