Skip to content

Commit c8f8f87

Browse files
committed
[scheduler] Add hardware tags to rust scheduler
A new tag type was added by AcademySoftwareFoundation#2125 and needs to be handled by the Scheduler module to account for the new type
1 parent c4b0cac commit c8f8f87

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

rust/crates/scheduler/src/cluster.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ impl ClusterFeed {
106106
.chain(cluster_dao.fetch_non_alloc_clusters());
107107
let mut clusters = Vec::new();
108108
let mut manual_tags: HashMap<Uuid, Vec<String>> = HashMap::new();
109+
let mut hardware_tags: HashMap<Uuid, Vec<String>> = HashMap::new();
109110
let mut hostname_tags: HashMap<Uuid, Vec<String>> = HashMap::new();
110111

111112
// Collect all tags
@@ -149,6 +150,12 @@ impl ClusterFeed {
149150
.or_default()
150151
.push(cluster.tag);
151152
}
153+
"HARDWARE" => {
154+
hardware_tags
155+
.entry(parse_uuid(&cluster.facility_id))
156+
.or_default()
157+
.push(cluster.tag);
158+
}
152159
_ => (),
153160
};
154161
}
@@ -189,6 +196,25 @@ impl ClusterFeed {
189196
}
190197
}
191198

199+
// Chunk Hardware tags
200+
for (facility_id, tags) in hardware_tags.into_iter() {
201+
for chunk in &tags
202+
.into_iter()
203+
// Hardware share the same size as manual to simplify configuration
204+
.chunks(CONFIG.queue.manual_tags_chunk_size)
205+
{
206+
clusters.push(Cluster::TagsKey(
207+
facility_id,
208+
chunk
209+
.map(|name| Tag {
210+
name,
211+
ttype: TagType::Hardware,
212+
})
213+
.collect(),
214+
))
215+
}
216+
}
217+
192218
Ok(ClusterFeed {
193219
clusters: Arc::new(RwLock::new(clusters)),
194220
current_index: Arc::new(AtomicUsize::new(0)),

rust/crates/scheduler/src/cluster_key.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub enum TagType {
1818
Alloc,
1919
HostName,
2020
Manual,
21+
Hardware,
2122
}
2223

2324
#[derive(Serialize, Deserialize, Debug, Clone, Hash, PartialEq, Eq)]

rust/crates/scheduler/src/host_cache/actor.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,13 +376,16 @@ impl HostCacheService {
376376
show_id,
377377
tag,
378378
})
379-
// Make sure tags are evaluated in this order: MANUAL -> HOSTNAME -> ALLOC
379+
// Make sure tags are evaluated in this order:
380+
// MANUAL -> HOSTNAME -> HARDWARE -> ALLOC
380381
.sorted_by(|l, r| match (&l.tag.ttype, &r.tag.ttype) {
381382
(TagType::Alloc, TagType::Alloc)
382383
| (TagType::HostName, TagType::HostName)
384+
| (TagType::Hardware, TagType::Hardware)
383385
| (TagType::Manual, TagType::Manual) => Ordering::Equal,
384386
(TagType::Manual, _) => Ordering::Less,
385387
(TagType::HostName, _) => Ordering::Less,
388+
(TagType::Hardware, _) => Ordering::Less,
386389
(TagType::Alloc, _) => Ordering::Greater,
387390
})
388391
}

0 commit comments

Comments
 (0)