Skip to content

Commit

Permalink
Merge pull request #3278 from mjudeikis/mjudeikis/more.cleaning
Browse files Browse the repository at this point in the history
🌱  noop: Fixup imports to be consistent.
  • Loading branch information
kcp-ci-bot authored Jan 28, 2025
2 parents 85ecae8 + ed2d2a9 commit a1ce379
Show file tree
Hide file tree
Showing 30 changed files with 179 additions and 179 deletions.
10 changes: 5 additions & 5 deletions pkg/admission/kubequota/kubequota_clusterworkspace_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache"
"github.com/kcp-dev/logicalcluster/v3"

"k8s.io/apimachinery/pkg/util/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/util/workqueue"
Expand Down Expand Up @@ -68,15 +68,15 @@ func NewLogicalClusterDeletionMonitor(
func (m *LogicalClusterDeletionMonitor) enqueue(obj interface{}) {
key, err := kcpcache.DeletionHandlingMetaClusterNamespaceKeyFunc(obj)
if err != nil {
runtime.HandleError(err)
utilruntime.HandleError(err)
return
}

m.queue.Add(key)
}

func (m *LogicalClusterDeletionMonitor) Start(stop <-chan struct{}) {
defer runtime.HandleCrash()
defer utilruntime.HandleCrash()
defer m.queue.ShutDown()

logger := logging.WithReconciler(klog.Background(), m.name)
Expand Down Expand Up @@ -107,7 +107,7 @@ func (m *LogicalClusterDeletionMonitor) processNextWorkItem() bool {

if err := m.process(key); err != nil {
//nolint:revive
runtime.HandleError(fmt.Errorf("LogicalClusterDeletionMonitor failed to sync %q, err: %w", key, err))
utilruntime.HandleError(fmt.Errorf("LogicalClusterDeletionMonitor failed to sync %q, err: %w", key, err))

m.queue.AddRateLimited(key)

Expand All @@ -123,7 +123,7 @@ func (m *LogicalClusterDeletionMonitor) processNextWorkItem() bool {
func (m *LogicalClusterDeletionMonitor) process(key string) error {
clusterName, _, _, err := kcpcache.SplitMetaClusterNamespaceKey(key)
if err != nil {
runtime.HandleError(err)
utilruntime.HandleError(err)
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/features/kcp_features.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

"github.com/spf13/pflag"

"k8s.io/apimachinery/pkg/util/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
genericfeatures "k8s.io/apiserver/pkg/features"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/component-base/featuregate"
Expand All @@ -47,7 +47,7 @@ const (
var DefaultFeatureGate = utilfeature.DefaultFeatureGate

func init() {
runtime.Must(utilfeature.DefaultMutableFeatureGate.Add(defaultGenericControlPlaneFeatureGates))
utilruntime.Must(utilfeature.DefaultMutableFeatureGate.Add(defaultGenericControlPlaneFeatureGates))
}

func KnownFeatures() []string {
Expand Down
10 changes: 5 additions & 5 deletions pkg/proxy/index/index_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/kcp-dev/logicalcluster/v3"

"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/util/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/util/workqueue"
Expand Down Expand Up @@ -133,7 +133,7 @@ type Controller struct {
// Start the controller. It does not really do anything, but to keep the shape of a normal
// controller, we keep it.
func (c *Controller) Start(ctx context.Context, numThreads int) {
defer runtime.HandleCrash()
defer utilruntime.HandleCrash()
defer func() {
c.lock.Lock()
defer c.lock.Unlock()
Expand All @@ -156,7 +156,7 @@ func (c *Controller) Start(ctx context.Context, numThreads int) {
func (c *Controller) enqueueShard(ctx context.Context, obj interface{}) {
key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(obj)
if err != nil {
runtime.HandleError(err)
utilruntime.HandleError(err)
return
}

Expand Down Expand Up @@ -188,7 +188,7 @@ func (c *Controller) processNextWorkItem(ctx context.Context) bool {
defer c.queue.Done(key)

if err := c.process(ctx, key); err != nil {
runtime.HandleError(fmt.Errorf("%q controller failed to sync %q, err: %w", controllerName, key, err))
utilruntime.HandleError(fmt.Errorf("%q controller failed to sync %q, err: %w", controllerName, key, err))
c.queue.AddRateLimited(key)
return true
}
Expand All @@ -201,7 +201,7 @@ func (c *Controller) process(ctx context.Context, key string) error {

_, name, err := cache.SplitMetaNamespaceKey(key)
if err != nil {
runtime.HandleError(err)
utilruntime.HandleError(err)
return nil
}
shard, err := c.shardLister.Get(name)
Expand Down
4 changes: 2 additions & 2 deletions pkg/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"net/url"
"os"

"k8s.io/apimachinery/pkg/util/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
userinfo "k8s.io/apiserver/pkg/authentication/user"
"k8s.io/apiserver/pkg/endpoints/request"
)
Expand Down Expand Up @@ -88,7 +88,7 @@ func newShardReverseProxy() *httputil.ReverseProxy {
shardURL := ShardURLFrom(req.Context())
if shardURL == nil {
// should not happen if wiring is correct
runtime.HandleError(fmt.Errorf("no shard URL found in request context"))
utilruntime.HandleError(fmt.Errorf("no shard URL found in request context"))
req.URL.Scheme = "https"
req.URL.Host = "notfound"
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/util/workqueue"
Expand Down Expand Up @@ -132,7 +132,7 @@ type Controller struct {
func (c *Controller) enqueue(obj interface{}) {
key, err := kcpcache.DeletionHandlingMetaClusterNamespaceKeyFunc(obj)
if err != nil {
runtime.HandleError(err)
utilruntime.HandleError(err)
return
}
logger := logging.WithQueueKey(logging.WithReconciler(klog.Background(), ControllerName), key)
Expand All @@ -141,7 +141,7 @@ func (c *Controller) enqueue(obj interface{}) {
}

func (c *Controller) Start(ctx context.Context, numThreads int) {
defer runtime.HandleCrash()
defer utilruntime.HandleCrash()
defer c.queue.ShutDown()

logger := logging.WithReconciler(klog.FromContext(ctx), ControllerName)
Expand Down Expand Up @@ -194,7 +194,7 @@ func (c *Controller) processNextWorkItem(ctx context.Context) bool {
} else {
// rather than wait for a full resync, re-add the workspace to the queue to be processed
c.queue.AddRateLimited(key)
runtime.HandleError(fmt.Errorf("deletion of apibinding %v failed: %w", key, err))
utilruntime.HandleError(fmt.Errorf("deletion of apibinding %v failed: %w", key, err))
}

return true
Expand All @@ -205,7 +205,7 @@ func (c *Controller) process(ctx context.Context, key string) error {
startTime := time.Now()
cluster, _, name, err := kcpcache.SplitMetaClusterNamespaceKey(key)
if err != nil {
runtime.HandleError(err)
utilruntime.HandleError(err)
return nil
}
clusterName := logicalcluster.Name(cluster.String()) // TODO: remove when SplitMetaClusterNamespaceKey is updated
Expand All @@ -220,7 +220,7 @@ func (c *Controller) process(ctx context.Context, key string) error {
return nil
}
if deleteErr != nil {
runtime.HandleError(fmt.Errorf("unable to retrieve apibinding %v from store: %w", key, deleteErr))
utilruntime.HandleError(fmt.Errorf("unable to retrieve apibinding %v from store: %w", key, deleteErr))
return deleteErr
}
logger = logging.WithObject(logger, apibinding)
Expand Down
18 changes: 9 additions & 9 deletions pkg/reconciler/apis/apiexport/apiexport_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/apimachinery/pkg/util/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/util/workqueue"
Expand Down Expand Up @@ -200,7 +200,7 @@ type controller struct {
func (c *controller) enqueueAPIExport(apiExport *apisv1alpha1.APIExport) {
key, err := kcpcache.DeletionHandlingMetaClusterNamespaceKeyFunc(apiExport)
if err != nil {
runtime.HandleError(err)
utilruntime.HandleError(err)
return
}

Expand All @@ -212,15 +212,15 @@ func (c *controller) enqueueAPIExport(apiExport *apisv1alpha1.APIExport) {
func (c *controller) enqueueAllAPIExports(shard *corev1alpha1.Shard) {
list, err := c.listAPIExports()
if err != nil {
runtime.HandleError(err)
utilruntime.HandleError(err)
return
}

logger := logging.WithObject(logging.WithReconciler(klog.Background(), ControllerName), shard)
for i := range list {
key, err := kcpcache.MetaClusterNamespaceKeyFunc(list[i])
if err != nil {
runtime.HandleError(err)
utilruntime.HandleError(err)
continue
}

Expand All @@ -232,15 +232,15 @@ func (c *controller) enqueueAllAPIExports(shard *corev1alpha1.Shard) {
func (c *controller) enqueueSecret(secret *corev1.Secret) {
apiExports, err := c.listAPIExportsForSecret(secret)
if err != nil {
runtime.HandleError(err)
utilruntime.HandleError(err)
return
}

logger := logging.WithObject(logging.WithReconciler(klog.Background(), ControllerName), secret)
for _, apiExport := range apiExports {
key, err := kcpcache.DeletionHandlingMetaClusterNamespaceKeyFunc(apiExport)
if err != nil {
runtime.HandleError(err)
utilruntime.HandleError(err)
return
}
logging.WithQueueKey(logger, key).V(3).Info("queueing APIExport via identity Secret")
Expand All @@ -250,7 +250,7 @@ func (c *controller) enqueueSecret(secret *corev1.Secret) {

// Start starts the controller, which stops when ctx.Done() is closed.
func (c *controller) Start(ctx context.Context, numThreads int) {
defer runtime.HandleCrash()
defer utilruntime.HandleCrash()
defer c.queue.ShutDown()

logger := logging.WithReconciler(klog.FromContext(ctx), ControllerName)
Expand Down Expand Up @@ -287,7 +287,7 @@ func (c *controller) processNextWorkItem(ctx context.Context) bool {
defer c.queue.Done(key)

if err := c.process(ctx, key); err != nil {
runtime.HandleError(fmt.Errorf("%q controller failed to sync %q, err: %w", ControllerName, key, err))
utilruntime.HandleError(fmt.Errorf("%q controller failed to sync %q, err: %w", ControllerName, key, err))
c.queue.AddRateLimited(key)
return true
}
Expand All @@ -298,7 +298,7 @@ func (c *controller) processNextWorkItem(ctx context.Context) bool {
func (c *controller) process(ctx context.Context, key string) error {
cluster, _, name, err := kcpcache.SplitMetaClusterNamespaceKey(key)
if err != nil {
runtime.HandleError(err)
utilruntime.HandleError(err)
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/apimachinery/pkg/util/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/tools/cache"
Expand Down Expand Up @@ -181,7 +181,7 @@ type controller struct {
func (c *controller) enqueueAPIExportEndpointSlice(obj interface{}) {
key, err := kcpcache.DeletionHandlingMetaClusterNamespaceKeyFunc(obj)
if err != nil {
runtime.HandleError(err)
utilruntime.HandleError(err)
return
}

Expand All @@ -197,7 +197,7 @@ func (c *controller) enqueueAPIExportEndpointSlicesForAPIExport(obj interface{})
}
export, ok := obj.(*apisv1alpha1.APIExport)
if !ok {
runtime.HandleError(fmt.Errorf("obj is supposed to be a APIExport, but is %T", obj))
utilruntime.HandleError(fmt.Errorf("obj is supposed to be a APIExport, but is %T", obj))
return
}

Expand All @@ -206,23 +206,23 @@ func (c *controller) enqueueAPIExportEndpointSlicesForAPIExport(obj interface{})
if path := logicalcluster.NewPath(export.Annotations[core.LogicalClusterPathAnnotationKey]); !path.Empty() {
pathKeys, err := c.apiExportEndpointSliceClusterInformer.Informer().GetIndexer().IndexKeys(indexAPIExportEndpointSliceByAPIExport, path.Join(export.Name).String())
if err != nil {
runtime.HandleError(err)
utilruntime.HandleError(err)
return
}
keys.Insert(pathKeys...)
}

clusterKeys, err := c.apiExportEndpointSliceClusterInformer.Informer().GetIndexer().IndexKeys(indexAPIExportEndpointSliceByAPIExport, logicalcluster.From(export).Path().Join(export.Name).String())
if err != nil {
runtime.HandleError(err)
utilruntime.HandleError(err)
return
}
keys.Insert(clusterKeys...)

for _, key := range sets.List[string](keys) {
slice, exists, err := c.apiExportEndpointSliceClusterInformer.Informer().GetIndexer().GetByKey(key)
if err != nil {
runtime.HandleError(err)
utilruntime.HandleError(err)
continue
} else if !exists {
continue
Expand All @@ -237,15 +237,15 @@ func (c *controller) enqueueAPIExportEndpointSlicesForAPIExport(obj interface{})
func (c *controller) enqueueAllAPIExportEndpointSlices(shard interface{}) {
list, err := c.listAPIExportEndpointSlices()
if err != nil {
runtime.HandleError(err)
utilruntime.HandleError(err)
return
}

logger := logging.WithObject(logging.WithReconciler(klog.Background(), ControllerName), shard.(*corev1alpha1.Shard))
for i := range list {
key, err := kcpcache.DeletionHandlingMetaClusterNamespaceKeyFunc(list[i])
if err != nil {
runtime.HandleError(err)
utilruntime.HandleError(err)
continue
}

Expand All @@ -258,13 +258,13 @@ func (c *controller) enqueueAllAPIExportEndpointSlices(shard interface{}) {
func (c *controller) enqueuePartition(obj interface{}) {
key, err := kcpcache.DeletionHandlingMetaClusterNamespaceKeyFunc(obj)
if err != nil {
runtime.HandleError(err)
utilruntime.HandleError(err)
return
}

slices, err := c.getAPIExportEndpointSlicesByPartition(key)
if err != nil {
runtime.HandleError(err)
utilruntime.HandleError(err)
return
}

Expand All @@ -277,7 +277,7 @@ func (c *controller) enqueuePartition(obj interface{}) {

// Start starts the controller, which stops when ctx.Done() is closed.
func (c *controller) Start(ctx context.Context, numThreads int) {
defer runtime.HandleCrash()
defer utilruntime.HandleCrash()
defer c.queue.ShutDown()

logger := logging.WithReconciler(klog.FromContext(ctx), ControllerName)
Expand Down Expand Up @@ -314,7 +314,7 @@ func (c *controller) processNextWorkItem(ctx context.Context) bool {
defer c.queue.Done(key)

if err := c.process(ctx, key); err != nil {
runtime.HandleError(fmt.Errorf("%q controller failed to sync %q, err: %w", ControllerName, key, err))
utilruntime.HandleError(fmt.Errorf("%q controller failed to sync %q, err: %w", ControllerName, key, err))
c.queue.AddRateLimited(key)
return true
}
Expand All @@ -325,7 +325,7 @@ func (c *controller) processNextWorkItem(ctx context.Context) bool {
func (c *controller) process(ctx context.Context, key string) error {
clusterName, _, name, err := kcpcache.SplitMetaClusterNamespaceKey(key)
if err != nil {
runtime.HandleError(err)
utilruntime.HandleError(err)
return nil
}
obj, err := c.getAPIExportEndpointSlice(clusterName, name)
Expand Down
Loading

0 comments on commit a1ce379

Please sign in to comment.