Skip to content

Commit

Permalink
fix, webhook and controller
Browse files Browse the repository at this point in the history
  • Loading branch information
shaofan-hs committed Aug 17, 2023
1 parent 2bba136 commit bc3217b
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 13 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/davecgh/go-spew v1.1.1
github.com/docker/distribution v2.8.1+incompatible
github.com/go-logr/logr v1.2.3
github.com/google/uuid v1.3.0
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.26.0
github.com/pkg/errors v0.9.1
Expand Down Expand Up @@ -42,7 +43,6 @@ require (
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/json-iterator/go v1.1.12 // indirect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func (r *ReconcilePodOpsLifecycle) addLabels(ctx context.Context, pod *corev1.Po
func (r *ReconcilePodOpsLifecycle) registerStages() {
r.ruleSetManager.RegisterStage(v1alpha1.PodOpsLifecyclePreCheckStage, func(po client.Object) bool {
labels := po.GetLabels()
return labels == nil && labelHasPrefix(labels, v1alpha1.PodPreCheckLabelPrefix)
return labels != nil && labelHasPrefix(labels, v1alpha1.PodPreCheckLabelPrefix)
})
r.ruleSetManager.RegisterStage(v1alpha1.PodOpsLifecyclePostCheckStage, func(po client.Object) bool {
labels := po.GetLabels()
Expand Down
1 change: 0 additions & 1 deletion pkg/webhook/server/generic/generic_webhooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,5 @@ var ValidatingTypeHandlerMap = map[string]webhookdmission.DispatchHandler{}

func init() {
MutatingTypeHandlerMap["Pod"] = pod.NewMutatingHandler()

ValidatingTypeHandlerMap["Pod"] = pod.NewValidatingHandler()
}
9 changes: 0 additions & 9 deletions pkg/webhook/server/generic/pod/opslifecycle/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import (

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/sets"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/runtime/inject"

"kusionstack.io/kafed/apis/apps/v1alpha1"
)
Expand Down Expand Up @@ -54,7 +52,6 @@ var (
type ReadyToUpgrade func(pod *corev1.Pod) (bool, []string, *time.Duration)
type SatisfyExpectedFinalizers func(pod *corev1.Pod) (bool, []string, error)
type TimeLabelValue func() string
type NeedOpsLifecycle func(oldPod, newPod *corev1.Pod) bool

type OpsLifecycle struct {
readyToUpgrade ReadyToUpgrade // for testing
Expand Down Expand Up @@ -174,9 +171,3 @@ func hasNoBlockingFinalizer(pod *corev1.Pod) (bool, []string, *time.Duration) {

return true, nil, nil
}

var _ inject.Client = &OpsLifecycle{}

func (lc *OpsLifecycle) InjectClient(c client.Client) error {
return nil
}
2 changes: 1 addition & 1 deletion pkg/webhook/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func Add(mgr manager.Manager) error {
// register admission handlers
for name, handler := range generic.HandlerMap {
if len(name) == 0 {
klog.Warningf("Skip no-name handler.")
klog.Warningf("Skip registering handlers without a name")
continue
}

Expand Down

0 comments on commit bc3217b

Please sign in to comment.