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

Add support for external routes to proxyService, use for model registry #3203

Conversation

mturley
Copy link
Contributor

@mturley mturley commented Sep 12, 2024

Closes https://issues.redhat.com/browse/RHOAIENG-10133 and https://issues.redhat.com/browse/RHOAIENG-9037

Description

Updates proxyService to support configuring services with an optional addressAnnotation. If the addressAnnotation is omitted, the existing behavior will apply, so this PR should not affect the behavior of proxied services other than model registry. If the addressAnnotation is EXTERNAL_REST or EXTERNAL_GRPC, the proxy will fetch the k8s Service named in the request URL and look for a corresponding annotation. If present, the proxy will use that annotation's value as the upstream URL. If it's missing, the proxy will fall back to the existing behavior (constructing an internal .svc.cluster.local URL), which will provide compatibility with non-Istio model registry services that don't require the external URL.

How Has This Been Tested?

On ods-qe-psi-08, we deployed a model registry from the istio TLS samples and observed that the Service has the routing.opendatahub.io/external-address-rest annotation on it. We then deployed the image for this PR using a devFlag and saw that the model registry page works when proxying requests through this new route.

We then also created a new registry using the settings page and reused the database details from the sample registry, and saw that the new istio spec provided on creation works correctly. That registry also became available and worked with the new proxy logic.

Test Impact

No tests for backend code, unfortunately.

Request review criteria:

Self checklist (all need to be checked):

  • The developer has manually tested the changes and verified that the changes work
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has added tests or explained why testing cannot be added (unit or cypress tests for related changes)

If you have UI changes:

  • Included any necessary screenshots or gifs if it was a UI change.
  • Included tags to the UX team if it was a UI/UX change.

After the PR is posted & before it merges:

  • The developer has tested their solution on a cluster by using the image produced by the PR to main

@mturley mturley changed the title [W{ [WIP] Add support for external routes to proxyService, use for model registry Sep 12, 2024
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress This PR is in WIP state label Sep 12, 2024
@mturley mturley force-pushed the RHOAIENG-10133-mr-external-route branch 4 times, most recently from 39f3233 to e51dd17 Compare September 12, 2024 21:52
backend/src/types.ts Outdated Show resolved Hide resolved
const k8sService = (
await fastify.kube.coreV1Api.readNamespacedService(serviceName, namespace)
).body;
const address = k8sService.metadata.annotations[annotation];
Copy link
Contributor

Choose a reason for hiding this comment

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

annotations are optional.

How come typescript isn't complaining about this in our back end :(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oof, good question...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think our backend tsconfig doesn't have strict or strictNullChecks. Maybe we want a separate tech debt issue for that.

backend/src/utils/proxy.ts Outdated Show resolved Hide resolved
@mturley mturley force-pushed the RHOAIENG-10133-mr-external-route branch 2 times, most recently from 71550c0 to 2c74818 Compare September 13, 2024 16:35
@mturley
Copy link
Contributor Author

mturley commented Sep 13, 2024

@christianvogt addressed your feedback

@mturley mturley force-pushed the RHOAIENG-10133-mr-external-route branch 2 times, most recently from bfa6cd6 to 31e4653 Compare September 16, 2024 16:20
@mturley
Copy link
Contributor Author

mturley commented Sep 16, 2024

/retest

Copy link

codecov bot commented Sep 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.43%. Comparing base (5613032) to head (bc1eb37).
Report is 5 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3203      +/-   ##
==========================================
+ Coverage   85.41%   85.43%   +0.02%     
==========================================
  Files        1275     1277       +2     
  Lines       28004    28082      +78     
  Branches     7451     7487      +36     
==========================================
+ Hits        23920    23993      +73     
- Misses       4084     4089       +5     
Files with missing lines Coverage Δ
frontend/src/k8sTypes.ts 100.00% <ø> (ø)
...nd/src/pages/modelRegistrySettings/CreateModal.tsx 69.13% <ø> (ø)

... and 15 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5613032...bc1eb37. Read the comment docs.

@mturley mturley force-pushed the RHOAIENG-10133-mr-external-route branch 2 times, most recently from 30344e9 to dca3fb2 Compare September 17, 2024 19:11
@mturley mturley force-pushed the RHOAIENG-10133-mr-external-route branch from dca3fb2 to 97e0d6b Compare September 17, 2024 19:38
@mturley mturley changed the title [WIP] Add support for external routes to proxyService, use for model registry Add support for external routes to proxyService, use for model registry Sep 17, 2024
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress This PR is in WIP state label Sep 17, 2024

export enum ServiceAddressAnnotation {
EXTERNAL_REST = 'routing.opendatahub.io/external-address-rest',
EXTERNAL_GRPC = 'routing.opendatahub.io/external-address-grpc',
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we expecting connecting the proxy server through grpc? I know between servers can be done, but since it's a proxified call browsers don't support grpc natively

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We aren't currently using that annotation, I just added it in the constant here because it was added at the same time on the service in case we may need it later. Maybe I should just remove it?

Copy link
Member

Choose a reason for hiding this comment

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

I think you can keep it because it's in the generic types folder -- but I agree with Lucas, there is not a likelihood of this working through the http-proxy -- I think Pipelines MLMD uses envoy proxy which is a http endpoint that converts it... @Gkrumbach07 would have to confirm that though.

Copy link
Contributor

@lucferbux lucferbux left a comment

Choose a reason for hiding this comment

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

/lgtm

Not approving until there's an extra review, I've tested the cluster and it seems to be connecting to the right route.

@Gkrumbach07
Copy link
Member

the pipelines construct url stuff looks to be in working order

@openshift-ci openshift-ci bot removed the lgtm label Sep 18, 2024
@Gkrumbach07
Copy link
Member

Tested on cluster and looks to be working and connecting to the annotation route.
/lgtm

@mturley
Copy link
Contributor Author

mturley commented Sep 18, 2024

/retest

1 similar comment
@mturley
Copy link
Contributor Author

mturley commented Sep 18, 2024

/retest

@mturley
Copy link
Contributor Author

mturley commented Sep 18, 2024

Self-approving with the LGTM from Gage and no more unaddressed feedback. Thanks guys

Copy link
Contributor

openshift-ci bot commented Sep 18, 2024

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@mturley
Copy link
Contributor Author

mturley commented Sep 18, 2024

/retest

@mturley mturley force-pushed the RHOAIENG-10133-mr-external-route branch from 2498217 to bc1eb37 Compare September 18, 2024 15:19
@openshift-ci openshift-ci bot removed the lgtm label Sep 18, 2024
@Gkrumbach07
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Sep 18, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit da0aa67 into opendatahub-io:main Sep 18, 2024
7 of 8 checks passed
@mturley mturley deleted the RHOAIENG-10133-mr-external-route branch September 18, 2024 17:15
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.

5 participants