fix controller Start method signature
Signed-off-by: Roland.Ma <rolandma@yunify.com>
This commit is contained in:
@@ -332,9 +332,9 @@ func (c *IPPoolController) processIPPool(name string) (*time.Duration, error) {
|
||||
return nil, c.updateIPPoolStatus(pool)
|
||||
}
|
||||
|
||||
func (c *IPPoolController) Start(stopCh <-chan struct{}) error {
|
||||
go c.provider.SyncStatus(stopCh, c.ippoolQueue)
|
||||
return c.Run(5, stopCh)
|
||||
func (c *IPPoolController) Start(ctx context.Context) error {
|
||||
go c.provider.SyncStatus(ctx.Done(), c.ippoolQueue)
|
||||
return c.Run(5, ctx.Done())
|
||||
}
|
||||
|
||||
func (c *IPPoolController) Run(workers int, stopCh <-chan struct{}) error {
|
||||
|
||||
@@ -77,7 +77,7 @@ var _ = Describe("test ippool", func() {
|
||||
stopCh := make(chan struct{})
|
||||
go ksInformer.Start(stopCh)
|
||||
go k8sInformer.Start(stopCh)
|
||||
go c.Start(stopCh)
|
||||
go c.Start(context.Background())
|
||||
|
||||
It("test create ippool", func() {
|
||||
clone := pool.DeepCopy()
|
||||
|
||||
@@ -692,8 +692,8 @@ func NewNSNetworkPolicyController(
|
||||
return controller
|
||||
}
|
||||
|
||||
func (c *NSNetworkPolicyController) Start(stopCh <-chan struct{}) error {
|
||||
return c.Run(defaultThread, defaultSync, stopCh)
|
||||
func (c *NSNetworkPolicyController) Start(ctx context.Context) error {
|
||||
return c.Run(defaultThread, defaultSync, ctx.Done())
|
||||
}
|
||||
|
||||
// Run starts the controller.
|
||||
|
||||
@@ -17,6 +17,7 @@ limitations under the License.
|
||||
package nsnetworkpolicy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
@@ -157,7 +158,7 @@ var _ = Describe("Nsnetworkpolicy", func() {
|
||||
c.workspaceInformerSynced = alwaysReady
|
||||
c.informerSynced = alwaysReady
|
||||
|
||||
go c.Start(stopCh)
|
||||
go c.Start(context.Background())
|
||||
})
|
||||
|
||||
It("test func namespaceNetworkIsolateEnabled", func() {
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
"net/http"
|
||||
"sync"
|
||||
|
||||
"k8s.io/api/admission/v1beta1"
|
||||
v1 "k8s.io/api/admission/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
|
||||
@@ -98,7 +98,7 @@ func (h *ValidatingHandler) Handle(ctx context.Context, req admission.Request) a
|
||||
|
||||
// Get the object in the request
|
||||
obj := validator.Obj.DeepCopyObject()
|
||||
if req.Operation == v1beta1.Create {
|
||||
if req.Operation == v1.Create {
|
||||
err := h.decoder.Decode(req, obj)
|
||||
if err != nil {
|
||||
return admission.Errored(http.StatusBadRequest, err)
|
||||
@@ -110,7 +110,7 @@ func (h *ValidatingHandler) Handle(ctx context.Context, req admission.Request) a
|
||||
}
|
||||
}
|
||||
|
||||
if req.Operation == v1beta1.Update {
|
||||
if req.Operation == v1.Update {
|
||||
oldObj := obj.DeepCopyObject()
|
||||
|
||||
err := h.decoder.DecodeRaw(req.Object, obj)
|
||||
@@ -128,7 +128,7 @@ func (h *ValidatingHandler) Handle(ctx context.Context, req admission.Request) a
|
||||
}
|
||||
}
|
||||
|
||||
if req.Operation == v1beta1.Delete {
|
||||
if req.Operation == v1.Delete {
|
||||
// In reference to PR: https://github.com/kubernetes/kubernetes/pull/76346
|
||||
// OldObject contains the object being deleted
|
||||
err := h.decoder.DecodeRaw(req.OldObject, obj)
|
||||
|
||||
Reference in New Issue
Block a user