Skip to content

Commit

Permalink
fix pg init
Browse files Browse the repository at this point in the history
  • Loading branch information
Y-Rookie committed Oct 30, 2023
1 parent 8ad3b81 commit 5e051f5
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 239 deletions.
109 changes: 1 addition & 108 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,80 +4,6 @@ kind: ClusterRole
metadata:
name: manager-role
rules:
- apiGroups:
- apps
resources:
- deployments
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
- update
- watch
- apiGroups:
- apps
resources:
- deployments/finalizers
verbs:
- update
- apiGroups:
- apps
resources:
- deployments/status
verbs:
- get
- apiGroups:
- apps
resources:
- replicasets
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps
resources:
- replicasets/finalizers
verbs:
- update
- apiGroups:
- apps
resources:
- replicasets/status
verbs:
- get
- apiGroups:
- apps
resources:
- statefulsets
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
- update
- watch
- apiGroups:
- apps
resources:
- statefulsets/finalizers
verbs:
- update
- apiGroups:
- apps
resources:
- statefulsets/status
verbs:
- get
- apiGroups:
- apps.kubeblocks.io
resources:
Expand Down Expand Up @@ -249,6 +175,7 @@ rules:
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
Expand Down Expand Up @@ -470,16 +397,6 @@ rules:
- configmaps/finalizers
verbs:
- update
- apiGroups:
- ""
resources:
- endpoints
verbs:
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
Expand Down Expand Up @@ -557,30 +474,6 @@ rules:
verbs:
- get
- list
- apiGroups:
- ""
resources:
- resourcequotas
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- resourcequotas/finalizers
verbs:
- update
- apiGroups:
- ""
resources:
- resourcequotas/status
verbs:
- get
- apiGroups:
- ""
resources:
Expand Down
2 changes: 1 addition & 1 deletion controllers/apps/component_plan_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (c *componentPlanBuilder) componentWalkFunc(v graph.Vertex) error {
case model.UPDATE:
err := c.cli.Update(c.transCtx.Context, vertex.Obj)
if err != nil && !apierrors.IsNotFound(err) {
c.transCtx.Logger.Error(err, fmt.Sprintf("update %T error: %s", vertex.Obj, vertex.OriObj.GetName()))
c.transCtx.Logger.Error(err, fmt.Sprintf("update %T error: %s", vertex.Obj, vertex.Obj.GetName()))
return err
}
case model.DELETE:
Expand Down
7 changes: 3 additions & 4 deletions controllers/apps/transformer_component_deletion.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ func (t *componentDeletionTransformer) Transform(ctx graph.TransformContext, dag
}

graphCli, _ := transCtx.Client.(model.GraphClient)
cluster := transCtx.Cluster
obj := transCtx.Component

ml := labelsForCompDelete(obj, cluster.Name)
ml := labelsForCompDelete(obj)
snapshot, err := model.ReadCacheSnapshot(transCtx, obj, ml, kindsForCompDelete()...)
if err != nil {
return err
Expand Down Expand Up @@ -76,10 +75,10 @@ func kindsForCompDelete() []client.ObjectList {
return kinds
}

func labelsForCompDelete(comp *appsv1alpha1.Component, clusterName string) map[string]string {
func labelsForCompDelete(comp *appsv1alpha1.Component) map[string]string {
return map[string]string{
constant.AppManagedByLabelKey: constant.AppName,
constant.AppInstanceLabelKey: clusterName,
constant.AppInstanceLabelKey: comp.Spec.Cluster,
constant.KBAppComponentLabelKey: comp.Name,
}
}
17 changes: 15 additions & 2 deletions controllers/apps/transformer_component_meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package apps

import (
"github.com/apecloud/kubeblocks/pkg/controller/model"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"

"github.com/apecloud/kubeblocks/pkg/constant"
Expand All @@ -33,9 +34,12 @@ var _ graph.Transformer = &componentMetaTransformer{}
func (t *componentMetaTransformer) Transform(ctx graph.TransformContext, dag *graph.DAG) error {
transCtx, _ := ctx.(*componentTransformContext)
component := transCtx.Component
componentOrig := transCtx.ComponentOrig
needUpdate := false

if !controllerutil.ContainsFinalizer(component, constant.DBComponentFinalizerName) {
controllerutil.AddFinalizer(component, constant.DBComponentFinalizerName)
needUpdate = true
}

labels := component.Labels
Expand All @@ -45,7 +49,16 @@ func (t *componentMetaTransformer) Transform(ctx graph.TransformContext, dag *gr
labelName := labels[constant.ComponentDefinitionLabelKey]
if labelName != component.Spec.CompDef {
labels[constant.ComponentDefinitionLabelKey] = component.Spec.CompDef
component.Labels = labels
needUpdate = true
}
return nil

if !needUpdate {
return nil
}

component.Labels = labels
graphCli, _ := transCtx.Client.(model.GraphClient)
graphCli.Update(dag, componentOrig, component)

return graph.ErrPrematureStop
}
109 changes: 1 addition & 108 deletions deploy/helm/config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,80 +4,6 @@ kind: ClusterRole
metadata:
name: manager-role
rules:
- apiGroups:
- apps
resources:
- deployments
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
- update
- watch
- apiGroups:
- apps
resources:
- deployments/finalizers
verbs:
- update
- apiGroups:
- apps
resources:
- deployments/status
verbs:
- get
- apiGroups:
- apps
resources:
- replicasets
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps
resources:
- replicasets/finalizers
verbs:
- update
- apiGroups:
- apps
resources:
- replicasets/status
verbs:
- get
- apiGroups:
- apps
resources:
- statefulsets
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
- update
- watch
- apiGroups:
- apps
resources:
- statefulsets/finalizers
verbs:
- update
- apiGroups:
- apps
resources:
- statefulsets/status
verbs:
- get
- apiGroups:
- apps.kubeblocks.io
resources:
Expand Down Expand Up @@ -249,6 +175,7 @@ rules:
verbs:
- create
- delete
- deletecollection
- get
- list
- patch
Expand Down Expand Up @@ -470,16 +397,6 @@ rules:
- configmaps/finalizers
verbs:
- update
- apiGroups:
- ""
resources:
- endpoints
verbs:
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
Expand Down Expand Up @@ -557,30 +474,6 @@ rules:
verbs:
- get
- list
- apiGroups:
- ""
resources:
- resourcequotas
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- resourcequotas/finalizers
verbs:
- update
- apiGroups:
- ""
resources:
- resourcequotas/status
verbs:
- get
- apiGroups:
- ""
resources:
Expand Down
Loading

0 comments on commit 5e051f5

Please sign in to comment.