Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix allowed resources checks on GKE #6657

Merged
merged 25 commits into from Dec 20, 2022
Merged

Conversation

Nokel81
Copy link
Collaborator

@Nokel81 Nokel81 commented Nov 28, 2022

Signed-off-by: Sebastian Malton sebastian@malton.name

NOTE: This is a rather large PR that fixes the GKE issue but also does some much need refactoring with fixing some circular dependencies.

The first commit fixes the bug on GKE and the rest of the commits work to do the following refactorings:

  1. Convert and simplify the retrival of known and allowed resources on the Cluster type so that the shouldShowResource method is more correct. Namely, just the apiName of a resource is not enough to uniquely specify it. Furthermore, this updated naming better describes how the information should be used (it is also what the Kube docs say to use for it).
    1. Furthermore, this leads to a natural addition to disable this check and just show all resources.
  2. Expands the ClusterContext type to include some helpful functions that are used in several places (more DRY)
  3. Make two different contexts, once for namespaced resources (which can work with cluster scoped resources as well) and one just for cluster scoped resources (which is much simpler in implementation). The benefit of this is that it removes a circular dependency with NamespaceStore
  4. Moves the KubeObjectStore.context static to the legacy extension API type and instead passes the context in as a dependency. This removed some more global shared state and permitted the removal of the circular dependency.
  5. Remove the last uses of the legacy global isMac, etc...
  6. Start moving more things into runnables for bootstrap

@Nokel81 Nokel81 added the bug Something isn't working label Nov 28, 2022
@Nokel81 Nokel81 added this to the 6.3.0 milestone Nov 28, 2022
@Nokel81 Nokel81 requested a review from a team as a code owner November 28, 2022 17:11
@Nokel81 Nokel81 requested review from ixrock and aleksfront and removed request for a team November 28, 2022 17:11
@github-actions
Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions
Copy link
Contributor

Conflicts have been resolved. A maintainer will review the pull request shortly.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2022

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2022

Conflicts have been resolved. A maintainer will review the pull request shortly.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2022

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2022

Conflicts have been resolved. A maintainer will review the pull request shortly.

@github-actions
Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions
Copy link
Contributor

Conflicts have been resolved. A maintainer will review the pull request shortly.

@github-actions
Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
- Make injectable phases more explicit for renderer

Signed-off-by: Sebastian Malton <sebastian@malton.name>
@github-actions
Copy link
Contributor

Conflicts have been resolved. A maintainer will review the pull request shortly.

const k8sRequest = di.inject(k8SRequestInjectable);
const logger = di.inject(loggerInjectable);

return async (cluster) => {
Copy link
Contributor

@Iku-turso Iku-turso Dec 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code as seen here could probably benefit from reducing its nesting. Eg. instead of mutating resourceListGroups and kubeApiResources inside for-loops inside async-IIFEs inside concurrency protected decorator, inside Promise.all, it could use some functional patterns to get something like. const resourceListGroups = await pipeline(clusters, map(toK8ApiRequestPromise), awaitAll, flatMap(toResourceListGroup)); and const kubeApiResources = await pipeline(resourceListGroups, map(toGeneralK8RequestCall), map(withApiLimit), map(toCalledFunction), awaitAll, flatMap(toKubeApiResources));.

Probably made an error somewhere there, but the point is there :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be a conversation-starter :)

console.warn("Setting KubeObjectStore.context is no longer supported");
void ctx;
},
get: () => asLegacyGlobalForExtensionApi(clusterFrameContextForNamespacedResourcesInjectable),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One day we'll get rid of these.

},
nodes: {
kind: "Node",
group: "v1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Nokel81 Should the group be an empty string? It seems only v1 stuff is not showing up for me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this probably isn't the place that you need to fix but instead the uses of shouldShowResourceInjectionToken

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But yes they probably should be empty here too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants