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

Teleterm: Define / Set AssumeStartTime fields #38480

Closed
wants to merge 7 commits into from

Conversation

kimlisa
Copy link
Contributor

@kimlisa kimlisa commented Feb 21, 2024

part of #35436

suggest reivewing by commit

This PR just defines and sets the AssumeStartTime fields in backend/frontend when: creating, reviewing, and listing

@kimlisa kimlisa added no-changelog Indicates that a PR does not require a changelog entry backport/branch/v15 labels Feb 21, 2024
@github-actions github-actions bot requested review from avatus and rudream February 21, 2024 03:27
@kimlisa kimlisa requested review from ravicious and gzdunek and removed request for avatus and rudream February 21, 2024 03:27
@kimlisa kimlisa force-pushed the lisa/teleterm-assume-start-time-fields branch from 6a28114 to 85664ad Compare February 21, 2024 03:29
@kimlisa kimlisa force-pushed the lisa/teleterm-assume-start-time-fields branch from f591e9a to 0d50dd1 Compare February 21, 2024 04:02
@kimlisa kimlisa requested a review from gzdunek February 22, 2024 05:07
api/types/access_request.go Outdated Show resolved Hide resolved
lib/teleterm/clusters/cluster_access_requests.go Outdated Show resolved Hide resolved
lib/teleterm/clusters/cluster_access_requests.go Outdated Show resolved Hide resolved
lib/teleterm/apiserver/handler/time_converter.go Outdated Show resolved Hide resolved
@kimlisa kimlisa requested a review from gzdunek February 23, 2024 16:37
Comment on lines +68 to +69
// can overwrite the start time requested by the requester
// by the reviewer.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// can overwrite the start time requested by the requester
// by the reviewer.
// The reviewer can overwrite the requested time.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe just "Overwrites the requested start time"? We're inside AccessRequestReview, so it should be clear who does what and directly states that this specific field, not just "the reviewer", overwrites the requested time.

The only question is whether this field is optional or not and whether it always overwrites the requested start time. An answer to this question should be included in the comment as well.

Comment on lines +68 to +69
// can overwrite the start time requested by the requester
// by the reviewer.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe just "Overwrites the requested start time"? We're inside AccessRequestReview, so it should be clear who does what and directly states that this specific field, not just "the reviewer", overwrites the requested time.

The only question is whether this field is optional or not and whether it always overwrites the requested start time. An answer to this question should be included in the comment as well.


// Too far in the future.
invalidStartTime := clock.Now().UTC().Add(1000000 * time.Hour)
err := ValidateAssumeStartTime(invalidStartTime)
Copy link
Member

Choose a reason for hiding this comment

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

I don't know where this function comes from, but shouldn't it accept the clock as an argument? In Go we cannot (shouldn't?) mock the system clock like in Jest. Most of the code that I saw that uses the clockwork package accepts the clock from outside so that tests can pass a fake clock. See lib/utils.VerifyCertificateExpiry for an example.

@@ -1096,6 +1097,14 @@ func (m *RequestValidator) Validate(ctx context.Context, req types.AccessRequest
return trace.BadParameter("only promoted requests can set the promoted access list title")
}

if req.GetAssumeStartTime() != nil {
assumeStartTime := *req.GetAssumeStartTime()
if time.Until(assumeStartTime) > constants.MaxAssumeStartDuration {
Copy link
Member

Choose a reason for hiding this comment

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

We should probably use m.clock to calculate this, with similar argumentation to one of my previous comments.

It seems like there's quite a few places in this file that already do this.

Copy link
Member

Choose a reason for hiding this comment

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

Even though this change is not that big, I feel like it deserves its own PR rather than being bundled together with teleterm changes. I think backend changes deserve more scrutiny by the virtue of being used by the server vs teleterm code which is merely a client.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I noticed that we're also moving the validation from tool/ – this would be another argument in favor of preparing a separate PR.

lib/teleterm/clusters/cluster_access_requests.go Outdated Show resolved Hide resolved
@kimlisa
Copy link
Contributor Author

kimlisa commented Mar 7, 2024

closing in favor of #39050, which extracts just defining new fields to teleterm api

@kimlisa kimlisa closed this Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/branch/v14 backport/branch/v15 no-changelog Indicates that a PR does not require a changelog entry size/md ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants