Skip to content

Commit

Permalink
feat: add dataprotection isolation deployment (#4074)
Browse files Browse the repository at this point in the history
  • Loading branch information
dengshaojiang committed Jul 4, 2023
1 parent d66645a commit 732a036
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 26 deletions.
1 change: 0 additions & 1 deletion cmd/cluster/dataprotection.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ func NewDeleteBackupCmd(f cmdutil.Factory, streams genericclioptions.IOStreams)
},
}
cmd.Flags().StringSliceVar(&o.Names, "name", []string{}, "Backup names")
_ = cmd.MarkFlagRequired("name")
o.AddFlags(cmd)
return cmd
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/kubeblocks/compare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package kubeblocks

import (
"github.com/apecloud/kubeblocks/internal/cli/testing"
"github.com/apecloud/kubeblocks/internal/cli/util/helm"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
clientfake "k8s.io/client-go/rest/fake"
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"

"github.com/apecloud/kubeblocks/internal/cli/testing"
"github.com/apecloud/kubeblocks/internal/cli/util/helm"
)

var _ = Describe("kubeblocks compare", func() {
Expand Down
23 changes: 0 additions & 23 deletions cmd/kubeblocks/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,16 @@ import (
"time"

"github.com/spf13/cobra"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/client-go/kubernetes"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
deploymentutil "k8s.io/kubectl/pkg/util/deployment"
"k8s.io/kubectl/pkg/util/templates"

"github.com/apecloud/kubeblocks/internal/cli/printer"
"github.com/apecloud/kubeblocks/internal/cli/types"
"github.com/apecloud/kubeblocks/internal/cli/util"
"github.com/apecloud/kubeblocks/internal/cli/util/helm"
"github.com/apecloud/kubeblocks/internal/constant"
)

var showAllConfig = false
Expand Down Expand Up @@ -241,26 +237,7 @@ func markKubeBlocksPodsToLoadConfigMap(client kubernetes.Interface) error {
if err != nil {
return err
}
if len(pods.Items) == 0 {
return nil
}
condition := deploymentutil.GetDeploymentCondition(deploy.Status, appsv1.DeploymentProgressing)
if condition == nil {
return nil
}
podBelongToKubeBlocks := func(pod corev1.Pod) bool {
for _, v := range pod.OwnerReferences {
if v.Kind == constant.ReplicaSetKind && strings.Contains(condition.Message, v.Name) {
return true
}
}
return false
}
for _, pod := range pods.Items {
belongToKubeBlocks := podBelongToKubeBlocks(pod)
if !belongToKubeBlocks {
continue
}
// mark the pod to load configmap
if pod.Annotations == nil {
pod.Annotations = map[string]string{}
Expand Down
6 changes: 6 additions & 0 deletions util/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ func GetKubeBlocksDeploy(client kubernetes.Interface) (*appsv1.Deployment, error
return nil, nil
}
if len(deploys.Items) > 1 {
// for compatibility with older versions, filter here instead of LabelSelector
for _, i := range deploys.Items {
if _, ok := i.Labels["app.kubernetes.io/component"]; ok {
return &i, nil
}
}
return nil, fmt.Errorf("found multiple KubeBlocks deployments, please check your cluster")
}
return &deploys.Items[0], nil
Expand Down

0 comments on commit 732a036

Please sign in to comment.