Created
September 2, 2022 13:15
-
-
Save sttts/1f63f82d1eeb4d98fecacf5a288f6441 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/pkg/reconciler/workload/apiexport/workload_apiexport_controller.go b/pkg/reconciler/workload/apiexport/workload_apiexport_controller.go | |
index fd2fc569..14f9d0b2 100644 | |
--- a/pkg/reconciler/workload/apiexport/workload_apiexport_controller.go | |
+++ b/pkg/reconciler/workload/apiexport/workload_apiexport_controller.go | |
@@ -145,7 +145,7 @@ func (c *controller) enqueueNegotiatedAPIResource(obj interface{}) { | |
clusterName := logicalcluster.From(resource) | |
key := clusters.ToClusterAwareKey(clusterName, TemporaryComputeServiceExportName) | |
- if _, err := c.apiExportsLister.Get(clusters.ToClusterAwareKey(clusterName, TemporaryComputeServiceExportName)); errors.IsNotFound(err) { | |
+ if _, err := c.apiExportsLister.Cluster(clusterName).Get(TemporaryComputeServiceExportName); errors.IsNotFound(err) { | |
return // it's gone | |
} else if err != nil { | |
runtime.HandleError(fmt.Errorf("failed to get APIExport %s|%s: %w", clusterName, TemporaryComputeServiceExportName, err)) | |
@@ -235,3 +235,8 @@ func (c *controller) process(ctx context.Context, key string) error { | |
return nil | |
} | |
+r | |
+ } | |
+ | |
+ return nil | |
+} | |
diff --git a/pkg/reconciler/workload/apiexport/workload_apiexport_reconcile.go b/pkg/reconciler/workload/apiexport/workload_apiexport_reconcile.go | |
index 8c1e4dc3..eaa34a6e 100644 | |
--- a/pkg/reconciler/workload/apiexport/workload_apiexport_reconcile.go | |
+++ b/pkg/reconciler/workload/apiexport/workload_apiexport_reconcile.go | |
@@ -30,7 +30,6 @@ import ( | |
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | |
"k8s.io/apimachinery/pkg/util/errors" | |
"k8s.io/apimachinery/pkg/util/sets" | |
- "k8s.io/client-go/tools/clusters" | |
"k8s.io/klog/v2" | |
apiresourcev1alpha1 "github.com/kcp-dev/kcp/pkg/apis/apiresource/v1alpha1" | |
@@ -251,7 +250,7 @@ func (c *controller) listAPIResourceSchemas(clusterName logicalcluster.Name) ([] | |
} | |
func (c *controller) getAPIResourceSchema(ctx context.Context, clusterName logicalcluster.Name, name string) (*apisv1alpha1.APIResourceSchema, error) { | |
- schema, err := c.apiResourceSchemaLister.Get(clusters.ToClusterAwareKey(clusterName, name)) | |
+ schema, err := c.apiResourceSchemaLister.Cluster(clusterName).Get(name) | |
if apierrors.IsNotFound(err) { | |
return c.kcpClusterClient.ApisV1alpha1().APIResourceSchemas().Get(logicalcluster.WithCluster(ctx, clusterName), name, metav1.GetOptions{}) | |
} | |
@@ -269,3 +268,5 @@ func (c *controller) updateAPIExport(ctx context.Context, clusterName logicalclu | |
func (c *controller) deleteAPIResourceSchema(ctx context.Context, clusterName logicalcluster.Name, name string) error { | |
return c.kcpClusterClient.ApisV1alpha1().APIResourceSchemas().Delete(logicalcluster.WithCluster(ctx, clusterName), name, metav1.DeleteOptions{}) | |
} | |
+ter(ctx, clusterName), name, metav1.DeleteOptions{}) | |
+} | |
diff --git a/pkg/syncer/shared/finalizer.go b/pkg/syncer/shared/finalizer.go | |
index 671d6fc7..98298855 100644 | |
--- a/pkg/syncer/shared/finalizer.go | |
+++ b/pkg/syncer/shared/finalizer.go | |
@@ -27,7 +27,6 @@ import ( | |
"k8s.io/apimachinery/pkg/runtime/schema" | |
"k8s.io/client-go/dynamic" | |
"k8s.io/client-go/dynamic/dynamicinformer" | |
- "k8s.io/client-go/tools/clusters" | |
"k8s.io/klog/v2" | |
workloadv1alpha1 "github.com/kcp-dev/kcp/pkg/apis/workload/v1alpha1" | |
@@ -40,7 +39,7 @@ const ( | |
) | |
func EnsureUpstreamFinalizerRemoved(ctx context.Context, gvr schema.GroupVersionResource, upstreamInformers dynamicinformer.DynamicSharedInformerFactory, upstreamClient dynamic.ClusterInterface, upstreamNamespace, syncTargetKey string, logicalClusterName logicalcluster.Name, resourceName string) error { | |
- upstreamObjFromLister, err := upstreamInformers.ForResource(gvr).Lister().ByNamespace(upstreamNamespace).Get(clusters.ToClusterAwareKey(logicalClusterName, resourceName)) | |
+ upstreamObjFromLister, err := upstreamInformers.ForResource(gvr).Lister().ByNamespace(upstreamNamespace).Cluster(logicalClusterName).Get(resourceName) | |
if err != nil && !apierrors.IsNotFound(err) { | |
return err | |
} | |
@@ -94,3 +93,6 @@ func EnsureUpstreamFinalizerRemoved(ctx context.Context, gvr schema.GroupVersion | |
klog.V(2).Infof("Updated resource %s|%s/%s after removing the finalizers", logicalClusterName, upstreamNamespace, upstreamObj.GetName()) | |
return nil | |
} | |
+pstreamNamespace, upstreamObj.GetName()) | |
+ return nil | |
+} | |
diff --git a/pkg/virtual/apiexport/controllers/apireconciler/apiexport_apireconciler_reconcile.go b/pkg/virtual/apiexport/controllers/apireconciler/apiexport_apireconciler_reconcile.go | |
index ce16ec56..153a3312 100644 | |
--- a/pkg/virtual/apiexport/controllers/apireconciler/apiexport_apireconciler_reconcile.go | |
+++ b/pkg/virtual/apiexport/controllers/apireconciler/apiexport_apireconciler_reconcile.go | |
@@ -37,7 +37,6 @@ import ( | |
"k8s.io/apimachinery/pkg/runtime" | |
"k8s.io/apimachinery/pkg/runtime/schema" | |
"k8s.io/apimachinery/pkg/types" | |
- "k8s.io/client-go/tools/clusters" | |
"k8s.io/klog/v2" | |
"k8s.io/kube-openapi/pkg/common" | |
"k8s.io/kubernetes/pkg/api/genericcontrolplanescheme" | |
@@ -247,7 +246,7 @@ func gvrString(gvr schema.GroupVersionResource) string { | |
func (c *APIReconciler) getSchemasFromAPIExport(apiExport *apisv1alpha1.APIExport) (map[schema.GroupResource]*apisv1alpha1.APIResourceSchema, error) { | |
apiResourceSchemas := map[schema.GroupResource]*apisv1alpha1.APIResourceSchema{} | |
for _, schemaName := range apiExport.Spec.LatestResourceSchemas { | |
- apiResourceSchema, err := c.apiResourceSchemaLister.Get(clusters.ToClusterAwareKey(logicalcluster.From(apiExport), schemaName)) | |
+ apiResourceSchema, err := c.apiResourceSchemaLister.Cluster(logicalcluster.From(apiExport)).Get(schemaName) | |
if err != nil && !apierrors.IsNotFound(err) { | |
return nil, err | |
} | |
@@ -494,4 +493,7 @@ var InternalAPIs = []internalapis.InternalAPI{ | |
Instance: &eventsv1.Event{}, | |
ResourceScope: apiextensionsv1.NamespaceScoped, | |
}, | |
+} | |
+ ResourceScope: apiextensionsv1.NamespaceScoped, | |
+ }, | |
} | |
diff --git a/pkg/virtual/initializingworkspaces/builder/build.go b/pkg/virtual/initializingworkspaces/builder/build.go | |
index 0e3d20f1..a74e6797 100644 | |
--- a/pkg/virtual/initializingworkspaces/builder/build.go | |
+++ b/pkg/virtual/initializingworkspaces/builder/build.go | |
@@ -37,7 +37,6 @@ import ( | |
kubernetesclient "k8s.io/client-go/kubernetes" | |
"k8s.io/client-go/rest" | |
"k8s.io/client-go/tools/cache" | |
- "k8s.io/client-go/tools/clusters" | |
"k8s.io/client-go/transport" | |
"k8s.io/klog/v2" | |
"k8s.io/utils/pointer" | |
@@ -232,7 +231,7 @@ func BuildVirtualWorkspace( | |
return | |
} | |
parent, name := cluster.Split() | |
- clusterWorkspace, err := lister.Get(clusters.ToClusterAwareKey(parent, name)) | |
+ clusterWorkspace, err := lister.Cluster(parent).Get(name) | |
if err != nil { | |
http.Error(writer, fmt.Sprintf("could not find cluster %q: %v", parent, err), http.StatusInternalServerError) | |
return | |
@@ -407,3 +406,8 @@ func newAuthorizer(client kubernetesclient.ClusterInterface) authorizer.Authoriz | |
return authz.Authorize(ctx, SARAttributes) | |
} | |
} | |
+ } | |
+ | |
+ return authz.Authorize(ctx, SARAttributes) | |
+ } | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment