Skip to content

Commit 8ec37c7

Browse files
authored
[cuebot][FIX] Hardware tags update on Host restart (#2125)
## Problem When an RQD instance restarts with a different version, the version tag (`rqdv-X`) in CueCommander is not being updated. The tags remain stuck at the first registered version despite the RQD instance reporting the correct new version on startup. ## Root Cause There is no mechanism to update host tags when an existing RQD instance reconnects with different version information. Tags are only set during initial host creation and remain static afterwards. ## Solution - New `updateHostTags` method to handle tag updates on host reconnection - Method removes existing RQD-related tags and replaces them with current values from the host report - Use `HostTagType.HARDWARE` for RQD tags to distinguish them from user-added manual tags Note: HostTagType.HARDWARE seemed unused. I don't know if a different usage was planned for it. It seems a good contender to segregate easily tags added at creation from _manual_ tags added by the user later. ## Testing Update related unit tests to reflect the new tag ordering after the type classification change. Add coverage to ensure manual tags are left untouched.
1 parent 71ef981 commit 8ec37c7

File tree

4 files changed

+91
-10
lines changed

4 files changed

+91
-10
lines changed

cuebot/src/main/java/com/imageworks/spcue/dispatcher/HostReportHandler.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ public void handleHostReport(HostReport report, boolean isBoot) {
206206
*/
207207
if (isBoot) {
208208
hostManager.setHostResources(host, report);
209+
210+
// Update host tags during boot to ensure they're current
211+
hostManager.updateHostTags(host, report.getHost());
209212
}
210213

211214
dispatchSupport.determineIdleCores(host, report.getHost().getLoad());

cuebot/src/main/java/com/imageworks/spcue/service/HostManager.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/*
32
* Copyright Contributors to the OpenCue Project
43
*
@@ -245,4 +244,12 @@ void setHostStatistics(HostInterface host, long totalMemory, long freeMemory, lo
245244
* @param report
246245
*/
247246
void setHostResources(DispatchHost host, HostReport report);
247+
248+
/**
249+
* Updates host tags during boot to ensure they're current.
250+
*
251+
* @param host DispatchHost
252+
* @param rhost RenderHost with updated tag information
253+
*/
254+
void updateHostTags(DispatchHost host, RenderHost rhost);
248255
}

cuebot/src/main/java/com/imageworks/spcue/service/HostManagerService.java

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/*
32
* Copyright Contributors to the OpenCue Project
43
*
@@ -172,12 +171,12 @@ public DispatchHost createHost(RenderHost rhost, AllocationEntity alloc) {
172171

173172
if (rhost.getTagsCount() > 0) {
174173
for (String tag : rhost.getTagsList()) {
175-
hostDao.tagHost(host, tag, HostTagType.MANUAL);
174+
hostDao.tagHost(host, tag, HostTagType.HARDWARE);
176175
}
177176
}
178177

179-
// Don't tag anything with hardware yet, we don't watch new procs
180-
// that report in to automatically start running frames.
178+
// RQD tags (version, platform) are tagged as HARDWARE type since they represent
179+
// technical characteristics of the host, not manual user assignments
181180

182181
hostDao.recalcuateTags(host.id);
183182
return host;
@@ -408,4 +407,26 @@ public SubscriptionDao getSubscriptionDao() {
408407
public void setSubscriptionDao(SubscriptionDao subscriptionDao) {
409408
this.subscriptionDao = subscriptionDao;
410409
}
410+
411+
@Override
412+
@Transactional(propagation = Propagation.REQUIRED)
413+
public void updateHostTags(DispatchHost host, RenderHost rhost) {
414+
// Remove existing hardware tags and re-add current tags from report
415+
hostDao.removeTagsByType(host, HostTagType.HARDWARE);
416+
417+
if (rhost.getTagsCount() > 0) {
418+
for (String tag : rhost.getTagsList()) {
419+
// Remove tag by name, regardless of type.
420+
// It avoids duplicates if the host was first registered with
421+
// an older version of Cuebot where those tags were of MANUAL type.
422+
hostDao.removeTag(host, tag);
423+
hostDao.tagHost(host, tag, HostTagType.HARDWARE);
424+
}
425+
}
426+
427+
hostDao.recalcuateTags(host.getHostId());
428+
429+
logger.info("Updated hardware tags for host {} with tags: {}", host.getName(),
430+
rhost.getTagsList());
431+
}
411432
}

cuebot/src/test/java/com/imageworks/spcue/test/dao/postgres/HostDaoTests.java

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/*
32
* Copyright Contributors to the OpenCue Project
43
*
@@ -471,7 +470,7 @@ public void testUpdateHostSetManualTags() {
471470

472471
String tag = jdbcTemplate.queryForObject("SELECT str_tags FROM host WHERE pk_host=?",
473472
String.class, host.id);
474-
assertEquals("unassigned beta 64bit frick jack linux", tag);
473+
assertEquals("unassigned 64bit linux beta frick jack", tag);
475474
}
476475

477476
@Test
@@ -493,18 +492,18 @@ public void testChangeTags() {
493492

494493
String tag = jdbcTemplate.queryForObject("SELECT str_tags FROM host WHERE pk_host=?",
495494
String.class, host.id);
496-
assertEquals("unassigned beta 64bit linux", tag);
495+
assertEquals("unassigned 64bit linux beta", tag);
497496

498497
hostDao.removeTag(host, "linux");
499498
hostDao.recalcuateTags(host.id);
500499

501-
assertEquals("unassigned beta 64bit", jdbcTemplate.queryForObject(
500+
assertEquals("unassigned 64bit beta", jdbcTemplate.queryForObject(
502501
"SELECT str_tags FROM host WHERE pk_host=?", String.class, host.id));
503502

504503
hostDao.tagHost(host, "32bit", HostTagType.MANUAL);
505504
hostDao.recalcuateTags(host.id);
506505

507-
assertEquals("unassigned beta 32bit 64bit", jdbcTemplate.queryForObject(
506+
assertEquals("unassigned 64bit beta 32bit", jdbcTemplate.queryForObject(
508507
"SELECT str_tags FROM host WHERE pk_host=?", String.class, host.id));
509508
}
510509

@@ -548,4 +547,55 @@ public void testIsNimby() {
548547
DispatchHost host = hostManager.createHost(buildRenderHost(TEST_HOST));
549548
assertFalse(hostDao.isNimbyHost(host));
550549
}
550+
551+
@Test
552+
@Transactional
553+
@Rollback(true)
554+
public void testUpdateHostTagsOnlyAffectsHardwareTags() {
555+
// Create initial host with default RQD tags (linux, 64bit)
556+
DispatchHost host = hostManager.createHost(buildRenderHost(TEST_HOST));
557+
558+
// Add some manual tags
559+
hostDao.tagHost(host, "manual_tag1", HostTagType.MANUAL);
560+
hostDao.tagHost(host, "manual_tag2", HostTagType.MANUAL);
561+
hostDao.recalcuateTags(host.id);
562+
563+
String initialTags = jdbcTemplate
564+
.queryForObject("SELECT str_tags FROM host WHERE pk_host=?", String.class, host.id);
565+
assertEquals("unassigned 64bit linux beta manual_tag1 manual_tag2", initialTags);
566+
567+
// Create updated RenderHost with different hardware tags
568+
RenderHost updatedRHost = buildRenderHost(TEST_HOST).toBuilder().clearTags()
569+
.addTags("rqdv-2").addTags("windows").build();
570+
hostManager.updateHostTags(host, updatedRHost);
571+
572+
// Check that hardware tags were updated but manual tags were preserved
573+
String updatedTags = jdbcTemplate
574+
.queryForObject("SELECT str_tags FROM host WHERE pk_host=?", String.class, host.id);
575+
assertEquals("unassigned rqdv-2 windows beta manual_tag1 manual_tag2", updatedTags);
576+
}
577+
578+
@Test
579+
@Transactional
580+
@Rollback(true)
581+
public void testUpdateHostTagsRemovesManualDuplicates() {
582+
// Create initial host with a manual tag that will become a hardware tag
583+
DispatchHost host = hostManager.createHost(buildRenderHost(TEST_HOST));
584+
hostDao.tagHost(host, "foo", HostTagType.MANUAL);
585+
hostDao.recalcuateTags(host.id);
586+
587+
String initialTags = jdbcTemplate
588+
.queryForObject("SELECT str_tags FROM host WHERE pk_host=?", String.class, host.id);
589+
assertEquals("unassigned 64bit linux beta foo", initialTags);
590+
591+
// Update hardware tags to include "foo"
592+
RenderHost updatedRHost = buildRenderHost(TEST_HOST).toBuilder().clearTags().addTags("foo")
593+
.addTags("linux").build();
594+
hostManager.updateHostTags(host, updatedRHost);
595+
596+
// Ensure "foo" appears only once and as a hardware tag
597+
String updatedTags = jdbcTemplate
598+
.queryForObject("SELECT str_tags FROM host WHERE pk_host=?", String.class, host.id);
599+
assertEquals("unassigned foo linux beta", updatedTags);
600+
}
551601
}

0 commit comments

Comments
 (0)