-
Notifications
You must be signed in to change notification settings - Fork 248
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
[batch] warns the user if client or server is using deprecated functionality #14621
[batch] warns the user if client or server is using deprecated functionality #14621
Conversation
568fe78
to
51d3e57
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Iris, this looks great! Just one concern.
batch/batch/front_end/front_end.py
Outdated
async def rest_get_version(request: web.Request) -> web.Response: | ||
headers = None | ||
server_version = version() | ||
client_version = request.headers.get("X-Hail-Version") | ||
if client_version is not None and client_version != server_version: | ||
headers = { | ||
"X-Hail-Deprecated": f"The version of the Batch Client ({client_version}) does not match the version of Batch running on the server ({server_version}). Please upgrade your Hail version to the latest release." | ||
} | ||
return web.Response(text=server_version, headers=headers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think warning whenever there is a newer release is probably too noisy. For now lets just warn when they are specifically depending on deprecated functionality.
If we did do this, we'd also need to be sure we're only comparing the release version, not the commit hash. Otherwise, since we deploy batch on every commit, every user would be out of date as soon as any PR merges after a release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I had honestly not realized we deploy Batch on every commit. If at some point down the line we come up with a policy for e.g. how many patch versions the difference between client and server can be, we can always reintroduce the version checking, but for now I agree it doesn't need to be there. Removed!
batch/batch/front_end/front_end.py
Outdated
headers={ | ||
"X-Hail-Deprecated": 'The endpoint "/api/v1alpha/batches/<batch_id>/jobs/<job_id>/log" is deprecated. Please upgrade your Hail version to the latest release.' | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How many routes are we likely to deprecate? While this solution is fine I'm not too fond of the repeated route names.
Would a modified routes
decorator that automatically adds this deprecation message be too complicated/overly fancy:
@get(route, deprecated=True)
async def get_foo(request: Request) -> Response:
...
def get(path, deprecated: bool):
return route(routes.get, path, deprecated)
def post(path, deprecated):
return route(routes.post, path, deprecated)
...
def route(verb, path, deprecated):
def wrapper(fn):
@verb(path)
async def handler(request, *args, **kwargs):
response = await fn(request, args, kwards)
if deprecated:
response.headers['X-Hail-Deprecated'] = (
f'The endpoint "{path}" is deprecated. '
'Please upgrade your Hail version to the latest release.'
)
return response
return handler
return wapper
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's fine if Iris wants to do it, but I expect deprecated endpoints to be pretty rare.
@@ -219,6 +219,18 @@ def cast_query_param_to_bool(param: Optional[str]) -> bool: | |||
return True | |||
|
|||
|
|||
def deprecated(fun): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a much nicer solution than I proposed. Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Sorry, meant to reply to your comment after the tests ran but forgot
Closes #14485.
Tested that this works by deploying the branch to my dev namespace and pointing my dev config at it:
hailctl dev deploy -b iris-garden/hail:batch/deprecated-apis -s deploy_batch,add_developers hailctl dev config set default_namespace irademac
And then running the following: