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

Require credentials for non-container clients #2361

Closed
wants to merge 9 commits into from

Conversation

erikbern
Copy link
Contributor

@erikbern erikbern commented Oct 18, 2024

This needs to be rebased on #2350 when merged.

We now fail immediately in Client.from_env if it's not _is_remote() and there are no credentials. This reduces the need for ClientHello.

We have a separate class method for creating "unauthenticated" clients, but it's only used for modal token new.

This mostly required fixing a bunch of tests that previously relied on the test fixture client having no credentials.

Cleans things up to the point where ClientHello can be trivially removed from containers. But I'll do that separately.

@erikbern erikbern force-pushed the erikbern/no-container-credentials-ii branch from 74ecd4d to d470734 Compare October 18, 2024 21:26
@erikbern erikbern changed the title Don't use credentials in container (post-PR cleanup) Require credentials for non-container clients Oct 19, 2024
@erikbern erikbern requested a review from mwaskom October 19, 2024 02:27
@erikbern erikbern force-pushed the erikbern/no-container-credentials-ii branch from d233c4d to 979e9a5 Compare October 19, 2024 02:30
Copy link
Contributor

@mwaskom mwaskom left a comment

Choose a reason for hiding this comment

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

Had a few thoughts — which might be totally off base — but the rules about what the Client can and should do feel sort of poorly defined in a way that makes it hard for me to predict the repercussions of this change.

Comment on lines 129 to +130
def authenticated(self):
return self._authenticated
return self._credentials is not None
Copy link
Contributor

Choose a reason for hiding this comment

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

This might just be hard to think about because there are many different ways of creating a Client, but this strikes me as wrong? Can't you end up with a Client that has credentials attached, but we don't know if they are valid? Not sure what the practical implications would be, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So yeah I think this is actually wrong (and let me try to add a test for it) but for a different reason I think. If a Modal app running in the cloud is trying to deploy a Modal app then I think it asserts that the client is authenticated, which will fail. Honestly think it's maybe better to remove this code altogether and just fail in respective handlers – I'm not sure why we need this check.

Comment on lines +237 to +239
if _is_remote():
credentials = None
client_type = api_pb2.CLIENT_TYPE_CONTAINER
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we're setting ourselves up for (more) confusion about the two distinct meanings of the local/remote dichotomy in Modal:

  • practical sense:
    • local: not on modal infrastructure
    • remote: on modal infrastructure
  • functional sense:
    • local: the context that you run or deploy your applications from
    • remote: the context that you run or deploy your applications in

(This is maybe not a perfect set of definitions but hopefully it makes sense)

The _is_remote helper indicates which side you're on in the practical sense (based on the environment variables that we define in containers).

But what about users who want to run or deploy applications from Modal infrastructure? I thought we had people doing that; including people doing it on behalf of their users (such that the orchestrator app and worker app are using different tokens). Are we breaking that behavior? Maybe we're not — but it feels very hard to reason about.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me add a test for deploying Modal apps from inside containers. It's possible this PR broke it because of the authenticated check. That being said, the authentication system (client vs container vs web) is basically orthogonal to what we're doing (creating an app vs running code inside an app).

@erikbern
Copy link
Contributor Author

On second thought I think this change conflates a bunch of logic changes with a bunch of test fixture stuff. I'm going to close this one and try to focus on just fixing tests first. That should make it possible to change the actual logic separately from the tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants