File tree Expand file tree Collapse file tree 6 files changed +35
-4
lines changed
services/pegboard/db/runner-log/migrations Expand file tree Collapse file tree 6 files changed +35
-4
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ pub struct LogShipper {
37
37
pub vector_socket_addr : String ,
38
38
39
39
pub runner_id : String ,
40
+ pub actor_id : Option < String > ,
40
41
}
41
42
42
43
impl LogShipper {
@@ -91,7 +92,7 @@ impl LogShipper {
91
92
while let Result :: Ok ( message) = self . msg_rx . recv ( ) {
92
93
let vector_message = VectorMessage :: Runners {
93
94
runner_id : self . runner_id . as_str ( ) ,
94
- task : "main" , // Backwards compatibility with logs
95
+ actor_id : self . actor_id . as_ref ( ) . map ( |x| x . as_str ( ) ) ,
95
96
stream_type : message. stream_type as u8 ,
96
97
ts : message. ts ,
97
98
message : message. message . as_str ( ) ,
@@ -114,7 +115,7 @@ enum VectorMessage<'a> {
114
115
#[ serde( rename = "runners" ) ]
115
116
Runners {
116
117
runner_id : & ' a str ,
117
- task : & ' a str ,
118
+ actor_id : Option < & ' a str > ,
118
119
stream_type : u8 ,
119
120
ts : u64 ,
120
121
message : & ' a str ,
Original file line number Diff line number Diff line change @@ -37,6 +37,8 @@ fn main() -> Result<()> {
37
37
. transpose ( )
38
38
. context ( "failed to parse vector socket addr" ) ?;
39
39
let runner_id = var ( "RUNNER_ID" ) ?;
40
+ // Only set if this is a single allocation runner (one actor running on it)
41
+ let actor_id = var ( "ACTOR_ID" ) . ok ( ) ;
40
42
41
43
let ( shutdown_tx, shutdown_rx) = mpsc:: sync_channel ( 1 ) ;
42
44
@@ -49,6 +51,7 @@ fn main() -> Result<()> {
49
51
msg_rx,
50
52
vector_socket_addr,
51
53
runner_id,
54
+ actor_id,
52
55
} ;
53
56
let log_shipper_thread = log_shipper. spawn ( ) ;
54
57
( Some ( msg_tx) , Some ( log_shipper_thread) )
Original file line number Diff line number Diff line change @@ -116,9 +116,15 @@ impl Actor {
116
116
. context ( "should have runner config" ) ?
117
117
{
118
118
protocol:: ActorRunner :: New { .. } => {
119
+ let actor_id = matches ! (
120
+ self . runner. config( ) . image. allocation_type,
121
+ protocol:: ImageAllocationType :: Single
122
+ )
123
+ . then_some ( self . actor_id ) ;
124
+
119
125
// Because the runner is not already started we can get the ports here instead of reading from
120
126
// sqlite
121
- let ports = self . runner . start ( ctx) . await ?;
127
+ let ports = self . runner . start ( ctx, actor_id ) . await ?;
122
128
123
129
let pid = self . runner . pid ( ) . await ?;
124
130
Original file line number Diff line number Diff line change @@ -243,9 +243,12 @@ impl Runner {
243
243
Ok ( ( ) )
244
244
}
245
245
246
+ // `actor_id` is set if this runner has a single allocation type which means there is only one actor
247
+ // runner on it
246
248
pub async fn start (
247
249
self : & Arc < Self > ,
248
250
ctx : & Arc < Ctx > ,
251
+ actor_id : Option < Uuid > ,
249
252
) -> Result < protocol:: HashableMap < String , protocol:: ProxiedPort > > {
250
253
tracing:: info!( runner_id=?self . runner_id, "starting" ) ;
251
254
@@ -298,7 +301,7 @@ impl Runner {
298
301
let self2 = self . clone ( ) ;
299
302
let ctx2 = ctx. clone ( ) ;
300
303
tokio:: spawn ( async move {
301
- match self2. run ( & ctx2) . await {
304
+ match self2. run ( & ctx2, actor_id ) . await {
302
305
Ok ( _) => {
303
306
if let Err ( err) = self2. observe ( & ctx2, false ) . await {
304
307
tracing:: error!( runner_id=?self2. runner_id, ?err, "observe failed" ) ;
@@ -333,6 +336,7 @@ impl Runner {
333
336
) ,
334
337
( "RUNNER_ID" , self . runner_id. to_string( ) ) ,
335
338
] ;
339
+
336
340
if let Some ( vector) = & ctx. config ( ) . vector {
337
341
runner_env. push ( ( "VECTOR_SOCKET_ADDR" , vector. address . to_string ( ) ) ) ;
338
342
}
Original file line number Diff line number Diff line change
1
+
2
+ CREATE TABLE IF NOT EXISTS runner_logs (
3
+ runner_id UUID,
4
+ actor_id UUID, -- When not set will be the NIL UUID (all zeros)
5
+ stream_type UInt8, -- pegboard::types::LogsStreamType
6
+ ts DateTime64 (9 ),
7
+ message String
8
+ ) ENGINE = ReplicatedMergeTree ()
9
+ PARTITION BY
10
+ toStartOfHour (ts)
11
+ ORDER BY (
12
+ runner_id,
13
+ toUnixTimestamp (ts),
14
+ stream_type
15
+ )
16
+ TTL toDate (ts + toIntervalDay (3 ))
17
+ SETTINGS index_granularity = 8192 , ttl_only_drop_parts = 1 ;
You can’t perform that action at this time.
0 commit comments