Skip to content

Commit

Permalink
Merge branch 'main' into feature/volume-attributes-class
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-inf committed Jan 10, 2025
2 parents 4475349 + ac3c0c8 commit 77dfe90
Show file tree
Hide file tree
Showing 90 changed files with 2,019 additions and 1,095 deletions.
4 changes: 4 additions & 0 deletions apis/operations/v1alpha1/opsrequest_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,10 @@ type RebuildInstance struct {
// +optional
BackupName string `json:"backupName,omitempty"`

// When multiple source targets exist of the backup, you must specify the source target to restore.
// +optional
SourceBackupTargetName string `json:"sourceBackupTargetName,omitempty"`

// Defines container environment variables for the restore process.
// merged with the ones specified in the Backup and ActionSet resources.
//
Expand Down
6 changes: 4 additions & 2 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ import (
workloadsv1 "github.com/apecloud/kubeblocks/apis/workloads/v1"
workloadsv1alpha1 "github.com/apecloud/kubeblocks/apis/workloads/v1alpha1"
appscontrollers "github.com/apecloud/kubeblocks/controllers/apps"
"github.com/apecloud/kubeblocks/controllers/apps/cluster"
"github.com/apecloud/kubeblocks/controllers/apps/component"
"github.com/apecloud/kubeblocks/controllers/apps/configuration"
experimentalcontrollers "github.com/apecloud/kubeblocks/controllers/experimental"
extensionscontrollers "github.com/apecloud/kubeblocks/controllers/extensions"
Expand Down Expand Up @@ -443,7 +445,7 @@ func main() {
os.Exit(1)
}

if err = (&appscontrollers.ClusterReconciler{
if err = (&cluster.ClusterReconciler{
Client: client,
Scheme: mgr.GetScheme(),
Recorder: mgr.GetEventRecorderFor("cluster-controller"),
Expand All @@ -453,7 +455,7 @@ func main() {
os.Exit(1)
}

if err = (&appscontrollers.ComponentReconciler{
if err = (&component.ComponentReconciler{
Client: client,
Scheme: mgr.GetScheme(),
Recorder: mgr.GetEventRecorderFor("component-controller"),
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/operations.kubeblocks.io_opsrequests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4207,6 +4207,10 @@ spec:
type: object
type: array
x-kubernetes-preserve-unknown-fields: true
sourceBackupTargetName:
description: When multiple source targets exist of the backup,
you must specify the source target to restore.
type: string
required:
- componentName
- instances
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package apps
package cluster

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package apps
package cluster

import (
"encoding/json"
Expand Down Expand Up @@ -422,7 +422,7 @@ var _ = Describe("Cluster Controller", func() {
clusterKey = client.ObjectKeyFromObject(clusterObj)

By("waiting for the cluster controller to create resources completely")
waitForCreatingResourceCompletely(clusterKey, compName, otherCompName)
waitForCreatingResourceCompletely(clusterKey)

By("scale in the target component")
Expect(testapps.GetAndChangeObj(&testCtx, clusterKey, func(cluster *appsv1.Cluster) {
Expand Down Expand Up @@ -512,19 +512,6 @@ var _ = Describe("Cluster Controller", func() {
g.Expect(svc.Spec.Selector).Should(HaveKeyWithValue(constant.RoleLabelKey, constant.Follower))
g.Expect(svc.Spec.ExternalTrafficPolicy).Should(BeEquivalentTo(corev1.ServiceExternalTrafficPolicyTypeLocal))
})).Should(Succeed())

By("check default component service created")
compSvcKey := types.NamespacedName{
Namespace: clusterKey.Namespace,
Name: constant.GenerateComponentServiceName(clusterObj.Name, compName, ""),
}
Eventually(testapps.CheckObj(&testCtx, compSvcKey, func(g Gomega, svc *corev1.Service) {
g.Expect(svc.Spec.Selector).Should(HaveKeyWithValue(constant.AppManagedByLabelKey, constant.AppName))
g.Expect(svc.Spec.Selector).Should(HaveKeyWithValue(constant.AppInstanceLabelKey, clusterObj.Name))
g.Expect(svc.Spec.Selector).Should(HaveKeyWithValue(constant.KBAppComponentLabelKey, compName))
g.Expect(svc.Spec.Selector).Should(HaveKey(constant.RoleLabelKey))
g.Expect(svc.Spec.Selector).Should(HaveKeyWithValue(constant.RoleLabelKey, constant.Leader))
})).Should(Succeed())
}

type expectService struct {
Expand Down Expand Up @@ -1199,7 +1186,8 @@ var _ = Describe("Cluster Controller", func() {
})).Should(Succeed())
})

Context("cluster component annotations and labels", func() {
// TODO: refactor the case and should not depend on objects created by the component controller
PContext("cluster component annotations and labels", func() {
BeforeEach(func() {
cleanEnv()
createAllDefinitionObjects()
Expand All @@ -1216,21 +1204,22 @@ var _ = Describe("Cluster Controller", func() {
(*metaMap)[key] = value
}

checkRelatedObject := func(compName string, checkFunc func(g Gomega, obj client.Object)) {
// check related services of the component
defaultSvcName := constant.GenerateComponentServiceName(clusterObj.Name, compName, "")
Eventually(testapps.CheckObj(&testCtx, client.ObjectKey{Name: defaultSvcName,
Namespace: testCtx.DefaultNamespace}, func(g Gomega, svc *corev1.Service) {
checkFunc(g, svc)
})).Should(Succeed())

// check related account secret of the component
rootAccountSecretName := constant.GenerateAccountSecretName(clusterObj.Name, compName, "root")
Eventually(testapps.CheckObj(&testCtx, client.ObjectKey{Name: rootAccountSecretName,
Namespace: testCtx.DefaultNamespace}, func(g Gomega, secret *corev1.Secret) {
checkFunc(g, secret)
})).Should(Succeed())
}
// TODO: remove it
// checkRelatedObject := func(compName string, checkFunc func(g Gomega, obj client.Object)) {
// // check related services of the component
// defaultSvcName := constant.GenerateComponentServiceName(clusterObj.Name, compName, "")
// Eventually(testapps.CheckObj(&testCtx, client.ObjectKey{Name: defaultSvcName,
// Namespace: testCtx.DefaultNamespace}, func(g Gomega, svc *corev1.Service) {
// checkFunc(g, svc)
// })).Should(Succeed())
//
// // check related account secret of the component
// rootAccountSecretName := constant.GenerateAccountSecretName(clusterObj.Name, compName, "root")
// Eventually(testapps.CheckObj(&testCtx, client.ObjectKey{Name: rootAccountSecretName,
// Namespace: testCtx.DefaultNamespace}, func(g Gomega, secret *corev1.Secret) {
// checkFunc(g, secret)
// })).Should(Succeed())
// }

testUpdateAnnoAndLabels := func(compName string,
changeCluster func(cluster *appsv1.Cluster),
Expand All @@ -1247,17 +1236,19 @@ var _ = Describe("Cluster Controller", func() {
checkWorkloadFunc(g, compObj.Spec.Labels, compObj.Spec.Annotations, false)
})).Should(Succeed())

By("check related objects annotations and labels")
checkRelatedObject(defaultCompName, func(g Gomega, obj client.Object) {
checkRelatedObjFunc(g, obj)
})

By("InstanceSet.spec.template.annotations/labels need to be consistent with component")
// The labels and annotations of the Pod will be kept consistent with those of the InstanceSet
Eventually(testapps.CheckObj(&testCtx, client.ObjectKey{Name: workloadName, Namespace: testCtx.DefaultNamespace},
func(g Gomega, instanceSet *workloadsv1.InstanceSet) {
checkWorkloadFunc(g, instanceSet.Spec.Template.GetLabels(), instanceSet.Spec.Template.GetAnnotations(), true)
})).Should(Succeed())
// TODO: remove it
// By("check related objects annotations and labels")
// checkRelatedObject(defaultCompName, func(g Gomega, obj client.Object) {
// checkRelatedObjFunc(g, obj)
// })

// TODO: remove it
// By("InstanceSet.spec.template.annotations/labels need to be consistent with component")
//// The labels and annotations of the Pod will be kept consistent with those of the InstanceSet
// Eventually(testapps.CheckObj(&testCtx, client.ObjectKey{Name: workloadName, Namespace: testCtx.DefaultNamespace},
// func(g Gomega, instanceSet *workloadsv1.InstanceSet) {
// checkWorkloadFunc(g, instanceSet.Spec.Template.GetLabels(), instanceSet.Spec.Template.GetAnnotations(), true)
// })).Should(Succeed())
}

It("test add/override annotations and labels", func() {
Expand Down Expand Up @@ -1342,7 +1333,6 @@ var _ = Describe("Cluster Controller", func() {
g.Expect(obj.GetLabels()[key2]).Should(Equal(value2))
g.Expect(obj.GetAnnotations()[key2]).Should(Equal(value2))
})

})
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package apps
package cluster

import (
"context"
Expand Down Expand Up @@ -194,11 +194,6 @@ func (c *clusterPlanBuilder) AddTransformer(transformer ...graph.Transformer) gr
return c
}

func (c *clusterPlanBuilder) AddParallelTransformer(transformer ...graph.Transformer) graph.PlanBuilder {
c.transformers = append(c.transformers, &ParallelTransformers{transformers: transformer})
return c
}

// Build runs all transformers to generate a plan
func (c *clusterPlanBuilder) Build() (graph.Plan, error) {
var err error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package apps
package cluster

import (
. "github.com/onsi/ginkgo/v2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package apps
package cluster

import (
"fmt"
Expand Down
Loading

0 comments on commit 77dfe90

Please sign in to comment.