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: API requests with single RM and recover from panic during unauthorized autocreate #9573

Merged
merged 3 commits into from
Jul 11, 2024

Conversation

amandavialva01
Copy link
Contributor

@amandavialva01 amandavialva01 commented Jun 26, 2024

Ticket

DET-10385, DET-10386

Description

This PR fixes the following issues:

  • API requests for single RM only work when the cluster name is specified in the request
  • Autocreate panic is not handled when attempted with OSS
  • Some lint issues after feature branch rebase with main
  • Autocreating namespace fails given workspace whose name doesn't match the accepted namespace regex pattern.

Test Plan

Spin up a single RM kubernetes EE cluster to execute the test plan.
To test API requests for single RM, run the following commands and make sure that they work:

  • det w create ws1 --auto-create-namespace
  • det w create ws2 && det w bindings set ws2 --namespace default
  • det w create ws3 --namespace default
  • det w create ws4 && det w bindings set ws4 --auto-create-namespace

To test auto-create panic handled gracefully with an intuitive error message:

  • Kill your Kubernetes cluster (if it's EE) and spin up an OSS Kubernetes cluster (remove license.txt and public.txt from your determined directory).
  • Run det w create ws10 --auto-create-namespace and verify that we get an error saying that auto create is an EE-only feature
  • Run det w create ws11 && det w bindings set ws11 --auto-create-namespace and verify that we get an error saying that auto create is an EE-only feature

To test namespace auto-creation with workspaces whose names don't match the accepted namespace regex pattern, run
det w create name,of_workspacE --auto-create-namespace and verify that a Kubernetes namespace is successfully created

  • Run det w create ANOTHER,name,of_workspacE && det w bindings set ANOTHER,name,of_workspacE --auto-create-namespace and verify that a Kubernetes namespace is successfully created

Checklist

  • Changes have been manually QA'd
  • New features have been approved by the corresponding PM
  • User-facing API changes have the "User-facing API Change" label
  • Release notes have been added as a separate file under docs/release-notes/
    See Release Note for details.
  • Licenses have been included for new code which was copied and/or modified from any external code

@amandavialva01 amandavialva01 requested review from a team as code owners June 26, 2024 15:22
@cla-bot cla-bot bot added the cla-signed label Jun 26, 2024
@amandavialva01 amandavialva01 changed the base branch from main to wksp-namespace-binding June 26, 2024 15:22
@determined-ci determined-ci requested a review from a team June 26, 2024 15:22
Copy link

netlify bot commented Jun 26, 2024

Deploy Preview for determined-ui ready!

Name Link
🔨 Latest commit 82011dc
🔍 Latest deploy log https://app.netlify.com/sites/determined-ui/deploys/667c323121ae3f0008b78e4b
😎 Deploy Preview https://deploy-preview-9573--determined-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Jun 26, 2024

Codecov Report

Attention: Patch coverage is 41.66667% with 14 lines in your changes missing coverage. Please review.

Project coverage is 51.75%. Comparing base (86214e5) to head (95a68f0).

Additional details and impacted files
@@                    Coverage Diff                     @@
##           wksp-namespace-binding    #9573      +/-   ##
==========================================================
- Coverage                   51.75%   51.75%   -0.01%     
==========================================================
  Files                        1255     1255              
  Lines                      154074   154076       +2     
  Branches                     3120     3120              
==========================================================
- Hits                        79747    79746       -1     
- Misses                      74172    74175       +3     
  Partials                      155      155              
Flag Coverage Δ
backend 43.82% <69.23%> (-0.01%) ⬇️
harness 72.61% <9.09%> (-0.01%) ⬇️
web 49.15% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
master/internal/api_workspace.go 59.07% <69.23%> (+0.25%) ⬆️
harness/determined/cli/workspace.py 16.50% <9.09%> (-0.32%) ⬇️

... and 1 file with indirect coverage changes

@amandavialva01 amandavialva01 force-pushed the amanda/bugBashFixes branch 2 times, most recently from 71d5420 to 86f8657 Compare June 26, 2024 15:37
Copy link
Member

@tara-det-ai tara-det-ai left a comment

Choose a reason for hiding this comment

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

LGTM

@salonig23 salonig23 force-pushed the wksp-namespace-binding branch 2 times, most recently from cd9b184 to 1ee0bbf Compare July 2, 2024 20:57
):
auto_create_namespace = args.auto_create_namespace or args.auto_create_namespace_all_clusters
set_namespace = args.namespace or auto_create_namespace
if args.cluster_name and not set_namespace:
Copy link
Contributor

Choose a reason for hiding this comment

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

I love this change; I think it's really easy to follow!

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice work. It's easier to understand the intention!

@@ -18,7 +18,7 @@ metadata:
release: {{ .Release.Name }}
rules:
- apiGroups: [""]
resources: ["pods", "pods/status", "pods/log", "configmaps", "namespaces"]
resources: ["pods", "pods/status", "pods/log", "configmaps"]
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm just curious - does this give master permission to create the resources in the list?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea! The pods in the master deployment running the master service are authorized as the specified service account when accessing the Kubernetes API and have the permissions granted to the service account in the helm release, among those permissions being the ability to CRUD the listed resources!

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, awesome - thanks!!

ClusterName: clusterName,
Namespace: namespace,
namespaceMetaWithAllClusterNames[newClusterName] = &workspacev1.WorkspaceNamespaceMeta{
ClusterName: clusterName,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be newClusterName instead of clusterName here? I guess I'm a little confused that there's a map where the key is newClusterName but the value has a field where ClusterName = clusterName.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Awesome catch! Yea it should be newClusterName. Thankss

Copy link
Contributor

@kkunapuli kkunapuli left a comment

Choose a reason for hiding this comment

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

LGTM!

Minor suggestion: this PR fixes a couple bugs right? Are there any tests we could add to help confirm the issues are fixed and to ensure they don't pop up again? (If not, that's fine. You know the work better than I do!)

@amandavialva01
Copy link
Contributor Author

LGTM!

Minor suggestion: this PR fixes a couple bugs right? Are there any tests we could add to help confirm the issues are fixed and to ensure they don't pop up again? (If not, that's fine. You know the work better than I do!)
We are planning to do automated testing that covers the bugs fixed here in separate PRs since there are a lot of features to test! I have manually tested everything following the description instructions!

@amandavialva01 amandavialva01 merged commit b4b1ed4 into wksp-namespace-binding Jul 11, 2024
78 of 92 checks passed
@amandavialva01 amandavialva01 deleted the amanda/bugBashFixes branch July 11, 2024 14:49
salonig23 pushed a commit that referenced this pull request Jul 23, 2024
salonig23 pushed a commit that referenced this pull request Jul 24, 2024
amandavialva01 added a commit that referenced this pull request Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants