From 3128e417b4dec297e5cef3fff658349989ffbea3 Mon Sep 17 00:00:00 2001 From: abrand Date: Fri, 19 Dec 2025 23:58:57 -0500 Subject: [PATCH 1/5] implement updateHostTags used on isBoot --- .../spcue/dispatcher/HostReportHandler.java | 3 +++ .../imageworks/spcue/service/HostManager.java | 9 ++++++- .../spcue/service/HostManagerService.java | 26 ++++++++++++++++--- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/cuebot/src/main/java/com/imageworks/spcue/dispatcher/HostReportHandler.java b/cuebot/src/main/java/com/imageworks/spcue/dispatcher/HostReportHandler.java index 7bd73ef3d..cb9618db7 100644 --- a/cuebot/src/main/java/com/imageworks/spcue/dispatcher/HostReportHandler.java +++ b/cuebot/src/main/java/com/imageworks/spcue/dispatcher/HostReportHandler.java @@ -206,6 +206,9 @@ public void handleHostReport(HostReport report, boolean isBoot) { */ if (isBoot) { hostManager.setHostResources(host, report); + + // Update host tags during boot to ensure they're current + hostManager.updateHostTags(host, report.getHost()); } dispatchSupport.determineIdleCores(host, report.getHost().getLoad()); diff --git a/cuebot/src/main/java/com/imageworks/spcue/service/HostManager.java b/cuebot/src/main/java/com/imageworks/spcue/service/HostManager.java index 76d5282b2..5913a7861 100644 --- a/cuebot/src/main/java/com/imageworks/spcue/service/HostManager.java +++ b/cuebot/src/main/java/com/imageworks/spcue/service/HostManager.java @@ -1,4 +1,3 @@ - /* * Copyright Contributors to the OpenCue Project * @@ -245,4 +244,12 @@ void setHostStatistics(HostInterface host, long totalMemory, long freeMemory, lo * @param report */ void setHostResources(DispatchHost host, HostReport report); + + /** + * Updates host tags during boot to ensure they're current. + * + * @param host DispatchHost + * @param rhost RenderHost with updated tag information + */ + void updateHostTags(DispatchHost host, RenderHost rhost); } diff --git a/cuebot/src/main/java/com/imageworks/spcue/service/HostManagerService.java b/cuebot/src/main/java/com/imageworks/spcue/service/HostManagerService.java index 1432f7169..5bb341bdc 100644 --- a/cuebot/src/main/java/com/imageworks/spcue/service/HostManagerService.java +++ b/cuebot/src/main/java/com/imageworks/spcue/service/HostManagerService.java @@ -1,4 +1,3 @@ - /* * Copyright Contributors to the OpenCue Project * @@ -172,12 +171,12 @@ public DispatchHost createHost(RenderHost rhost, AllocationEntity alloc) { if (rhost.getTagsCount() > 0) { for (String tag : rhost.getTagsList()) { - hostDao.tagHost(host, tag, HostTagType.MANUAL); + hostDao.tagHost(host, tag, HostTagType.HARDWARE); } } - // Don't tag anything with hardware yet, we don't watch new procs - // that report in to automatically start running frames. + // RQD tags (version, platform) are tagged as HARDWARE type since they represent + // technical characteristics of the host, not manual user assignments hostDao.recalcuateTags(host.id); return host; @@ -408,4 +407,23 @@ public SubscriptionDao getSubscriptionDao() { public void setSubscriptionDao(SubscriptionDao subscriptionDao) { this.subscriptionDao = subscriptionDao; } + + @Override + @Transactional(propagation = Propagation.REQUIRED) + public void updateHostTags(DispatchHost host, RenderHost rhost) { + // Remove existing hardware tags and re-add current tags from report + // This ensures platform/version tags are always up-to-date with what RQD is reporting + hostDao.removeTagsByType(host, HostTagType.HARDWARE); + + if (rhost.getTagsCount() > 0) { + for (String tag : rhost.getTagsList()) { + hostDao.tagHost(host, tag, HostTagType.HARDWARE); + } + } + + hostDao.recalcuateTags(host.getHostId()); + + logger.info("Updated hardware tags for host {} with tags: {}", host.getName(), + rhost.getTagsList()); + } } From 9ab16629dc24df4dd02bb4837a5ec7a5ca186c81 Mon Sep 17 00:00:00 2001 From: abrand Date: Sat, 20 Dec 2025 00:13:34 -0500 Subject: [PATCH 2/5] fix tests --- .../imageworks/spcue/test/dao/postgres/HostDaoTests.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cuebot/src/test/java/com/imageworks/spcue/test/dao/postgres/HostDaoTests.java b/cuebot/src/test/java/com/imageworks/spcue/test/dao/postgres/HostDaoTests.java index 77f0b2799..4fd7001ee 100644 --- a/cuebot/src/test/java/com/imageworks/spcue/test/dao/postgres/HostDaoTests.java +++ b/cuebot/src/test/java/com/imageworks/spcue/test/dao/postgres/HostDaoTests.java @@ -471,7 +471,7 @@ public void testUpdateHostSetManualTags() { String tag = jdbcTemplate.queryForObject("SELECT str_tags FROM host WHERE pk_host=?", String.class, host.id); - assertEquals("unassigned beta 64bit frick jack linux", tag); + assertEquals("unassigned 64bit linux beta frick jack", tag); } @Test @@ -493,18 +493,18 @@ public void testChangeTags() { String tag = jdbcTemplate.queryForObject("SELECT str_tags FROM host WHERE pk_host=?", String.class, host.id); - assertEquals("unassigned beta 64bit linux", tag); + assertEquals("unassigned 64bit linux beta", tag); hostDao.removeTag(host, "linux"); hostDao.recalcuateTags(host.id); - assertEquals("unassigned beta 64bit", jdbcTemplate.queryForObject( + assertEquals("unassigned 64bit beta", jdbcTemplate.queryForObject( "SELECT str_tags FROM host WHERE pk_host=?", String.class, host.id)); hostDao.tagHost(host, "32bit", HostTagType.MANUAL); hostDao.recalcuateTags(host.id); - assertEquals("unassigned beta 32bit 64bit", jdbcTemplate.queryForObject( + assertEquals("unassigned 64bit beta 32bit", jdbcTemplate.queryForObject( "SELECT str_tags FROM host WHERE pk_host=?", String.class, host.id)); } From 9fbebd6617816aa573b3b3d81de93a3bb97af6a1 Mon Sep 17 00:00:00 2001 From: abrand Date: Sat, 20 Dec 2025 01:06:39 -0500 Subject: [PATCH 3/5] add tests --- .../spcue/test/dao/postgres/HostDaoTests.java | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/cuebot/src/test/java/com/imageworks/spcue/test/dao/postgres/HostDaoTests.java b/cuebot/src/test/java/com/imageworks/spcue/test/dao/postgres/HostDaoTests.java index 4fd7001ee..5455cdd82 100644 --- a/cuebot/src/test/java/com/imageworks/spcue/test/dao/postgres/HostDaoTests.java +++ b/cuebot/src/test/java/com/imageworks/spcue/test/dao/postgres/HostDaoTests.java @@ -1,4 +1,3 @@ - /* * Copyright Contributors to the OpenCue Project * @@ -548,4 +547,35 @@ public void testIsNimby() { DispatchHost host = hostManager.createHost(buildRenderHost(TEST_HOST)); assertFalse(hostDao.isNimbyHost(host)); } + + @Test + @Transactional + @Rollback(true) + public void testUpdateHostTagsOnlyAffectsHardwareTags() { + // Create initial host with default RQD tags (linux, 64bit) + DispatchHost host = hostManager.createHost(buildRenderHost(TEST_HOST)); + + // Add some manual tags + hostDao.tagHost(host, "manual_tag1", HostTagType.MANUAL); + hostDao.tagHost(host, "manual_tag2", HostTagType.MANUAL); + hostDao.recalcuateTags(host.id); + + String initialTags = jdbcTemplate + .queryForObject("SELECT str_tags FROM host WHERE pk_host=?", String.class, host.id); + assertEquals("unassigned 64bit linux beta manual_tag1 manual_tag2", initialTags); + + // Create updated RenderHost with different hardware tags + RenderHost updatedRHost = buildRenderHost(TEST_HOST).toBuilder().clearTags() + .addTags("rqdv-2").addTags("windows").build(); + + // Update host tags using the new method + hostManager.updateHostTags(host, updatedRHost); + + // Check that hardware tags were updated but manual tags were preserved + String updatedTags = jdbcTemplate + .queryForObject("SELECT str_tags FROM host WHERE pk_host=?", String.class, host.id); + + // Verify all expected tags are present + assertEquals("unassigned rqdv-2 windows beta manual_tag1 manual_tag2", updatedTags); + } } From 9f92c35d18498a3c549e1e902442d7de7ce283af Mon Sep 17 00:00:00 2001 From: abrand Date: Sat, 20 Dec 2025 02:46:25 -0500 Subject: [PATCH 4/5] cleanup redundant comments --- .../com/imageworks/spcue/test/dao/postgres/HostDaoTests.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cuebot/src/test/java/com/imageworks/spcue/test/dao/postgres/HostDaoTests.java b/cuebot/src/test/java/com/imageworks/spcue/test/dao/postgres/HostDaoTests.java index 5455cdd82..1afbae912 100644 --- a/cuebot/src/test/java/com/imageworks/spcue/test/dao/postgres/HostDaoTests.java +++ b/cuebot/src/test/java/com/imageworks/spcue/test/dao/postgres/HostDaoTests.java @@ -567,15 +567,11 @@ public void testUpdateHostTagsOnlyAffectsHardwareTags() { // Create updated RenderHost with different hardware tags RenderHost updatedRHost = buildRenderHost(TEST_HOST).toBuilder().clearTags() .addTags("rqdv-2").addTags("windows").build(); - - // Update host tags using the new method hostManager.updateHostTags(host, updatedRHost); // Check that hardware tags were updated but manual tags were preserved String updatedTags = jdbcTemplate .queryForObject("SELECT str_tags FROM host WHERE pk_host=?", String.class, host.id); - - // Verify all expected tags are present assertEquals("unassigned rqdv-2 windows beta manual_tag1 manual_tag2", updatedTags); } } From 4e0c655556515319de1209aa5c5421e010aba891 Mon Sep 17 00:00:00 2001 From: abrand Date: Mon, 5 Jan 2026 16:00:13 -0500 Subject: [PATCH 5/5] prevent duplicated tags by removing old manual type tags now hardware --- .../spcue/service/HostManagerService.java | 5 +++- .../spcue/test/dao/postgres/HostDaoTests.java | 24 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/cuebot/src/main/java/com/imageworks/spcue/service/HostManagerService.java b/cuebot/src/main/java/com/imageworks/spcue/service/HostManagerService.java index 5bb341bdc..e7cee2248 100644 --- a/cuebot/src/main/java/com/imageworks/spcue/service/HostManagerService.java +++ b/cuebot/src/main/java/com/imageworks/spcue/service/HostManagerService.java @@ -412,11 +412,14 @@ public void setSubscriptionDao(SubscriptionDao subscriptionDao) { @Transactional(propagation = Propagation.REQUIRED) public void updateHostTags(DispatchHost host, RenderHost rhost) { // Remove existing hardware tags and re-add current tags from report - // This ensures platform/version tags are always up-to-date with what RQD is reporting hostDao.removeTagsByType(host, HostTagType.HARDWARE); if (rhost.getTagsCount() > 0) { for (String tag : rhost.getTagsList()) { + // Remove tag by name, regardless of type. + // It avoids duplicates if the host was first registered with + // an older version of Cuebot where those tags were of MANUAL type. + hostDao.removeTag(host, tag); hostDao.tagHost(host, tag, HostTagType.HARDWARE); } } diff --git a/cuebot/src/test/java/com/imageworks/spcue/test/dao/postgres/HostDaoTests.java b/cuebot/src/test/java/com/imageworks/spcue/test/dao/postgres/HostDaoTests.java index 1afbae912..796617fdc 100644 --- a/cuebot/src/test/java/com/imageworks/spcue/test/dao/postgres/HostDaoTests.java +++ b/cuebot/src/test/java/com/imageworks/spcue/test/dao/postgres/HostDaoTests.java @@ -574,4 +574,28 @@ public void testUpdateHostTagsOnlyAffectsHardwareTags() { .queryForObject("SELECT str_tags FROM host WHERE pk_host=?", String.class, host.id); assertEquals("unassigned rqdv-2 windows beta manual_tag1 manual_tag2", updatedTags); } + + @Test + @Transactional + @Rollback(true) + public void testUpdateHostTagsRemovesManualDuplicates() { + // Create initial host with a manual tag that will become a hardware tag + DispatchHost host = hostManager.createHost(buildRenderHost(TEST_HOST)); + hostDao.tagHost(host, "foo", HostTagType.MANUAL); + hostDao.recalcuateTags(host.id); + + String initialTags = jdbcTemplate + .queryForObject("SELECT str_tags FROM host WHERE pk_host=?", String.class, host.id); + assertEquals("unassigned 64bit linux beta foo", initialTags); + + // Update hardware tags to include "foo" + RenderHost updatedRHost = buildRenderHost(TEST_HOST).toBuilder().clearTags().addTags("foo") + .addTags("linux").build(); + hostManager.updateHostTags(host, updatedRHost); + + // Ensure "foo" appears only once and as a hardware tag + String updatedTags = jdbcTemplate + .queryForObject("SELECT str_tags FROM host WHERE pk_host=?", String.class, host.id); + assertEquals("unassigned foo linux beta", updatedTags); + } }