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

[BUG] External command only gets called once #6254

Open
2 tasks done
andrei-trandafir opened this issue Feb 17, 2025 · 5 comments
Open
2 tasks done

[BUG] External command only gets called once #6254

andrei-trandafir opened this issue Feb 17, 2025 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@andrei-trandafir
Copy link

Describe the bug

For services that use the ExternalCommand auth type with the admin server, the command execution only happens once when the flyteidl client is instantiated.

This behaviour was introduced in issue #5606 (PR #5686) when optimisations were made to reduce the number of calls to the admin authentication metadata endpoints. These changes also resulted in putting the creation of the token source provider for the client behind a Once synchronization (link).

As the external command gets executed in the token source provider (link), this only gets executed once, resulting in errors if the provided token expires or needs to be refreshed for any reason.

This bug broke our propeller instance when upgrading from version 1.11.0 to 1.14.1 as our external command returns a token that expires afters 45 minutes and results in a Unauthenticated error being returned from the admin instance.

Expected behavior

The external command should be re-executed whenever authentication fails. This ensures that if the external command expires or depends on some external configuration that might change, the command is re-run and authentication can continue.

This can be implemented by creating a custom externalCommandTokenSource that runs the command instead of the token source provider. Given that the token would be saved into the token cache, this command wouldn't be called until the token would expire, effectively providing the same experience for deployments that have non-expiring tokens.

This approach keeps the same behaviour for other authentication methods and the same behaviour of caching the authentication metadata that was originally introduced in the PR mentioned earlier.

Additional context to reproduce

  1. Deploy a flyte cluster where the propeller uses ExternalCommand authentication where the command returns a token that will expire.
  2. Wait until the token expires

Screenshots

No response

Are you sure this issue hasn't been raised already?

  • Yes

Have you read the Code of Conduct?

  • Yes
@andrei-trandafir andrei-trandafir added bug Something isn't working untriaged This issues has not yet been looked at by the Maintainers labels Feb 17, 2025
@eapolinario eapolinario removed the untriaged This issues has not yet been looked at by the Maintainers label Feb 20, 2025
@wild-endeavor
Copy link
Contributor

@andrei-trandafir just to be clear this is what you're referring to correct? https://github.com/flyteorg/flyte/pull/6271/files

@andrei-trandafir
Copy link
Author

@wild-endeavor that's exactly it, I've already opened a PR myself:
#6255

@wild-endeavor
Copy link
Contributor

Oh sorry... I completely missed that. I'm not used to not seeing the pr badge. Mind adding some unit tests to your PR and testing it?

I did my best to go through all the calls to Token() last night, I don't think there's anything crazy, but is there any chance you can test the change against your backend, just to make sure it's making the number of calls you expect?

@andrei-trandafir
Copy link
Author

andrei-trandafir commented Feb 26, 2025

Yeah, I'll be adding some tests soon, sorry for the delay on it.

We've already added this change to our instance and so far it seems to be working as expected.

@wild-endeavor
Copy link
Contributor

thanks! let me know when it's ready for review and i'll close my pr.

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
Status: Backlog
Development

No branches or pull requests

3 participants