Skip to content

Commit

Permalink
Merge pull request #554 from jwsui/webhook-fix
Browse files Browse the repository at this point in the history
Fix webhook panic error caused by bumping controller-runtime
  • Loading branch information
jwsui committed Apr 26, 2024
2 parents 7aa926b + 1f3d839 commit ebac866
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
7 changes: 5 additions & 2 deletions pkg/controllers/subnetset/subnetset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import (
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"

"github.com/vmware-tanzu/nsx-operator/pkg/apis/v1alpha1"

"github.com/vmware-tanzu/nsx-operator/pkg/config"
"github.com/vmware-tanzu/nsx-operator/pkg/controllers/common"
"github.com/vmware-tanzu/nsx-operator/pkg/logger"
Expand Down Expand Up @@ -343,7 +343,10 @@ func (r *SubnetSetReconciler) Start(mgr ctrl.Manager, enableWebhook bool) error
}
hookServer.Register("/validate-nsx-vmware-com-v1alpha1-subnetset",
&webhook.Admission{
Handler: &SubnetSetValidator{Client: mgr.GetClient()},
Handler: &SubnetSetValidator{
Client: mgr.GetClient(),
decoder: admission.NewDecoder(mgr.GetScheme()),
},
})
}
go r.GarbageCollector(make(chan bool), servicecommon.GCInterval)
Expand Down
7 changes: 0 additions & 7 deletions pkg/controllers/subnetset/subnetset_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,3 @@ func (v *SubnetSetValidator) Handle(ctx context.Context, req admission.Request)
}
return admission.Allowed("")
}

// InjectDecoder injects the decoder into a validator.
// A decoder will be automatically injected by controller-manager.
func (v *SubnetSetValidator) InjectDecoder(d *admission.Decoder) error {
v.decoder = d
return nil
}

0 comments on commit ebac866

Please sign in to comment.