Skip to content

Commit 724f139

Browse files
committed
Minor fix-ups
Signed-off-by: Danny Kopping <danny@coder.com>
1 parent 6f0b8f8 commit 724f139

File tree

9 files changed

+172
-53
lines changed

9 files changed

+172
-53
lines changed

coderd/database/dump.sql

Lines changed: 32 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
INSERT INTO provisioner_job_timings (job_id, started_at, ended_at, stage, source, action, resource)
2+
VALUES
3+
-- Job 1 - init stage
4+
('d09b6083-e482-41ac-ad06-3aa731ec4fc6', NOW() - INTERVAL '1 hour 55 minutes', NOW() - INTERVAL '1 hour 50 minutes', 'init', 'source1', 'action1', 'resource1'),
5+
6+
-- Job 1 - plan stage
7+
('d09b6083-e482-41ac-ad06-3aa731ec4fc6', NOW() - INTERVAL '1 hour 50 minutes', NOW() - INTERVAL '1 hour 40 minutes', 'plan', 'source2', 'action2', 'resource2'),
8+
9+
-- Job 1 - graph stage
10+
('d09b6083-e482-41ac-ad06-3aa731ec4fc6', NOW() - INTERVAL '1 hour 40 minutes', NOW() - INTERVAL '1 hour 30 minutes', 'graph', 'source3', 'action3', 'resource3'),
11+
12+
-- Job 1 - apply stage
13+
('d09b6083-e482-41ac-ad06-3aa731ec4fc6', NOW() - INTERVAL '1 hour 30 minutes', NOW() - INTERVAL '1 hour 20 minutes', 'apply', 'source4', 'action4', 'resource4');

coderd/provisionerdserver/provisionerdserver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1471,7 +1471,7 @@ func (s *server) CompleteJob(ctx context.Context, completed *proto.CompletedJob)
14711471
_, err = s.Database.InsertProvisionerJobTimings(ctx, params)
14721472
if err != nil {
14731473
// Don't fail the transaction for non-critical data.
1474-
s.Logger.Warn(ctx, "failed to update provisioner job timings", slog.Error(err))
1474+
s.Logger.Warn(ctx, "failed to update provisioner job timings", slog.F("job_id", jobID), slog.Error(err))
14751475
}
14761476

14771477
// audit the outcome of the workspace build

codersdk/workspacebuilds.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -74,23 +74,6 @@ type WorkspaceBuild struct {
7474
DailyCost int32 `json:"daily_cost"`
7575
}
7676

