Skip to content

Commit b6f5cda

Browse files
authored
Merge branch 'develop' into podAntiAffinity
2 parents 0aba431 + d024aef commit b6f5cda

File tree

6 files changed

+64
-30
lines changed

6 files changed

+64
-30
lines changed

deploy/helm/charts/Chart.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
apiVersion: v2
22
name: lvm-localpv
33
description: CSI Driver for dynamic provisioning of LVM Persistent Local Volumes.
4-
version: 1.8.0-develop
5-
appVersion: 1.8.0-develop
4+
version: 1.9.0-develop
5+
appVersion: 1.9.0-develop
66
icon: https://raw.githubusercontent.com/cncf/artwork/master/projects/openebs/icon/color/openebs-icon-color.png
77
home: https://openebs.io/
88
keywords:
@@ -16,5 +16,5 @@ sources:
1616
- https://github.com/openebs/lvm-localpv
1717
dependencies:
1818
- name: crds
19-
version: 1.8.0-develop
19+
version: 1.9.0-develop
2020
condition: crds.enabled
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
apiVersion: v2
22
name: crds
3-
version: 1.8.0-develop
3+
version: 1.9.0-develop
44
description: A Helm chart that collects CustomResourceDefinitions (CRDs) from lvm-localpv.

deploy/helm/charts/values.yaml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ lvmNode:
3838
# microk8s where kubelet dir is different
3939
kubeletDir: "/var/lib/kubelet/"
4040
resources: {}
41-
# limits:
42-
# cpu: 10m
43-
# memory: 32Mi
44-
# requests:
45-
# cpu: 10m
46-
# memory: 32Mi
41+
# limits:
42+
# cpu: 10m
43+
# memory: 32Mi
44+
# requests:
45+
# cpu: 10m
46+
# memory: 32Mi
4747
## Labels to be added to openebs-lvm node pods
4848
podLabels:
4949
app: openebs-lvm-node
@@ -121,12 +121,12 @@ lvmController:
121121
annotations: {}
122122
podAnnotations: {}
123123
resources: {}
124-
# limits:
125-
# cpu: 10m
126-
# memory: 32Mi
127-
# requests:
128-
# cpu: 10m
129-
# memory: 32Mi
124+
# limits:
125+
# cpu: 10m
126+
# memory: 32Mi
127+
# requests:
128+
# cpu: 10m
129+
# memory: 32Mi
130130
## Labels to be added to openebs-lvm controller pods
131131
podLabels:
132132
name: openebs-lvm-controller
@@ -154,11 +154,11 @@ lvmPlugin:
154154
image:
155155
# Make sure that registry name end with a '/'.
156156
# For example : registry.k8s.io/ is a correct value here and quay.io is incorrect
157-
registry:
157+
registry: docker.io/
158158
repository: openebs/lvm-driver
159159
pullPolicy: IfNotPresent
160160
# Overrides the image tag whose default is the chart appVersion.
161-
tag: 1.8.0-develop
161+
tag: 1.9.0-develop
162162
ioLimits:
163163
enabled: false
164164
containerRuntime: containerd

pkg/driver/controller.go

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,6 @@ func CreateLVMVolume(ctx context.Context, req *csi.CreateVolumeRequest,
365365
}
366366
klog.Infof("scheduling the volume %s/%s on node %s",
367367
params.VgPattern.String(), volName, owner)
368-
369368
volObj, err := volbuilder.NewBuilder().
370369
WithName(volName).
371370
WithCapacity(capacity).
@@ -664,14 +663,19 @@ func (cs *controller) CreateSnapshot(
664663
}
665664

666665
snapTimeStamp := time.Now().Unix()
667-
state, err := lvm.GetLVMSnapshotStatus(req.Name)
668-
666+
var lvmSnap *lvmapi.LVMSnapshot
667+
var restoreSize int64
668+
lvmSnap, err = waitForLVMSnapshotReady(req.Name)
669669
if err == nil {
670+
if lvmSnap.Spec.ThinProvision {
671+
restoreSize = lvmSnap.Status.LvSize.Value()
672+
}
670673
return csipayload.NewCreateSnapshotResponseBuilder().
671674
WithSourceVolumeID(req.SourceVolumeId).
672675
WithSnapshotID(req.SourceVolumeId+"@"+req.Name).
673676
WithCreationTime(snapTimeStamp, 0).
674-
WithReadyToUse(state == lvm.LVMStatusReady).
677+
WithReadyToUse(lvmSnap.Status.State == lvm.LVMStatusReady).
678+
WithSize(restoreSize).
675679
Build(), nil
676680
}
677681

