diff --git a/cmd/manager/main.go b/cmd/manager/main.go
index 76706f68643..3c58e789819 100644
--- a/cmd/manager/main.go
+++ b/cmd/manager/main.go
@@ -361,15 +361,6 @@ func main() {
os.Exit(1)
}
- if err = (&k8scorecontrollers.PersistentVolumeClaimReconciler{
- Client: mgr.GetClient(),
- Scheme: mgr.GetScheme(),
- Recorder: mgr.GetEventRecorderFor("pvc-controller"),
- }).SetupWithManager(mgr); err != nil {
- setupLog.Error(err, "unable to create controller", "controller", "PersistentVolumeClaim")
- os.Exit(1)
- }
-
if err = (&appscontrollers.ComponentClassReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
diff --git a/controllers/apps/operations/suite_test.go b/controllers/apps/operations/suite_test.go
index b0585d78d6b..6dd11620c18 100644
--- a/controllers/apps/operations/suite_test.go
+++ b/controllers/apps/operations/suite_test.go
@@ -42,7 +42,6 @@ import (
appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
workloads "github.com/apecloud/kubeblocks/apis/workloads/v1alpha1"
"github.com/apecloud/kubeblocks/controllers/apps/components"
- "github.com/apecloud/kubeblocks/controllers/k8score"
"github.com/apecloud/kubeblocks/internal/constant"
intctrlutil "github.com/apecloud/kubeblocks/internal/controllerutil"
"github.com/apecloud/kubeblocks/internal/testutil"
@@ -120,12 +119,6 @@ var _ = BeforeSuite(func() {
Expect(err).ToNot(HaveOccurred())
eventRecorder = k8sManager.GetEventRecorderFor("event-controller")
- err = (&k8score.PersistentVolumeClaimReconciler{
- Client: k8sManager.GetClient(),
- Scheme: k8sManager.GetScheme(),
- Recorder: k8sManager.GetEventRecorderFor("pvc-controller"),
- }).SetupWithManager(k8sManager)
- Expect(err).ToNot(HaveOccurred())
appsv1alpha1.RegisterWebhookManager(k8sManager)
diff --git a/controllers/apps/operations/volume_expansion_test.go b/controllers/apps/operations/volume_expansion_test.go
index 10f5241311d..96659da2295 100644
--- a/controllers/apps/operations/volume_expansion_test.go
+++ b/controllers/apps/operations/volume_expansion_test.go
@@ -145,56 +145,6 @@ var _ = Describe("OpsRequest Controller Volume Expansion Handler", func() {
Expect(err).Should(BeNil())
}
- testWarningEventOnPVC := func(reqCtx intctrlutil.RequestCtx, clusterObject *appsv1alpha1.Cluster, opsRes *OpsResource) {
- // init resources for volume expansion
- comp := opsRes.Cluster.Spec.GetComponentByName(consensusCompName)
- newOps, pvcNames := initResourcesForVolumeExpansion(clusterObject, opsRes, "4Gi", int(comp.Replicas))
-
- By("mock run volumeExpansion action and reconcileAction")
- mockVolumeExpansionActionAndReconcile(reqCtx, opsRes, newOps, pvcNames)
-
- By("test warning event and volumeExpansion failed")
- // test when the event does not reach the conditions
- event := &corev1.Event{
- Count: 1,
- Type: corev1.EventTypeWarning,
- Reason: VolumeResizeFailed,
- Message: OptimisticLockErrorMsg,
- }
- stsInvolvedObject := corev1.ObjectReference{
- Name: pvcNames[0],
- Kind: constant.PersistentVolumeClaimKind,
- Namespace: "default",
- }
- event.InvolvedObject = stsInvolvedObject
- pvcEventHandler := PersistentVolumeClaimEventHandler{}
- Expect(pvcEventHandler.Handle(k8sClient, reqCtx, eventRecorder, event)).Should(Succeed())
-
- // test when the event reaches the conditions
- event.Count = 5
- event.FirstTimestamp = metav1.Time{Time: time.Now()}
- event.LastTimestamp = metav1.Time{Time: time.Now().Add(61 * time.Second)}
-
- By("expect for progressDetail is not failed")
- Expect(pvcEventHandler.Handle(k8sClient, reqCtx, eventRecorder, event)).Should(Succeed())
- Eventually(testapps.CheckObj(&testCtx, client.ObjectKeyFromObject(newOps), func(g Gomega, tmpOps *appsv1alpha1.OpsRequest) {
- progressDetails := tmpOps.Status.Components[consensusCompName].ProgressDetails
- g.Expect(len(progressDetails) > 0).Should(BeTrue())
- progressDetail := findStatusProgressDetail(progressDetails, getPVCProgressObjectKey(pvcNames[0]))
- g.Expect(progressDetail.Status).ShouldNot(Equal(appsv1alpha1.FailedProgressStatus))
- })).Should(Succeed())
-
- By("expect for progressDetail is failed")
- event.Message = "You've reached the maximum modification rate per volume limit. Wait at least 6 hours between modifications per EBS volume."
- Expect(pvcEventHandler.Handle(k8sClient, reqCtx, eventRecorder, event)).Should(Succeed())
- Eventually(testapps.CheckObj(&testCtx, client.ObjectKeyFromObject(newOps), func(g Gomega, tmpOps *appsv1alpha1.OpsRequest) {
- progressDetails := tmpOps.Status.Components[consensusCompName].ProgressDetails
- g.Expect(len(progressDetails) > 0).Should(BeTrue())
- progressDetail := findStatusProgressDetail(progressDetails, getPVCProgressObjectKey(pvcNames[0]))
- g.Expect(progressDetail.Status).Should(Equal(appsv1alpha1.FailedProgressStatus))
- })).Should(Succeed())
- }
-
testVolumeExpansion := func(reqCtx intctrlutil.RequestCtx, clusterObject *appsv1alpha1.Cluster, opsRes *OpsResource, randomStr string) {
// mock cluster is Running to support volume expansion ops
Expect(testapps.ChangeObjStatus(&testCtx, clusterObject, func() {
@@ -262,7 +212,6 @@ var _ = Describe("OpsRequest Controller Volume Expansion Handler", func() {
By("test handle the invalid volumeExpansion OpsRequest")
pvc := &corev1.PersistentVolumeClaim{}
Expect(k8sClient.Get(ctx, client.ObjectKey{Name: pvcNames[0], Namespace: testCtx.DefaultNamespace}, pvc)).Should(Succeed())
- Expect(handleVolumeExpansionWithPVC(intctrlutil.RequestCtx{Ctx: ctx}, k8sClient, pvc)).Should(Succeed())
Eventually(testapps.GetClusterPhase(&testCtx, client.ObjectKeyFromObject(clusterObject))).Should(Equal(appsv1alpha1.RunningClusterPhase))
}
@@ -296,9 +245,6 @@ var _ = Describe("OpsRequest Controller Volume Expansion Handler", func() {
By("Test VolumeExpansion")
testVolumeExpansion(reqCtx, clusterObject, opsRes, randomStr)
- By("Test Warning Event occurs during volume expanding")
- testWarningEventOnPVC(reqCtx, clusterObject, opsRes)
-
By("Test delete the Running VolumeExpansion OpsRequest")
testDeleteRunningVolumeExpansion(clusterObject, opsRes)
})
diff --git a/controllers/apps/operations/volume_expansion_updater.go b/controllers/apps/operations/volume_expansion_updater.go
deleted file mode 100644
index ce49a2bec17..00000000000
--- a/controllers/apps/operations/volume_expansion_updater.go
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
-Copyright (C) 2022-2023 ApeCloud Co., Ltd
-
-This file is part of KubeBlocks project
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU Affero General Public License for more details.
-
-You should have received a copy of the GNU Affero General Public License
-along with this program. If not, see .
-*/
-
-package operations
-
-import (
- "strings"
- "time"
-
- "golang.org/x/exp/slices"
- corev1 "k8s.io/api/core/v1"
- "k8s.io/client-go/tools/record"
- "sigs.k8s.io/controller-runtime/pkg/client"
-
- appsv1alpha1 "github.com/apecloud/kubeblocks/apis/apps/v1alpha1"
- opsutil "github.com/apecloud/kubeblocks/controllers/apps/operations/util"
- "github.com/apecloud/kubeblocks/controllers/k8score"
- "github.com/apecloud/kubeblocks/internal/constant"
- intctrlutil "github.com/apecloud/kubeblocks/internal/controllerutil"
-)
-
-type PersistentVolumeClaimEventHandler struct {
-}
-
-const (
- // PVCEventTimeOut timeout of the pvc event
- PVCEventTimeOut = 30 * time.Second
-
- // VolumeResizeFailed the event reason of volume resize failed on external-resizer(the csi driver sidecar)
- VolumeResizeFailed = "VolumeResizeFailed"
- // FileSystemResizeFailed the event reason of fileSystem resize failed on kubelet volume manager
- FileSystemResizeFailed = "FileSystemResizeFailed"
- OptimisticLockErrorMsg = "the object has been modified; please apply your changes to the latest version and try again"
-)
-
-func init() {
- k8score.PersistentVolumeClaimHandlerMap["volume-expansion"] = handleVolumeExpansionWithPVC
- k8score.EventHandlerMap["volume-expansion"] = PersistentVolumeClaimEventHandler{}
-}
-
-// handleVolumeExpansionOperation handles the pvc for the volume expansion OpsRequest.
-// it will be triggered when the PersistentVolumeClaim has changed.
-func handleVolumeExpansionWithPVC(reqCtx intctrlutil.RequestCtx, cli client.Client, pvc *corev1.PersistentVolumeClaim) error {
- opsRequestList, err := appsv1alpha1.GetRunningOpsByOpsType(reqCtx.Ctx, cli,
- pvc.Labels[constant.AppInstanceLabelKey], pvc.Namespace, string(appsv1alpha1.VolumeExpansionType))
- if err != nil {
- return err
- }
- if len(opsRequestList) == 0 {
- return nil
- }
- // notice the OpsRequest to reconcile
- for _, ops := range opsRequestList {
- if err = opsutil.PatchOpsRequestReconcileAnnotation(reqCtx.Ctx, cli, pvc.Namespace, ops.Name); err != nil {
- return err
- }
- }
- return nil
-}
-
-// Handle the warning events of PVCs. if the events are resize-failed events, update the OpsRequest.status.
-func (pvcEventHandler PersistentVolumeClaimEventHandler) Handle(cli client.Client,
- reqCtx intctrlutil.RequestCtx,
- recorder record.EventRecorder,
- event *corev1.Event) error {
- if !pvcEventHandler.isTargetResizeFailedEvents(event) {
- return nil
- }
- if !k8score.IsOvertimeEvent(event, PVCEventTimeOut) {
- return nil
- }
- var (
- pvc = &corev1.PersistentVolumeClaim{}
- err error
- )
- // get pvc object
- if err = cli.Get(reqCtx.Ctx, client.ObjectKey{
- Name: event.InvolvedObject.Name,
- Namespace: event.InvolvedObject.Namespace,
- }, pvc); err != nil {
- return err
- }
-
- // check if the pvc is managed by kubeblocks
- if !intctrlutil.WorkloadFilterPredicate(pvc) {
- return nil
- }
-
- // ignore the OptimisticLockErrorMsg
- if strings.Contains(event.Message, OptimisticLockErrorMsg) {
- return nil
- }
- // here, if the volume expansion ops is running, change the pvc status to Failed on the OpsRequest.
- return pvcEventHandler.handlePVCFailedStatusOnRunningOpsRequests(cli, reqCtx, recorder, event, pvc)
-}
-
-// isTargetResizeFailedEvents checks the event is the resize-failed events.
-func (pvcEventHandler PersistentVolumeClaimEventHandler) isTargetResizeFailedEvents(event *corev1.Event) bool {
- // ignores ExternalExpanding event, this event always exists when using csi driver.
- return event.Type == corev1.EventTypeWarning && event.InvolvedObject.Kind == constant.PersistentVolumeClaimKind &&
- slices.Index([]string{VolumeResizeFailed, FileSystemResizeFailed}, event.Reason) != -1
-}
-
-// handlePVCFailedStatusOnOpsRequest if the volume expansion ops is running, changes the pvc status to Failed on the OpsRequest,
-func (pvcEventHandler PersistentVolumeClaimEventHandler) handlePVCFailedStatusOnRunningOpsRequests(cli client.Client,
- reqCtx intctrlutil.RequestCtx,
- recorder record.EventRecorder,
- event *corev1.Event,
- pvc *corev1.PersistentVolumeClaim) error {
- var (
- cluster = &appsv1alpha1.Cluster{}
- err error
- )
- // get cluster object from the pvc
- if err = cli.Get(reqCtx.Ctx, client.ObjectKey{
- Name: pvc.Labels[constant.AppInstanceLabelKey],
- Namespace: pvc.Namespace,
- }, cluster); err != nil {
- return err
- }
- opsRequestList, err := appsv1alpha1.GetRunningOpsByOpsType(reqCtx.Ctx, cli,
- pvc.Labels[constant.AppInstanceLabelKey], pvc.Namespace, string(appsv1alpha1.VolumeExpansionType))
- if err != nil {
- return err
- }
- if len(opsRequestList) == 0 {
- return nil
- }
- for _, ops := range opsRequestList {
- if err = pvcEventHandler.handlePVCFailedStatus(cli, reqCtx, recorder, event, pvc, &ops); err != nil {
- return err
- }
- }
- return nil
-}
-
-func (pvcEventHandler PersistentVolumeClaimEventHandler) handlePVCFailedStatus(cli client.Client,
- reqCtx intctrlutil.RequestCtx,
- recorder record.EventRecorder,
- event *corev1.Event,
- pvc *corev1.PersistentVolumeClaim,
- opsRequest *appsv1alpha1.OpsRequest) error {
- compsStatus := opsRequest.Status.Components
- if compsStatus == nil {
- return nil
- }
- componentName := pvc.Labels[constant.KBAppComponentLabelKey]
- vctName := pvc.Labels[constant.VolumeClaimTemplateNameLabelKey]
- patch := client.MergeFrom(opsRequest.DeepCopy())
- var isChanged bool
- // change the pvc status to Failed in OpsRequest.status.components.
- for cName, component := range compsStatus {
- if cName != componentName {
- continue
- }
- // save the failed message to the progressDetail.
- objectKey := getPVCProgressObjectKey(pvc.Name)
- progressDetail := findStatusProgressDetail(component.ProgressDetails, objectKey)
- if progressDetail == nil || progressDetail.Message != event.Message {
- isChanged = true
- }
- progressDetail = &appsv1alpha1.ProgressStatusDetail{
- Group: vctName,
- ObjectKey: objectKey,
- Status: appsv1alpha1.FailedProgressStatus,
- Message: event.Message,
- }
-
- setComponentStatusProgressDetail(recorder, opsRequest, &component.ProgressDetails, *progressDetail)
- compsStatus[cName] = component
- break
- }
- if !isChanged {
- return nil
- }
- if err := cli.Status().Patch(reqCtx.Ctx, opsRequest, patch); err != nil {
- return err
- }
- recorder.Event(opsRequest, corev1.EventTypeWarning, event.Reason, event.Message)
- return nil
-}
diff --git a/controllers/apps/opsrequest_controller.go b/controllers/apps/opsrequest_controller.go
index 18c3909dfc4..94a8945eb65 100644
--- a/controllers/apps/opsrequest_controller.go
+++ b/controllers/apps/opsrequest_controller.go
@@ -85,6 +85,7 @@ func (r *OpsRequestReconciler) SetupWithManager(mgr ctrl.Manager) error {
For(&appsv1alpha1.OpsRequest{}).
Watches(&appsv1alpha1.Cluster{}, handler.EnqueueRequestsFromMapFunc(r.parseAllOpsRequest)).
Watches(&dpv1alpha1.Backup{}, handler.EnqueueRequestsFromMapFunc(r.parseBackupOpsRequest)).
+ Watches(&corev1.PersistentVolumeClaim{}, handler.EnqueueRequestsFromMapFunc(r.parseVolumeExpansionOpsRequest)).
Complete(r)
}
@@ -305,6 +306,32 @@ func (r *OpsRequestReconciler) parseAllOpsRequest(ctx context.Context, object cl
return requests
}
+func (r *OpsRequestReconciler) parseVolumeExpansionOpsRequest(ctx context.Context, object client.Object) []reconcile.Request {
+ pvc := object.(*corev1.PersistentVolumeClaim)
+ if pvc.Labels[constant.AppManagedByLabelKey] != constant.AppName {
+ return nil
+ }
+ clusterName := pvc.Labels[constant.AppInstanceLabelKey]
+ if clusterName == "" {
+ return nil
+ }
+ opsRequestList, err := appsv1alpha1.GetRunningOpsByOpsType(ctx, r.Client,
+ pvc.Labels[constant.AppInstanceLabelKey], pvc.Namespace, string(appsv1alpha1.VolumeExpansionType))
+ if err != nil {
+ return nil
+ }
+ var requests []reconcile.Request
+ for _, v := range opsRequestList {
+ requests = append(requests, reconcile.Request{
+ NamespacedName: types.NamespacedName{
+ Namespace: v.Namespace,
+ Name: v.Name,
+ },
+ })
+ }
+ return requests
+}
+
func (r *OpsRequestReconciler) parseBackupOpsRequest(ctx context.Context, object client.Object) []reconcile.Request {
backup := object.(*dpv1alpha1.Backup)
var (
diff --git a/controllers/k8score/pvc_controller.go b/controllers/k8score/pvc_controller.go
deleted file mode 100644
index 96132e44196..00000000000
--- a/controllers/k8score/pvc_controller.go
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
-Copyright (C) 2022-2023 ApeCloud Co., Ltd
-
-This file is part of KubeBlocks project
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU Affero General Public License for more details.
-
-You should have received a copy of the GNU Affero General Public License
-along with this program. If not, see .
-*/
-
-package k8score
-
-import (
- "context"
-
- corev1 "k8s.io/api/core/v1"
- apierrors "k8s.io/apimachinery/pkg/api/errors"
- "k8s.io/apimachinery/pkg/runtime"
- "k8s.io/client-go/tools/record"
- ctrl "sigs.k8s.io/controller-runtime"
- "sigs.k8s.io/controller-runtime/pkg/builder"
- "sigs.k8s.io/controller-runtime/pkg/client"
- "sigs.k8s.io/controller-runtime/pkg/log"
- "sigs.k8s.io/controller-runtime/pkg/predicate"
-
- intctrlutil "github.com/apecloud/kubeblocks/internal/controllerutil"
-)
-
-type HandlePersistentVolumeClaim func(reqCtx intctrlutil.RequestCtx, cli client.Client, pvc *corev1.PersistentVolumeClaim) error
-
-// PersistentVolumeClaimReconciler reconciles a PersistentVolumeClaim object
-type PersistentVolumeClaimReconciler struct {
- client.Client
- Scheme *runtime.Scheme
- Recorder record.EventRecorder
-}
-
-var PersistentVolumeClaimHandlerMap = map[string]HandlePersistentVolumeClaim{}
-
-// +kubebuilder:rbac:groups=core,resources=persistentvolumeclaims,verbs=get;list;watch;create;update;patch;delete
-
-// Reconcile is part of the main kubernetes reconciliation loop which aims to
-// move the current state of the cluster closer to the desired state.
-//
-// For more details, check Reconcile and its Result here:
-// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.14.4/pkg/reconcile
-func (r *PersistentVolumeClaimReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
- reqCtx := intctrlutil.RequestCtx{
- Ctx: ctx,
- Req: req,
- Log: log.FromContext(ctx).WithValues("PersistentVolumeClaim", req.NamespacedName),
- }
-
- reqCtx.Log.V(1).Info("PersistentVolumeClaim watcher")
-
- pvc := &corev1.PersistentVolumeClaim{}
- if err := r.Client.Get(ctx, req.NamespacedName, pvc); err != nil {
- return intctrlutil.CheckedRequeueWithError(err, reqCtx.Log, "getPVCError")
- }
-
- // skip if pvc is being deleted
- if !pvc.DeletionTimestamp.IsZero() {
- return intctrlutil.Reconciled()
- }
-
- for _, handlePVC := range PersistentVolumeClaimHandlerMap {
- // ignores the not found error.
- if err := handlePVC(reqCtx, r.Client, pvc); err != nil && !apierrors.IsNotFound(err) {
- return intctrlutil.RequeueWithError(err, reqCtx.Log, "handlePVCError")
- }
- }
- return intctrlutil.Reconciled()
-}
-
-// SetupWithManager sets up the controller with the Manager.
-func (r *PersistentVolumeClaimReconciler) SetupWithManager(mgr ctrl.Manager) error {
- return ctrl.NewControllerManagedBy(mgr).
- For(&corev1.PersistentVolumeClaim{}, builder.WithPredicates(predicate.NewPredicateFuncs(intctrlutil.WorkloadFilterPredicate))).
- Complete(r)
-}
diff --git a/controllers/k8score/pvc_controller_test.go b/controllers/k8score/pvc_controller_test.go
deleted file mode 100644
index c4143fc745f..00000000000
--- a/controllers/k8score/pvc_controller_test.go
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
-Copyright (C) 2022-2023 ApeCloud Co., Ltd
-
-This file is part of KubeBlocks project
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU Affero General Public License for more details.
-
-You should have received a copy of the GNU Affero General Public License
-along with this program. If not, see .
-*/
-
-package k8score
-
-import (
- "fmt"
-
- . "github.com/onsi/ginkgo/v2"
- . "github.com/onsi/gomega"
-
- corev1 "k8s.io/api/core/v1"
- "k8s.io/apimachinery/pkg/api/resource"
- "sigs.k8s.io/controller-runtime/pkg/client"
-
- intctrlutil "github.com/apecloud/kubeblocks/internal/controllerutil"
- "github.com/apecloud/kubeblocks/internal/generics"
- testapps "github.com/apecloud/kubeblocks/internal/testutil/apps"
-)
-
-var _ = Describe("PersistentVolumeClaim Controller", func() {
- cleanEnv := func() {
- // must wait till resources deleted and no longer existed before the testcases start,
- // otherwise if later it needs to create some new resource objects with the same name,
- // in race conditions, it will find the existence of old objects, resulting failure to
- // create the new objects.
- By("clean resources")
-
- // delete rest mocked objects
- inNS := client.InNamespace(testCtx.DefaultNamespace)
- ml := client.HasLabels{testCtx.TestObjLabelKey}
- // namespaced
- testapps.ClearResourcesWithRemoveFinalizerOption(&testCtx, generics.PersistentVolumeClaimSignature, true, inNS, ml)
- }
-
- BeforeEach(cleanEnv)
-
- AfterEach(cleanEnv)
-
- createPVC := func(pvcName string) *corev1.PersistentVolumeClaim {
- By("By assure an default storageClass")
- return testapps.NewPersistentVolumeClaimFactory(testCtx.DefaultNamespace, pvcName, "apecloud-mysql",
- "consensus", "data").SetStorage("2Gi").
- SetStorageClass("csi-hostpath-sc").Create(&testCtx).GetObject()
- }
-
- handlePersistentVolumeClaim := func(reqCtx intctrlutil.RequestCtx, cli client.Client, pvc *corev1.PersistentVolumeClaim) error {
- patch := client.MergeFrom(pvc.DeepCopy())
- pvc.Annotations["kubeblocks.io/test"] = "test_pvc"
- return cli.Patch(ctx, pvc, patch)
- }
-
- Context("test creating PersistentVolumeClaim", func() {
- It("should handle it properly", func() {
- By("register an pvcHandler for testing")
- PersistentVolumeClaimHandlerMap["pvc-controller"] = handlePersistentVolumeClaim
-
- By("test PersistentVolumeClaim changes")
- pvcName := fmt.Sprintf("pvc-%s", testCtx.GetRandomStr())
- pvc := createPVC(pvcName)
- Expect(testapps.GetAndChangeObj(&testCtx, client.ObjectKeyFromObject(pvc), func(tmpPvc *corev1.PersistentVolumeClaim) {
- pvc.Spec.Resources.Requests[corev1.ResourceStorage] = resource.MustParse("4Gi")
- })()).Should(Succeed())
-
- // wait until pvc patched the annotation by storageClass controller.
- Eventually(testapps.CheckObj(&testCtx, client.ObjectKeyFromObject(pvc), func(g Gomega, tmpPVC *corev1.PersistentVolumeClaim) {
- g.Expect(tmpPVC.Annotations["kubeblocks.io/test"] == "test_pvc").Should(BeTrue())
- })).Should(Succeed())
- })
- })
-})
diff --git a/controllers/k8score/suite_test.go b/controllers/k8score/suite_test.go
index f81b2aea10a..52f467ef7b6 100644
--- a/controllers/k8score/suite_test.go
+++ b/controllers/k8score/suite_test.go
@@ -119,13 +119,6 @@ var _ = BeforeSuite(func() {
}).SetupWithManager(k8sManager)
Expect(err).ToNot(HaveOccurred())
- err = (&PersistentVolumeClaimReconciler{
- Client: k8sManager.GetClient(),
- Scheme: k8sManager.GetScheme(),
- Recorder: k8sManager.GetEventRecorderFor("pvc-controller"),
- }).SetupWithManager(k8sManager)
- Expect(err).ToNot(HaveOccurred())
-
testCtx = testutil.NewDefaultTestContext(ctx, k8sClient, testEnv)
go func() {