77-
// WorkspaceBuildStats is a point-in-time representation of a workspace build, including timing information.
78-
type WorkspaceBuildStats struct {
79-
ID uuid.UUID `json:"id" format:"uuid"`
80-
JobStatus ProvisionerJobStatus `json:"job_status"`
81-
WorkerID uuid.UUID `json:"worker_id" format:"uuid"`
82-
WorkspaceID uuid.UUID `json:"workspace_id" format:"uuid"`
83-
Error string `json:"error"`
84-
ErrorCode string `json:"error_code"`
85-
UpdatedAt time.Time `json:"updated_at" format:"date-time"`
86-
QueuedSecs float64 `json:"queued_secs"`
87-
CompletionSecs float64 `json:"completion_secs"`
88-
CanceledSecs float64 `json:"canceled_secs"`
89-
InitSecs float64 `json:"init_secs"`
90-
PlanSecs float64 `json:"plan_secs"`
91-
ApplySecs float64 `json:"apply_secs"`
92-
}
93-
9477
// WorkspaceResource describes resources used to create a workspace, for instance:
9578
// containers, images, volumes.
9679
type WorkspaceResource struct {

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
name = "coder-${osArch}";
118118
# Updated with ./scripts/update-flake.sh`.
119119
# This should be updated whenever go.mod changes!
120-
vendorHash = "sha256-AZ0qzh7H+UwnZNyg2iaNMSUWlGgomI/mo70T+FdF7ws=";
120+
vendorHash = "sha256-i3sseokxA5MoSJDzrWJI+GdS5HOYG1fPIRdr239Zx30=";
121121
proxyVendor = true;
122122
src = ./.;
123123
nativeBuildInputs = with pkgs; [ getopt openssl zstd ];

provisioner/terraform/timings_internal_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func TestAggregation(t *testing.T) {
6868
// txtar is a text-based archive format used in the stdlib for simple and elegant tests.
6969
//
7070
// We ALWAYS expect that the archive contains two or more "files":
71-
// 1. JSON logs generated by a terraform execution, one per line, *one file per stage*
71+
// 1. JSON logs generated by a terraform execution, one per line, *one file per stage*
7272
// N. Expected resulting timings in JSON form, one per line
7373
arc := txtar.Parse(tc.input)
7474
require.GreaterOrEqual(t, len(arc.Files), 2)

provisioner/terraform/timings_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ func TestTimingsFromProvision(t *testing.T) {
9494
// Sort the timings stably to keep reduce flakiness.
9595
terraform.StableSortTimings(t, timings)
9696

97+
// Then: the received timings should match the expected values below.
9798
// NOTE: These timings have been encoded to JSON format to make the tests more readable.
9899
planTimings := terraform.ParseTimingLines(t, []byte(`{"start":"2024-08-15T08:26:39.194726Z", "end":"2024-08-15T08:26:39.195836Z", "action":"read", "source":"coder", "resource":"data.coder_parameter.memory_size", "stage":"plan", "state":"COMPLETED"}
99100
{"start":"2024-08-15T08:26:39.194726Z", "end":"2024-08-15T08:26:39.195712Z", "action":"read", "source":"coder", "resource":"data.coder_provisioner.me", "stage":"plan", "state":"COMPLETED"}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
/* eslint-disable */
2+
import * as _m0 from "protobufjs/minimal";
3+
4+
export const protobufPackage = "google.protobuf";
5+
6+
/**
7+
* A Timestamp represents a point in time independent of any time zone or local
8+
* calendar, encoded as a count of seconds and fractions of seconds at
9+
* nanosecond resolution. The count is relative to an epoch at UTC midnight on
10+
* January 1, 1970, in the proleptic Gregorian calendar which extends the
11+
* Gregorian calendar backwards to year one.
12+
*
13+
* All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
14+
* second table is needed for interpretation, using a [24-hour linear
15+
* smear](https://developers.google.com/time/smear).
16+
*
17+
* The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
18+
* restricting to that range, we ensure that we can convert to and from [RFC
19+
* 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
20+
*
21+
* # Examples
22+
*
23+
* Example 1: Compute Timestamp from POSIX `time()`.
24+
*
25+
* Timestamp timestamp;
26+
* timestamp.set_seconds(time(NULL));
27+
* timestamp.set_nanos(0);
28+
*
29+
* Example 2: Compute Timestamp from POSIX `gettimeofday()`.
30+
*
31+
* struct timeval tv;
32+
* gettimeofday(&tv, NULL);
33+
*
34+
* Timestamp timestamp;
35+
* timestamp.set_seconds(tv.tv_sec);
36+
* timestamp.set_nanos(tv.tv_usec * 1000);
37+
*
38+
* Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
39+
*
40+
* FILETIME ft;
41+
* GetSystemTimeAsFileTime(&ft);
42+
* UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
43+
*
44+
* // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
45+
* // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
46+
* Timestamp timestamp;
47+
* timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
48+
* timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
49+
*
50+
* Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
51+
*
52+
* long millis = System.currentTimeMillis();
53+
*
54+
* Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
55+
* .setNanos((int) ((millis % 1000) * 1000000)).build();
56+
*
57+
* Example 5: Compute Timestamp from Java `Instant.now()`.
58+
*
59+
* Instant now = Instant.now();
60+
*
61+
* Timestamp timestamp =
62+
* Timestamp.newBuilder().setSeconds(now.getEpochSecond())
63+
* .setNanos(now.getNano()).build();
64+
*
65+
* Example 6: Compute Timestamp from current time in Python.
66+
*
67+
* timestamp = Timestamp()
68+
* timestamp.GetCurrentTime()
69+
*
70+
* # JSON Mapping
71+
*
72+
* In JSON format, the Timestamp type is encoded as a string in the
73+
* [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
74+
* format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
75+
* where {year} is always expressed using four digits while {month}, {day},
76+
* {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
77+
* seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
78+
* are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
79+
* is required. A proto3 JSON serializer should always use UTC (as indicated by
80+
* "Z") when printing the Timestamp type and a proto3 JSON parser should be
81+
* able to accept both UTC and other timezones (as indicated by an offset).
82+
*
83+
* For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
84+
* 01:30 UTC on January 15, 2017.
85+
*
86+
* In JavaScript, one can convert a Date object to this format using the
87+
* standard
88+
* [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
89+
* method. In Python, a standard `datetime.datetime` object can be converted
90+
* to this format using
91+
* [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
92+
* the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
93+
* the Joda Time's [`ISODateTimeFormat.dateTime()`](
94+
* http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()
95+
* ) to obtain a formatter capable of generating timestamps in this format.
96+
*/
97+
export interface Timestamp {
98+
/**
99+
* Represents seconds of UTC time since Unix epoch
100+
* 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
101+
* 9999-12-31T23:59:59Z inclusive.
102+
*/
103+
seconds: number;
104+
/**
105+
* Non-negative fractions of a second at nanosecond resolution. Negative
106+
* second values with fractions must still have non-negative nanos values
107+
* that count forward in time. Must be from 0 to 999,999,999
108+
* inclusive.
109+
*/
110+
nanos: number;
111+
}
112+
113+
export const Timestamp = {
114+
encode(message: Timestamp, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
115+
if (message.seconds !== 0) {
116+
writer.uint32(8).int64(message.seconds);
117+
}
118+
if (message.nanos !== 0) {
119+
writer.uint32(16).int32(message.nanos);
120+
}
121+
return writer;
122+
},
123+
};

site/src/api/typesGenerated.ts

Lines changed: 0 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)