@@ -751,16 +755,47 @@ func (cs *controller) CreateSnapshot(
751755
)
752756
}
753757

754-
state, _ = lvm.GetLVMSnapshotStatus(req.Name)
758+
lvmSnap, err = waitForLVMSnapshotReady(req.Name)
759+
if err != nil {
760+
return nil, status.Errorf(
761+
codes.ResourceExhausted,
762+
"failed to handle CreateSnapshotRequest for %s: %s, {%s}",
763+
req.SourceVolumeId, req.Name,
764+
err.Error(),
765+
)
766+
}
767+
if lvmSnap.Spec.ThinProvision {
768+
restoreSize = lvmSnap.Status.LvSize.Value()
769+
}
755770

756771
return csipayload.NewCreateSnapshotResponseBuilder().
757772
WithSourceVolumeID(req.SourceVolumeId).
758773
WithSnapshotID(req.SourceVolumeId+"@"+req.Name).
759774
WithCreationTime(snapTimeStamp, 0).
760-
WithReadyToUse(state == lvm.LVMStatusReady).
775+
WithReadyToUse(lvmSnap.Status.State == lvm.LVMStatusReady).
776+
WithSize(restoreSize).
761777
Build(), nil
762778
}
763779

780+
// waitForLVMSnapshotReady waits for lvm snapshot to be ready and returns
781+
// the lvm snapshot CR object
782+
func waitForLVMSnapshotReady(snapName string) (*lvmapi.LVMSnapshot, error) {
783+
var err error
784+
var snap *lvmapi.LVMSnapshot
785+
for i := 0; i < 20; i++ {
786+
snap, err = lvm.GetLVMSnapshot(snapName)
787+
if k8serror.IsNotFound(err) {
788+
return snap, err
789+
} else if err == nil {
790+
if snap.Status.State == lvm.LVMStatusReady {
791+
break
792+
}
793+
}
794+
time.Sleep(time.Duration(100 * time.Millisecond))
795+
}
796+
return snap, err
797+
}
798+
764799
func getSnapSize(params *SnapshotParams, capacity int64) int64 {
765800
var snapSize int64
766801
if !params.AbsSnapSize {

scripts/test-update-chart-version.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ run_test "Test 9: On tag creation, version to be reflected on release/x.y branch
6767
--tag "v1.2.0" --dry-run --chart-version "1.2.0-prerelease"
6868

6969
run_test "Test 10: On tag creation, version to be reflected on release/x.y branch, tag is in future" \
70-
"For release/x.y branch the current chart version(1.2.0-prerelease)'s X.Y must exactly match X.Y from tag (1.5.0)" \
70+
"ERROR: For release/x.y branch the current chart version(1.2.0-prerelease)'s X.Y must exactly match X.Y from tag (1.5.0)" \
7171
--tag "v1.5.0" --dry-run --chart-version "1.2.0-prerelease"
7272

7373
run_test "Test 11: On tag creation, version to be reflected on release/x.y branch, tag is in past" \
74-
"For release/x.y branch the current chart version(1.2.0-prerelease)'s X.Y must exactly match X.Y from tag (1.0.0)" \
74+
"ERROR: For release/x.y branch the current chart version(1.2.0-prerelease)'s X.Y must exactly match X.Y from tag (1.0.0)" \
7575
--tag "v1.0.0" --dry-run --chart-version "1.2.0-prerelease"
7676

7777
run_test "Test 12: On tag creation, version to be reflected on release/x.y branch, the current chart version is not prerelease" \
78-
"Chart version(1.2.0-develop) should be a prerelease format to proceed for tag creation flow" \
78+
"ERROR: Chart version(1.2.0-develop) should be a prerelease format to proceed for tag creation flow" \
7979
--tag "v1.0.0" --dry-run --chart-version "1.2.0-develop"
8080

8181
run_test "Test 13: rc tag, with chart type prerelease" \

scripts/yq_utils.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
# this function gets around that using diff with --ignore-blank-lines
33
yq_ibl()
44
{
5-
set +e
6-
diff_out=$(diff -B <(yq '.' "$2") <(yq "$1" "$2")) || error=$?
5+
error=0
6+
diff_out=$(diff -B <(cat "$2") <(yq "$1" "$2")) || error=$?
77
if [ "$error" != "0" ] && [ "$error" != "1" ]; then
88
exit "$error"
99
fi
1010
if [ -n "$diff_out" ]; then
1111
echo "$diff_out" | patch --quiet --no-backup-if-mismatch "$2" -
1212
fi
13-
set -euo pipefail
1413
}

0 commit comments

Comments
 (0)