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

Added session management routes + crd + cli interaction. #2235

Merged
merged 48 commits into from
Feb 28, 2024

Conversation

meowjesty
Copy link
Member

@meowjesty meowjesty commented Feb 13, 2024

Creates a new cli command to forcefully kill one or more OperatorSessions.

Adds a new CustomResource, as this new command is a a separate route in the operator from the ones that we had.

@meowjesty meowjesty marked this pull request as ready for review February 15, 2024 20:43
Copy link
Contributor

@Razz4780 Razz4780 left a comment

Choose a reason for hiding this comment

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

I feel like this also needs another operator feature, like session_management: bool. Otherwise the users will see real ugliness 💀

mirrord/cli/src/operator.rs Outdated Show resolved Hide resolved
mirrord/cli/src/config.rs Show resolved Hide resolved
mirrord/cli/src/config.rs Show resolved Hide resolved
mirrord/config/src/target.rs Outdated Show resolved Hide resolved
mirrord/config/src/target.rs Outdated Show resolved Hide resolved
mirrord/cli/src/operator/session.rs Outdated Show resolved Hide resolved
mirrord/cli/src/operator/session.rs Outdated Show resolved Hide resolved
mirrord/cli/src/operator/session.rs Outdated Show resolved Hide resolved
mirrord/cli/src/operator/session.rs Outdated Show resolved Hide resolved
mirrord/cli/src/operator/session.rs Outdated Show resolved Hide resolved
meowjesty and others added 3 commits February 21, 2024 16:00
Co-authored-by: Michał Smolarek <[email protected]>
Co-authored-by: Michał Smolarek <[email protected]>
Co-authored-by: Michał Smolarek <[email protected]>
@meowjesty
Copy link
Member Author

I feel like this also needs another operator feature, like session_management: bool. Otherwise the users will see real ugliness 💀

Ideally we would have some credentials/permissions system in place, so a random user would not be able to just kill-all sessions, instead they could only kill their own. While some admin level user could do whatever.

We could add a route that enables/disables session management, but this seems like extra annoyance for users, due to us not having a system in place to handle this stuff?

@aviramha
Copy link
Member

I feel like this also needs another operator feature, like session_management: bool. Otherwise the users will see real ugliness 💀

Ideally we would have some credentials/permissions system in place, so a random user would not be able to just kill-all sessions, instead they could only kill their own. While some admin level user could do whatever.

We could add a route that enables/disables session management, but this seems like extra annoyance for users, due to us not having a system in place to handle this stuff?

That's controlled via k8s RBAC. To use the route users need to have the delete verb on the sessions resource.

@Razz4780
Copy link
Contributor

Razz4780 commented Feb 23, 2024

I feel like this also needs another operator feature, like session_management: bool. Otherwise the users will see real ugliness 💀

Ideally we would have some credentials/permissions system in place, so a random user would not be able to just kill-all sessions, instead they could only kill their own. While some admin level user could do whatever.
We could add a route that enables/disables session management, but this seems like extra annoyance for users, due to us not having a system in place to handle this stuff?

That's controlled via k8s RBAC. To use the route users need to have the delete verb on the sessions resource.

To be honest, I was not thinking about access control at all. Rather compatibility with older operators, which don't have these routes. Like with copy_target, the operator should announce that it supports killing sessions, so that the users don't see generic 404 or 503 (?) when it doesn't

@aviramha
Copy link
Member

Ah it could be nice the cli to check for feature existence, yes.

@meowjesty
Copy link
Member Author

Ah it could be nice the cli to check for feature existence, yes.

Hmm we could just convert an 404 for hitting a missing route in an error saying "The operator doesn't seem to support this operation.". Maybe the message could also contain the operator version? I think the whole handling for this can be done on the cli-side?

@meowjesty
Copy link
Member Author

killing all sessions
  x Session operation `kill-all` failed!
    x `operator session kill-all` is not supported by the mirrord-operator found in your cluster, consider updating it!                                                                                             2024-02-26T18:02:45.664986Z ERROR mirrord::operator::session: not_supported="`operator session kill-all` is not supported by the mirrord-operator found in your cluster, consider updating it!"
Error:   × Failed to connect to the operator, probably due to RBAC: getting status failed: ApiError: "": Failed to parse error data (ErrorResponse { status: "404 Not Found", message: "\"\"", reason: "Failed to parse
  │ error data", code: 404 })

(...)

Progress now shows a nicer error if operator version doesn't support the session ops.

Copy link
Contributor

@Razz4780 Razz4780 left a comment

Choose a reason for hiding this comment

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

Looks mostly good, but there are 3 things:

  1. Do we really need the response.reason.contains("parse") part when checking operator response? I think checking status code should be enough.
  2. Same error handling logic is repeated in all 3 command handlers
  3. Using OperatorApiError::KubeError with OperatorOperation::GettingStatus is not a good idea. User sees Failed to connect to the operator, probably due to RBAC: getting status failed in the CLI output :x You can use OperatorApiError::UnsupportedFeature for this. It would require fetching the operator status first (you'd need the operator version), but I think it's even better - we can check if the operator is installed before attempting to kill sessions

mirrord/cli/src/operator/session.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@Razz4780 Razz4780 left a comment

Choose a reason for hiding this comment

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

Wonderful 🐈

@meowjesty meowjesty added this pull request to the merge queue Feb 28, 2024
Merged via the queue into metalbear-co:main with commit e72e888 Feb 28, 2024
16 checks passed
@meowjesty meowjesty deleted the issue/217/clearing-routes branch February 28, 2024 15:40
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.

3 participants