Issue 8344: constrain data path expose (#9064)
Run the E2E test on kind / build (push) Failing after 7m38s
Run the E2E test on kind / setup-test-matrix (push) Successful in 4s
Run the E2E test on kind / run-e2e-test (push) Has been skipped
Main CI / Build (push) Failing after 39s
Close stale issues and PRs / stale (push) Successful in 22s
Trivy Nightly Scan / Trivy nightly scan (velero, main) (push) Failing after 1m32s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-aws, main) (push) Failing after 1m41s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-gcp, main) (push) Failing after 1m30s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-microsoft-azure, main) (push) Failing after 1m18s

* issue 8344: constrain data path exposure.

Signed-off-by: Lyndon-Li <lyonghui@vmware.com>
This commit is contained in:
lyndon-li
2025-07-18 13:32:45 +08:00
committed by GitHub
parent 29a8bc4492
commit 06d305ea47
16 changed files with 671 additions and 57 deletions
@@ -144,6 +144,7 @@ func initPVBReconcilerWithError(needError ...error) (*PodVolumeBackupReconciler,
nil,
fakeKubeClient,
dataPathMgr,
nil,
"test-node",
time.Minute*5,
time.Minute,
@@ -224,6 +225,7 @@ func TestPVBReconcile(t *testing.T) {
getExposeNil bool
fsBRInitErr error
fsBRStartErr error
constrained bool
expectedErr string
expectedResult *ctrl.Result
expectDataPath bool
@@ -317,6 +319,13 @@ func TestPVBReconcile(t *testing.T) {
name: "Unknown pvb status",
pvb: pvbBuilder().Phase("Unknown").Finalizers([]string{PodVolumeFinalizer}).Result(),
},
{
name: "new pvb but constrained",
pvb: pvbBuilder().Finalizers([]string{PodVolumeFinalizer}).Node("test-node").Result(),
constrained: true,
expected: pvbBuilder().Finalizers([]string{PodVolumeFinalizer}).Result(),
expectedResult: &ctrl.Result{Requeue: true, RequeueAfter: time.Second * 5},
},
{
name: "new pvb but accept failed",
pvb: pvbBuilder().Finalizers([]string{PodVolumeFinalizer}).Node("test-node").Result(),
@@ -480,6 +489,10 @@ func TestPVBReconcile(t *testing.T) {
r.cancelledPVB[test.pvb.Name] = test.sportTime.Time
}
if test.constrained {
r.vgdpCounter = &exposer.VgdpCounter{}
}
if test.needMockExposer {
r.exposer = &fakePvbExposer{r.client, r.clock, test.peekErr, test.exposeErr, test.getExposeErr, test.getExposeNil}
}
@@ -525,13 +538,13 @@ func TestPVBReconcile(t *testing.T) {
assert.Equal(t, test.expectedResult.RequeueAfter, actualResult.RequeueAfter)
}
if test.expected != nil || test.expectDeleted {
pvb := velerov1api.PodVolumeBackup{}
err = r.client.Get(ctx, client.ObjectKey{
Name: test.pvb.Name,
Namespace: test.pvb.Namespace,
}, &pvb)
pvb := velerov1api.PodVolumeBackup{}
err = r.client.Get(ctx, client.ObjectKey{
Name: test.pvb.Name,
Namespace: test.pvb.Namespace,
}, &pvb)
if test.expected != nil || test.expectDeleted {
if test.expectDeleted {
assert.True(t, apierrors.IsNotFound(err))
} else {
@@ -555,6 +568,12 @@ func TestPVBReconcile(t *testing.T) {
} else {
assert.Empty(t, r.cancelledPVB)
}
if isPVBInFinalState(&pvb) || pvb.Status.Phase == velerov1api.PodVolumeBackupPhaseInProgress {
assert.NotContains(t, pvb.Labels, exposer.ExposeOnGoingLabel)
} else if pvb.Status.Phase == velerov1api.PodVolumeBackupPhaseAccepted {
assert.Contains(t, pvb.Labels, exposer.ExposeOnGoingLabel)
}
})
}
}