-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[usage] Change instance runtime calculation: creationTime → startedTime, stoppedTime → stoppingTime #12195
Conversation
39eea52
to
8aaa1ab
Compare
8aaa1ab
to
ca1252f
Compare
I don't know the background of this decision, but I think counting in the starting and stopping time makes sense, especially until we bill usage for storage because the starting and stopping phase highly depend on the size of the workspace backup. |
Thanks for your feedback @svenefftinge!
This is exactly the reason we initially went with However, there is one problem with Regarding However, I do share your worries about the shorter runtime tracking -- by doing
That's maybe okay at first, but might come back to bite us in the future e.g. when we want to start billing any of these, thus making Gitpod more expensive for users (it's always easier to start expensive and make it cheaper, than to start cheap and regularly make it more expensive 😬). But since |
@jankeromnes Thanks for identifying the status quo, incl. the (potential) changes. @svenefftinge First and foremost, I wanted to have the discussion and document it somewhere. Maybe I just wasn't part of the last one..? 🤷 For context: here is what we do now (Chargebee): started -> stopping Regarding "when does the session a) start and b) end":
I have no hard feelings here, but feel that |
Thanks for sharing your thoughts. Makes sense 👍 |
@@ -280,6 +287,7 @@ func TestReportGenerator_GenerateUsageReport(t *testing.T) { | |||
ID: uuid.New(), | |||
UsageAttributionID: db.NewTeamAttributionID(teamID.String()), | |||
StartedTime: db.NewVarcharTime(time.Date(2022, 06, 1, 1, 0, 0, 0, time.UTC)), | |||
StoppingTime: db.NewVarcharTime(time.Date(2022, 06, 1, 1, 0, 0, 0, time.UTC)), | |||
StoppedTime: db.NewVarcharTime(time.Date(2022, 06, 1, 1, 0, 0, 0, time.UTC)), |
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.
the comment says: No creation time, invalid record
. that should be No startedTime, invalid record
and StartedTime
should be removed, I guess.
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.
Hmm, is this actually the case? This part of the query hasn't changed:
gitpod/components/usage/pkg/db/workspace_instance.go
Lines 79 to 80 in 135bc0f
Where("wsi.creationTime < ?", TimeToISO8601(to)). | |
Where("wsi.startedTime != ?", ""). |
And when I remove the StartedTime
, this changes the test behavior from {3 raw sessions; 1 invalid session; 2 usage records} to {2 raw sessions; 0 invalid session; 2 usage records}.
For now I've rolled back this suggestion, but please let me know if the test / the query logic should change here.
if instance.CreationTime.Time().Before(maximumStart) { | ||
instance.CreationTime = db.NewVarcharTime(maximumStart) | ||
if instance.StartedTime.Time().Before(maximumStart) { | ||
instance.StartedTime = db.NewVarcharTime(maximumStart) |
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.
Unrelated to this PR, but manipulating instances here was surprising, especially since they are handed out through the usage report. I don't have enough context, yet, though. Just wanted to share.
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 agree, and think it would make more sense to manipulate usage records instead of instances.
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.
They are not manipulated, as we create copies here (not working on references/pointers).
But had to read twice as well.. 😆 🙈
…me, stoppedTime → stoppingTime
ca1252f
to
812f6eb
Compare
…topping/stopped time
812f6eb
to
1a12a75
Compare
Had a discussion with @jankeromnes again. We noticed that if we would (have and) use
As we do not have I will document the discussion that happened here, and will ask Team Workspace how much effort it is to re-vive |
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.
Code LGTM and tests work.
Description
Change instance runtime calculation:
Related Issue(s)
Fixes #12177
How to test
Release Notes
Documentation
Werft options: