Skip to content

Commit 712168b

Browse files
authored
Feature: Task Scheduling configuration during task creation (#337)
* introduce very basic task_scheduling configuration during task creation * allow node_groups plugin to schedule tasks based on matching plugin config
1 parent 49d5c00 commit 712168b

File tree

8 files changed

+163
-62
lines changed

8 files changed

+163
-62
lines changed

crates/orchestrator/src/api/routes/heartbeat.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@ mod tests {
139139
let task = TaskRequest {
140140
image: "test".to_string(),
141141
name: "test".to_string(),
142-
command: None,
143-
args: None,
144-
env_vars: None,
142+
..Default::default()
145143
};
146144
app_state.store_context.task_store.add_task(task.into());
147145

@@ -171,12 +169,7 @@ mod tests {
171169
let value = value.unwrap();
172170
let heartbeat = HeartbeatRequest {
173171
address: "0x0000000000000000000000000000000000000000".to_string(),
174-
task_id: None,
175-
task_state: None,
176-
metrics: None,
177-
version: None,
178-
timestamp: None,
179-
p2p_id: None,
172+
..Default::default()
180173
};
181174
assert_eq!(value, heartbeat);
182175
}

crates/orchestrator/src/api/routes/task.rs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ async fn get_all_tasks(app_state: Data<AppState>) -> HttpResponse {
1616
async fn create_task(task: web::Json<TaskRequest>, app_state: Data<AppState>) -> HttpResponse {
1717
let task = Task::from(task.into_inner());
1818
let task_store = app_state.store_context.task_store.clone();
19+
1920
task_store.add_task(task.clone());
2021
HttpResponse::Ok().json(json!({"success": true, "task": task}))
2122
}
@@ -57,9 +58,7 @@ mod tests {
5758
let payload = TaskRequest {
5859
image: "test".to_string(),
5960
name: "test".to_string(),
60-
command: None,
61-
args: None,
62-
env_vars: None,
61+
..Default::default()
6362
};
6463
let req = test::TestRequest::post()
6564
.uri("/tasks")
@@ -101,9 +100,7 @@ mod tests {
101100
let task: Task = TaskRequest {
102101
image: "test".to_string(),
103102
name: "test".to_string(),
104-
command: None,
105-
args: None,
106-
env_vars: None,
103+
..Default::default()
107104
}
108105
.into();
109106

@@ -136,9 +133,7 @@ mod tests {
136133
let task: Task = TaskRequest {
137134
image: "test".to_string(),
138135
name: "test".to_string(),
139-
command: None,
140-
args: None,
141-
env_vars: None,
136+
..Default::default()
142137
}
143138
.into();
144139

@@ -178,9 +173,7 @@ mod tests {
178173
let task1: Task = TaskRequest {
179174
image: "test1".to_string(),
180175
name: "test1".to_string(),
181-
command: None,
182-
args: None,
183-
env_vars: None,
176+
..Default::default()
184177
}
185178
.into();
186179
task_store.add_task(task1.clone());
@@ -192,9 +185,7 @@ mod tests {
192185
let task2: Task = TaskRequest {
193186
image: "test2".to_string(),
194187
name: "test2".to_string(),
195-
command: None,
196-
args: None,
197-
env_vars: None,
188+
..Default::default()
198189
}
199190
.into();
200191
task_store.add_task(task2.clone());
@@ -223,9 +214,7 @@ mod tests {
223214
let task: Task = TaskRequest {
224215
image: format!("test{}", i),
225216
name: format!("test{}", i),
226-
command: None,
227-
args: None,
228-
env_vars: None,
217+
..Default::default()
229218
}
230219
.into();
231220
task_store.add_task(task);

crates/orchestrator/src/scheduler/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,9 @@ mod tests {
6060
id: Uuid::new_v4(),
6161
image: "image".to_string(),
6262
name: "name".to_string(),
63-
env_vars: None,
64-
command: None,
65-
args: None,
6663
state: TaskState::PENDING,
6764
created_at: 1,
68-
updated_at: None,
65+
..Default::default()
6966
};
7067

7168
state.store_context.task_store.add_task(task.clone());

crates/orchestrator/src/scheduler/plugins/newest_task.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,17 @@ mod tests {
3737
id: Uuid::new_v4(),
3838
image: "image".to_string(),
3939
name: "name".to_string(),
40-
env_vars: None,
41-
command: None,
42-
args: None,
4340
state: TaskState::PENDING,
4441
created_at: 1,
45-
updated_at: None,
42+
..Default::default()
4643
},
4744
Task {
4845
id: Uuid::new_v4(),
4946
image: "image".to_string(),
5047
name: "name".to_string(),
51-
env_vars: None,
52-
command: None,
53-
args: None,
5448
state: TaskState::PENDING,
5549
created_at: 2,
56-
updated_at: None,
50+
..Default::default()
5751
},
5852
];
5953

0 commit comments

Comments
 (0)