Browse Source

Merge branch 'lts-4.4' into fix/system-patch-after-startup-lts-4.4

pull/16643/head
Kostenko Roman 3 weeks ago
committed by GitHub
parent
commit
2abe584ee0
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 9
      application/src/main/java/org/thingsboard/server/service/edge/EdgeEntityTenantChecker.java
  2. 17
      application/src/main/java/org/thingsboard/server/service/queue/DefaultTbClusterService.java
  3. 45
      application/src/test/java/org/thingsboard/server/edge/TelemetryEdgeTest.java
  4. 24
      application/src/test/java/org/thingsboard/server/queue/discovery/HashPartitionServiceTest.java
  5. 45
      application/src/test/java/org/thingsboard/server/service/queue/DefaultTbClusterServiceTest.java
  6. 30
      common/integration/cluster-integration-api/src/main/java/org/thingsboard/server/service/integration/DefaultClusterIntegrationService.java
  7. 95
      common/integration/cluster-integration-api/src/test/java/org/thingsboard/server/service/integration/DefaultClusterIntegrationServiceTest.java
  8. 2
      common/proto/src/main/proto/integration.proto
  9. 5
      common/queue/src/main/java/org/thingsboard/server/queue/discovery/HashPartitionService.java
  10. 3
      common/queue/src/main/java/org/thingsboard/server/queue/discovery/PartitionService.java
  11. 19
      dao/src/main/java/org/thingsboard/server/dao/pat/ApiKeyServiceImpl.java
  12. 68
      dao/src/test/java/org/thingsboard/server/dao/pat/ApiKeyCacheEvictionTest.java
  13. 53
      dao/src/test/java/org/thingsboard/server/dao/service/ApiKeyServiceTest.java
  14. 8
      transport/coap/src/main/resources/tb-coap-transport.yml
  15. 8
      transport/http/src/main/resources/tb-http-transport.yml
  16. 8
      transport/lwm2m/src/main/resources/tb-lwm2m-transport.yml
  17. 8
      transport/mqtt/src/main/resources/tb-mqtt-transport.yml
  18. 8
      transport/snmp/src/main/resources/tb-snmp-transport.yml
  19. 2
      ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-installed-items-table.component.html

9
application/src/main/java/org/thingsboard/server/service/edge/EdgeEntityTenantChecker.java

@ -5,6 +5,7 @@ package org.thingsboard.server.service.edge;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.thingsboard.server.common.data.HasOwnerId;
import org.thingsboard.server.common.data.HasTenantId;
import org.thingsboard.server.common.data.id.EntityId;
import org.thingsboard.server.common.data.id.TenantId;
@ -35,7 +36,13 @@ public class EdgeEntityTenantChecker {
}
try {
return entityService.fetchEntity(tenantId, entityId)
.map(entity -> entity instanceof HasTenantId hasTenantId && tenantId.equals(hasTenantId.getTenantId()))
.map(entity -> {
if (entity instanceof HasTenantId hasTenantId) {
return tenantId.equals(hasTenantId.getTenantId());
}
// entities without own tenant id (entity groups) belong to the tenant of their owner
return entity instanceof HasOwnerId hasOwnerId && isTenantEntity(tenantId, hasOwnerId.getOwnerId());
})
.orElse(false);
} catch (IllegalArgumentException e) {
log.warn("[{}] Unsupported entity type of {}", tenantId, entityId);

17
application/src/main/java/org/thingsboard/server/service/queue/DefaultTbClusterService.java

@ -1189,7 +1189,8 @@ public class DefaultTbClusterService implements TbClusterService {
ToRuleEngineNotificationMsg ruleEngineMsg = ToRuleEngineNotificationMsg.newBuilder().addAllQueueUpdateMsgs(queueUpdateMsgs).build();
ToCoreNotificationMsg coreMsg = ToCoreNotificationMsg.newBuilder().addAllQueueUpdateMsgs(queueUpdateMsgs).build();
ToTransportMsg transportMsg = ToTransportMsg.newBuilder().addAllQueueUpdateMsgs(queueUpdateMsgs).build();
doSendQueueNotifications(ruleEngineMsg, coreMsg, transportMsg);
ToIntegrationExecutorNotificationMsg integrationExecutorMsg = ToIntegrationExecutorNotificationMsg.newBuilder().addAllQueueUpdateMsgs(queueUpdateMsgs).build();
doSendQueueNotifications(ruleEngineMsg, coreMsg, transportMsg, integrationExecutorMsg);
}
@Override
@ -1207,15 +1208,20 @@ public class DefaultTbClusterService implements TbClusterService {
ToRuleEngineNotificationMsg ruleEngineMsg = ToRuleEngineNotificationMsg.newBuilder().addAllQueueDeleteMsgs(queueDeleteMsgs).build();
ToCoreNotificationMsg coreMsg = ToCoreNotificationMsg.newBuilder().addAllQueueDeleteMsgs(queueDeleteMsgs).build();
ToTransportMsg transportMsg = ToTransportMsg.newBuilder().addAllQueueDeleteMsgs(queueDeleteMsgs).build();
doSendQueueNotifications(ruleEngineMsg, coreMsg, transportMsg);
ToIntegrationExecutorNotificationMsg integrationExecutorMsg = ToIntegrationExecutorNotificationMsg.newBuilder().addAllQueueDeleteMsgs(queueDeleteMsgs).build();
doSendQueueNotifications(ruleEngineMsg, coreMsg, transportMsg, integrationExecutorMsg);
}
private void doSendQueueNotifications(ToRuleEngineNotificationMsg ruleEngineMsg, ToCoreNotificationMsg coreMsg, ToTransportMsg transportMsg) {
private void doSendQueueNotifications(ToRuleEngineNotificationMsg ruleEngineMsg, ToCoreNotificationMsg coreMsg, ToTransportMsg transportMsg,
ToIntegrationExecutorNotificationMsg integrationExecutorMsg) {
Set<String> tbRuleEngineServices = partitionService.getAllServiceIds(ServiceType.TB_RULE_ENGINE);
Set<String> tbCoreServices = partitionService.getAllServiceIds(ServiceType.TB_CORE);
Set<String> tbTransportServices = partitionService.getAllServiceIds(ServiceType.TB_TRANSPORT);
Set<String> tbIntegrationExecutorServices = partitionService.getAllServiceIds(ServiceType.TB_INTEGRATION_EXECUTOR);
// No need to push notifications twice
tbTransportServices.removeAll(tbCoreServices);
tbIntegrationExecutorServices.removeAll(tbCoreServices);
tbIntegrationExecutorServices.removeAll(tbRuleEngineServices);
tbCoreServices.removeAll(tbRuleEngineServices);
for (String ruleEngineServiceId : tbRuleEngineServices) {
@ -1233,6 +1239,11 @@ public class DefaultTbClusterService implements TbClusterService {
producerProvider.getTransportNotificationsMsgProducer().send(tpi, new TbProtoQueueMsg<>(UUID.randomUUID(), transportMsg), null);
toTransportNfs.incrementAndGet();
}
for (String integrationExecutorServiceId : tbIntegrationExecutorServices) {
TopicPartitionInfo tpi = topicService.getNotificationsTopic(ServiceType.TB_INTEGRATION_EXECUTOR, integrationExecutorServiceId);
producerProvider.getTbIntegrationExecutorNotificationsMsgProducer().send(tpi, new TbProtoQueueMsg<>(UUID.randomUUID(), integrationExecutorMsg), null);
toIntegrationExecutorNfs.incrementAndGet();
}
}
}

45
application/src/test/java/org/thingsboard/server/edge/TelemetryEdgeTest.java

@ -13,11 +13,13 @@ import org.junit.Test;
import org.thingsboard.common.util.JacksonUtil;
import org.thingsboard.server.common.data.DataConstants;
import org.thingsboard.server.common.data.Device;
import org.thingsboard.server.common.data.EntityType;
import org.thingsboard.server.common.data.StringUtils;
import org.thingsboard.server.common.data.asset.Asset;
import org.thingsboard.server.common.data.edge.EdgeEvent;
import org.thingsboard.server.common.data.edge.EdgeEventActionType;
import org.thingsboard.server.common.data.edge.EdgeEventType;
import org.thingsboard.server.common.data.group.EntityGroup;
import org.thingsboard.server.common.data.id.EntityId;
import org.thingsboard.server.dao.service.DaoSqlTest;
import org.thingsboard.server.gen.edge.v1.AttributeDeleteMsg;
@ -345,4 +347,47 @@ public class TelemetryEdgeTest extends AbstractEdgeTest {
});
}
@Test
public void testSendEntityGroupAttributesAndTelemetryToCloud() throws Exception {
EntityGroup entityGroup = createEntityGroupAndAssignToEdge(EntityType.DEVICE, "TelemetryDeviceGroup", tenantId);
long ts = System.currentTimeMillis();
EntityDataProto entityData = EntityDataProto.newBuilder()
.setEntityIdMSB(entityGroup.getUuidId().getMostSignificantBits())
.setEntityIdLSB(entityGroup.getUuidId().getLeastSignificantBits())
.setEntityType(entityGroup.getId().getEntityType().name())
.setAttributesUpdatedMsg(TransportProtos.PostAttributeMsg.newBuilder()
.addKv(TransportProtos.KeyValueProto.newBuilder()
.setKey("groupKey")
.setType(TransportProtos.KeyValueType.STRING_V)
.setStringV("groupValue").build())
.build())
.setPostAttributeScope(DataConstants.SERVER_SCOPE)
.setPostTelemetryMsg(TransportProtos.PostTelemetryMsg.newBuilder()
.addTsKvList(TransportProtos.TsKvListProto.newBuilder()
.setTs(ts)
.addKv(TransportProtos.KeyValueProto.newBuilder()
.setKey("groupTemperature")
.setType(TransportProtos.KeyValueType.LONG_V)
.setLongV(25).build())
.build())
.build())
.build();
sendUplinkMsgAndWaitForResponse(uplinkMsgBuilder -> uplinkMsgBuilder.addEntityData(entityData));
String valuesUrl = "/api/plugins/telemetry/ENTITY_GROUP/" + entityGroup.getUuidId() + "/values/";
Awaitility.await()
.atMost(TIMEOUT, TimeUnit.SECONDS)
.untilAsserted(() -> {
JsonNode attributes = doGetAsync(valuesUrl + "attributes/" + DataConstants.SERVER_SCOPE, JsonNode.class);
Assert.assertEquals(1, attributes.size());
Assert.assertEquals("groupKey", attributes.get(0).get("key").asText());
Assert.assertEquals("groupValue", attributes.get(0).get("value").asText());
JsonNode timeseries = doGetAsync(valuesUrl + "timeseries?keys=groupTemperature", JsonNode.class);
Assert.assertEquals(1, timeseries.get("groupTemperature").size());
Assert.assertEquals(ts, timeseries.get("groupTemperature").get(0).get("ts").asLong());
Assert.assertEquals("25", timeseries.get("groupTemperature").get(0).get("value").asText());
});
}
}

24
application/src/test/java/org/thingsboard/server/queue/discovery/HashPartitionServiceTest.java

@ -459,6 +459,30 @@ public class HashPartitionServiceTest {
Set.of(tenantId).equals(event.getAffectedTenants()));
}
@Test
public void testEvictTenantProfileInfo_reResolvesIsolationOnlyForTenantsOfThatProfile() {
TenantProfileId isolatedProfileId = new TenantProfileId(UUID.randomUUID());
TenantProfileId otherProfileId = new TenantProfileId(UUID.randomUUID());
TenantId tenantId = TenantId.fromUUID(UUID.randomUUID());
TenantId otherTenantId = TenantId.fromUUID(UUID.randomUUID());
mockQueues(List.of(createQueue(TenantId.SYS_TENANT_ID, 10), createQueue(tenantId, 3), createQueue(otherTenantId, 3)));
mockRoutingInfo(tenantId, isolatedProfileId, false);
mockRoutingInfo(otherTenantId, otherProfileId, false);
HashPartitionService partitionService = createPartitionService();
DeviceId deviceId = new DeviceId(UUID.randomUUID());
// routing info is cached as "not isolated"
assertThat(partitionService.resolve(ServiceType.TB_RULE_ENGINE, tenantId, deviceId).getFullTopicName()).doesNotContain(".isolated.");
assertThat(partitionService.resolve(ServiceType.TB_RULE_ENGINE, otherTenantId, deviceId).getFullTopicName()).doesNotContain(".isolated.");
mockRoutingInfo(tenantId, isolatedProfileId, true);
mockRoutingInfo(otherTenantId, otherProfileId, true);
partitionService.evictTenantProfileInfo(isolatedProfileId);
assertThat(partitionService.resolve(ServiceType.TB_RULE_ENGINE, tenantId, deviceId).getFullTopicName()).contains(".isolated." + tenantId.getId());
assertThat(partitionService.resolve(ServiceType.TB_RULE_ENGINE, otherTenantId, deviceId).getFullTopicName()).doesNotContain(".isolated.");
}
@Test
public void testPartitionsDistribution_sameTenantDifferentQueues() {
List<ServiceInfo> ruleEngines = new ArrayList<>();

45
application/src/test/java/org/thingsboard/server/service/queue/DefaultTbClusterServiceTest.java

@ -51,6 +51,7 @@ import org.thingsboard.server.dao.cf.CalculatedFieldService;
import org.thingsboard.server.dao.edge.EdgeService;
import org.thingsboard.server.dao.group.EntityGroupService;
import org.thingsboard.server.dao.ota.OtaPackageStateService;
import org.thingsboard.server.gen.integration.ToIntegrationExecutorNotificationMsg;
import org.thingsboard.server.gen.transport.TransportProtos;
import org.thingsboard.server.queue.TbQueueCallback;
import org.thingsboard.server.queue.TbQueueProducer;
@ -299,6 +300,50 @@ public class DefaultTbClusterServiceTest {
.send(eq(topicService.getNotificationsTopic(ServiceType.TB_TRANSPORT, monolith2)), any(TbProtoQueueMsg.class), isNull());
}
@Test
public void testOnQueuesUpdateIsSentToIntegrationExecutors() {
TbQueueProducer<TbProtoQueueMsg<ToIntegrationExecutorNotificationMsg>> tbIeQueueProducer = mockQueueNotificationTargetsWithIntegrationExecutors();
clusterService.onQueuesUpdate(List.of(createTestQueue()));
ArgumentCaptor<TbProtoQueueMsg<ToIntegrationExecutorNotificationMsg>> msgCaptor = ArgumentCaptor.forClass(TbProtoQueueMsg.class);
verify(tbIeQueueProducer).send(eq(topicService.getNotificationsTopic(ServiceType.TB_INTEGRATION_EXECUTOR, "ie1")), msgCaptor.capture(), isNull());
verifyNoMoreInteractions(tbIeQueueProducer);
ToIntegrationExecutorNotificationMsg ieMsg = msgCaptor.getValue().getValue();
assertThat(ieMsg.getQueueUpdateMsgsCount()).isEqualTo(1);
assertThat(ieMsg.getQueueUpdateMsgs(0).getQueueName()).isEqualTo(DataConstants.MAIN_QUEUE_NAME);
assertThat(ieMsg.hasComponentLifecycle()).isFalse();
}
@Test
public void testOnQueuesDeleteIsSentToIntegrationExecutors() {
TbQueueProducer<TbProtoQueueMsg<ToIntegrationExecutorNotificationMsg>> tbIeQueueProducer = mockQueueNotificationTargetsWithIntegrationExecutors();
clusterService.onQueuesDelete(List.of(createTestQueue()));
ArgumentCaptor<TbProtoQueueMsg<ToIntegrationExecutorNotificationMsg>> msgCaptor = ArgumentCaptor.forClass(TbProtoQueueMsg.class);
verify(tbIeQueueProducer).send(eq(topicService.getNotificationsTopic(ServiceType.TB_INTEGRATION_EXECUTOR, "ie1")), msgCaptor.capture(), isNull());
verifyNoMoreInteractions(tbIeQueueProducer);
ToIntegrationExecutorNotificationMsg ieMsg = msgCaptor.getValue().getValue();
assertThat(ieMsg.getQueueDeleteMsgsCount()).isEqualTo(1);
assertThat(ieMsg.getQueueDeleteMsgs(0).getQueueName()).isEqualTo(DataConstants.MAIN_QUEUE_NAME);
assertThat(ieMsg.hasComponentLifecycle()).isFalse();
}
// The monolith and the core run an integration executor too, but already apply queue updates from their own notifications
private TbQueueProducer<TbProtoQueueMsg<ToIntegrationExecutorNotificationMsg>> mockQueueNotificationTargetsWithIntegrationExecutors() {
when(partitionService.getAllServiceIds(ServiceType.TB_RULE_ENGINE)).thenReturn(Sets.newHashSet(MONOLITH, RULE_ENGINE));
when(partitionService.getAllServiceIds(ServiceType.TB_CORE)).thenReturn(Sets.newHashSet(MONOLITH, CORE));
when(partitionService.getAllServiceIds(ServiceType.TB_TRANSPORT)).thenReturn(Sets.newHashSet(MONOLITH));
when(partitionService.getAllServiceIds(ServiceType.TB_INTEGRATION_EXECUTOR)).thenReturn(Sets.newHashSet(MONOLITH, CORE, "ie1"));
when(producerProvider.getRuleEngineNotificationsMsgProducer()).thenReturn(mock(TbQueueProducer.class));
when(producerProvider.getTbCoreNotificationsMsgProducer()).thenReturn(mock(TbQueueProducer.class));
TbQueueProducer<TbProtoQueueMsg<ToIntegrationExecutorNotificationMsg>> tbIeQueueProducer = mock(TbQueueProducer.class);
when(producerProvider.getTbIntegrationExecutorNotificationsMsgProducer()).thenReturn(tbIeQueueProducer);
return tbIeQueueProducer;
}
@Test
public void testPushNotificationToCoreWithRestApiCallResponseMsgProto() {
TopicPartitionInfo tpi = mock(TopicPartitionInfo.class);

30
common/integration/cluster-integration-api/src/main/java/org/thingsboard/server/service/integration/DefaultClusterIntegrationService.java

@ -12,6 +12,9 @@ import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.stereotype.Service;
import org.thingsboard.common.util.ThingsBoardExecutors;
import org.thingsboard.common.util.ThingsBoardThreadFactory;
import org.thingsboard.server.common.data.id.EntityId;
import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.id.TenantProfileId;
import org.thingsboard.server.common.data.integration.IntegrationType;
import org.thingsboard.server.common.msg.TbActorMsg;
import org.thingsboard.server.common.msg.plugin.ComponentLifecycleMsg;
@ -23,6 +26,7 @@ import org.thingsboard.server.gen.integration.ToIntegrationExecutorDownlinkMsg;
import org.thingsboard.server.gen.integration.ToIntegrationExecutorNotificationMsg;
import org.thingsboard.server.queue.TbQueueConsumer;
import org.thingsboard.server.queue.common.TbProtoQueueMsg;
import org.thingsboard.server.queue.discovery.PartitionService;
import org.thingsboard.server.queue.discovery.QueueKey;
import org.thingsboard.server.queue.discovery.TbApplicationEventListener;
import org.thingsboard.server.queue.discovery.TbServiceInfoProvider;
@ -60,6 +64,7 @@ public class DefaultClusterIntegrationService extends TbApplicationEventListener
private final TbQueueIntegrationExecutorSettings integrationNotificationSettings;
private final TbCoreIntegrationExecutorQueueFactory queueFactory;
private final IntegrationManagerService integrationManagerService;
private final PartitionService partitionService;
@Autowired(required = false)
private IntegrationExecutorCacheStartupService cacheStartupService;
@ -69,11 +74,13 @@ public class DefaultClusterIntegrationService extends TbApplicationEventListener
public DefaultClusterIntegrationService(TbServiceInfoProvider serviceInfoProvider,
TbQueueIntegrationExecutorSettings integrationNotificationSettings,
TbCoreIntegrationExecutorQueueFactory queueFactory,
IntegrationManagerService integrationManagerService) {
IntegrationManagerService integrationManagerService,
PartitionService partitionService) {
this.serviceInfoProvider = serviceInfoProvider;
this.integrationNotificationSettings = integrationNotificationSettings;
this.queueFactory = queueFactory;
this.integrationManagerService = integrationManagerService;
this.partitionService = partitionService;
}
private volatile ExecutorService consumersExecutor;
@ -335,9 +342,17 @@ public class DefaultClusterIntegrationService extends TbApplicationEventListener
}
}
private void handleNotification(UUID id, TbProtoQueueMsg<ToIntegrationExecutorNotificationMsg> msg, TbCallback callback) {
void handleNotification(UUID id, TbProtoQueueMsg<ToIntegrationExecutorNotificationMsg> msg, TbCallback callback) {
ToIntegrationExecutorNotificationMsg nf = msg.getValue();
handleComponentLifecycleMsg(id, ProtoUtils.fromProto(nf.getComponentLifecycle()));
if (nf.hasComponentLifecycle()) {
handleComponentLifecycleMsg(id, ProtoUtils.fromProto(nf.getComponentLifecycle()));
}
if (nf.getQueueUpdateMsgsCount() > 0) {
partitionService.updateQueues(nf.getQueueUpdateMsgsList());
}
if (nf.getQueueDeleteMsgsCount() > 0) {
partitionService.removeQueues(nf.getQueueDeleteMsgsList());
}
callback.onSuccess();
}
@ -347,10 +362,19 @@ public class DefaultClusterIntegrationService extends TbApplicationEventListener
componentLifecycleMsg.getEntityId().getEntityType(),
componentLifecycleMsg.getEntityId(), componentLifecycleMsg.getEvent());
integrationManagerService.handleComponentLifecycleMsg(componentLifecycleMsg);
// after the tenant profile caches are evicted, so that the routing info is re-read from the updated profile
evictTenantRoutingInfo(componentLifecycleMsg.getEntityId());
}
log.trace("[{}] Forwarding message to App Actor {}", id, actorMsg);
}
private void evictTenantRoutingInfo(EntityId entityId) {
switch (entityId.getEntityType()) {
case TENANT -> partitionService.evictTenantInfo(TenantId.fromUUID(entityId.getId()));
case TENANT_PROFILE -> partitionService.evictTenantProfileInfo(new TenantProfileId(entityId.getId()));
}
}
private void refreshIntegrationsByType(IntegrationType type) {
try {
Set<TopicPartitionInfo> partitions = getLatestPartitionsFromQueue(type);

95
common/integration/cluster-integration-api/src/test/java/org/thingsboard/server/service/integration/DefaultClusterIntegrationServiceTest.java

@ -12,13 +12,24 @@ import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.thingsboard.server.common.data.id.EntityId;
import org.thingsboard.server.common.data.id.IntegrationId;
import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.id.TenantProfileId;
import org.thingsboard.server.common.data.integration.IntegrationType;
import org.thingsboard.server.common.data.plugin.ComponentLifecycleEvent;
import org.thingsboard.server.common.msg.plugin.ComponentLifecycleMsg;
import org.thingsboard.server.common.msg.queue.ServiceType;
import org.thingsboard.server.common.msg.queue.TbCallback;
import org.thingsboard.server.common.msg.queue.TopicPartitionInfo;
import org.thingsboard.server.common.util.ProtoUtils;
import org.thingsboard.server.gen.integration.ToIntegrationExecutorDownlinkMsg;
import org.thingsboard.server.gen.integration.ToIntegrationExecutorNotificationMsg;
import org.thingsboard.server.gen.transport.TransportProtos.QueueDeleteMsg;
import org.thingsboard.server.gen.transport.TransportProtos.QueueUpdateMsg;
import org.thingsboard.server.queue.TbQueueConsumer;
import org.thingsboard.server.queue.common.TbProtoQueueMsg;
import org.thingsboard.server.queue.discovery.PartitionService;
import org.thingsboard.server.queue.discovery.QueueKey;
import org.thingsboard.server.queue.discovery.TbServiceInfoProvider;
import org.thingsboard.server.queue.discovery.event.PartitionChangeEvent;
@ -30,6 +41,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import static org.mockito.ArgumentMatchers.any;
@ -39,6 +51,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
@ -56,12 +69,18 @@ class DefaultClusterIntegrationServiceTest {
@Mock
private IntegrationManagerService integrationManagerService;
@Mock
private PartitionService partitionService;
@Mock
private TbCallback callback;
@Mock
private TbQueueConsumer<TbProtoQueueMsg<ToIntegrationExecutorDownlinkMsg>> mqttConsumer;
@Mock
private TbQueueConsumer<TbProtoQueueMsg<ToIntegrationExecutorDownlinkMsg>> httpConsumer;
private DefaultClusterIntegrationService service;
private final TenantId tenantId = TenantId.fromUUID(UUID.randomUUID());
@BeforeEach
@SuppressWarnings("unchecked")
void setUp() {
@ -70,7 +89,7 @@ class DefaultClusterIntegrationServiceTest {
.thenReturn(mock(TbQueueConsumer.class));
when(queueFactory.createToIntegrationExecutorDownlinkMsgConsumer(IntegrationType.MQTT)).thenReturn(mqttConsumer);
when(queueFactory.createToIntegrationExecutorDownlinkMsgConsumer(IntegrationType.HTTP)).thenReturn(httpConsumer);
service = new DefaultClusterIntegrationService(serviceInfoProvider, settings, queueFactory, integrationManagerService) {
service = new DefaultClusterIntegrationService(serviceInfoProvider, settings, queueFactory, integrationManagerService, partitionService) {
@Override
protected void launchMainConsumers() {
}
@ -146,6 +165,80 @@ class DefaultClusterIntegrationServiceTest {
verify(integrationManagerService, never()).refresh(IntegrationType.MQTT, tpis(0));
}
@Test
void givenQueueUpdateNotification_whenHandled_thenQueuesAreUpdatedInPartitionService() {
QueueUpdateMsg queueUpdateMsg = QueueUpdateMsg.newBuilder()
.setTenantIdMSB(tenantId.getId().getMostSignificantBits())
.setTenantIdLSB(tenantId.getId().getLeastSignificantBits())
.setQueueName("Main")
.setQueueTopic("tb_rule_engine.main")
.setPartitions(3)
.build();
handle(ToIntegrationExecutorNotificationMsg.newBuilder().addQueueUpdateMsgs(queueUpdateMsg).build());
verify(partitionService).updateQueues(List.of(queueUpdateMsg));
verify(integrationManagerService, never()).handleComponentLifecycleMsg(any());
verify(callback).onSuccess();
}
@Test
void givenQueueDeleteNotification_whenHandled_thenQueuesAreRemovedFromPartitionService() {
QueueDeleteMsg queueDeleteMsg = QueueDeleteMsg.newBuilder()
.setTenantIdMSB(tenantId.getId().getMostSignificantBits())
.setTenantIdLSB(tenantId.getId().getLeastSignificantBits())
.setQueueName("Main")
.build();
handle(ToIntegrationExecutorNotificationMsg.newBuilder().addQueueDeleteMsgs(queueDeleteMsg).build());
verify(partitionService).removeQueues(List.of(queueDeleteMsg));
verify(integrationManagerService, never()).handleComponentLifecycleMsg(any());
verify(callback).onSuccess();
}
@Test
void givenTenantUpdated_whenHandled_thenTenantRoutingInfoIsEvictedAfterTenantProfileCaches() {
handle(lifecycleNotification(tenantId, tenantId));
// the routing info is re-read from the tenant profile cache, so it must be evicted after that cache
InOrder inOrder = inOrder(integrationManagerService, partitionService);
inOrder.verify(integrationManagerService).handleComponentLifecycleMsg(any());
inOrder.verify(partitionService).evictTenantInfo(tenantId);
verify(callback).onSuccess();
}
@Test
void givenTenantProfileUpdated_whenHandled_thenRoutingInfoOfItsTenantsIsEvictedAfterTenantProfileCaches() {
TenantProfileId tenantProfileId = new TenantProfileId(UUID.randomUUID());
handle(lifecycleNotification(TenantId.SYS_TENANT_ID, tenantProfileId));
InOrder inOrder = inOrder(integrationManagerService, partitionService);
inOrder.verify(integrationManagerService).handleComponentLifecycleMsg(any());
inOrder.verify(partitionService).evictTenantProfileInfo(tenantProfileId);
verify(callback).onSuccess();
}
@Test
void givenIntegrationUpdated_whenHandled_thenRoutingInfoIsKept() {
handle(lifecycleNotification(tenantId, new IntegrationId(UUID.randomUUID())));
verify(integrationManagerService).handleComponentLifecycleMsg(any());
verifyNoInteractions(partitionService);
verify(callback).onSuccess();
}
private ToIntegrationExecutorNotificationMsg lifecycleNotification(TenantId tenantId, EntityId entityId) {
ComponentLifecycleMsg msg = new ComponentLifecycleMsg(tenantId, entityId, ComponentLifecycleEvent.UPDATED);
return ToIntegrationExecutorNotificationMsg.newBuilder().setComponentLifecycle(ProtoUtils.toProto(msg)).build();
}
private void handle(ToIntegrationExecutorNotificationMsg nf) {
UUID id = UUID.randomUUID();
service.handleNotification(id, new TbProtoQueueMsg<>(id, nf), callback);
}
private static PartitionChangeEvent partitionChangeEvent(Integer... partitions) {
return partitionChangeEvent(Map.of(IntegrationType.MQTT, tpis(partitions)));
}

2
common/proto/src/main/proto/integration.proto

@ -343,6 +343,8 @@ message IntegrationApiResponseMsg {
/* High priority messages with low latency are handled by ThingsBoard Integration Executor Service separately */
message ToIntegrationExecutorNotificationMsg {
transport.ComponentLifecycleMsgProto componentLifecycle = 1;
repeated transport.QueueUpdateMsg queueUpdateMsgs = 2;
repeated transport.QueueDeleteMsg queueDeleteMsgs = 3;
}
message IntegrationValidationRequestProto {

5
common/queue/src/main/java/org/thingsboard/server/queue/discovery/HashPartitionService.java

@ -616,6 +616,11 @@ public class HashPartitionService implements PartitionService {
tenantRoutingInfoMap.remove(tenantId);
}
@Override
public void evictTenantProfileInfo(TenantProfileId tenantProfileId) {
tenantRoutingInfoMap.values().removeIf(routingInfo -> tenantProfileId.equals(routingInfo.getProfileId()));
}
@Override
public int countTransportsByType(String type) {
var list = tbTransportServicesByType.get(type);

3
common/queue/src/main/java/org/thingsboard/server/queue/discovery/PartitionService.java

@ -5,6 +5,7 @@ package org.thingsboard.server.queue.discovery;
import org.thingsboard.server.common.data.id.EntityId;
import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.id.TenantProfileId;
import org.thingsboard.server.common.msg.queue.ServiceType;
import org.thingsboard.server.common.msg.queue.TopicPartitionInfo;
import org.thingsboard.server.gen.transport.TransportProtos;
@ -61,6 +62,8 @@ public interface PartitionService {
void evictTenantInfo(TenantId tenantId);
void evictTenantProfileInfo(TenantProfileId tenantProfileId);
int countTransportsByType(String type);
int getIntegrationExecutorPartitionsCount();

19
dao/src/main/java/org/thingsboard/server/dao/pat/ApiKeyServiceImpl.java

@ -90,7 +90,12 @@ public class ApiKeyServiceImpl extends AbstractCachedEntityService<ApiKeyCacheKe
var savedApiKey = apiKeyDao.save(tenantId, apiKey);
eventPublisher.publishEvent(SaveEntityEvent.builder().tenantId(tenantId).entityId(savedApiKey.getId()).entity(savedApiKey).created(apiKey.getId() == null).build());
if (isPublishEvictRequired(old, apiKey)) {
publishEvictEvent(new ApiKeyEvictEvent(apiKey.getValue()));
// the cache is keyed by value, so the entry to evict is the one the old value still resolves to
publishEvictEvent(new ApiKeyEvictEvent(old.getValue()));
}
if (value != null && (old == null || !value.equals(old.getValue()))) {
// a failed authentication attempt may have cached a miss for the explicitly provided value (edge sync)
publishEvictEvent(new ApiKeyEvictEvent(value));
}
return savedApiKey;
} catch (Exception e) {
@ -219,17 +224,19 @@ public class ApiKeyServiceImpl extends AbstractCachedEntityService<ApiKeyCacheKe
}
/**
* Whether an update changed anything the cached copy of the key is read for. A newly created key has nothing
* cached yet, hence the null check on the previous state.
* Whether an update changed anything the cached copy of the key is read for, so the entry under the old value
* must be evicted. Null old means create: there is no previous value to evict; a cached miss for an explicitly
* provided value is evicted separately in saveApiKey.
* <p>
* Authentication resolves a key by value straight from the cache and builds the caller's effective permissions
* from the cached instance, so both the enabled flag and the permissions must trigger an eviction. The value
* itself is not compared: an update preserves it, and a rotation evicts unconditionally.
* from the cached instance, so the enabled flag, the permissions and the value must all trigger an eviction.
* A rotation evicts unconditionally.
*/
private static boolean isPublishEvictRequired(ApiKey old, ApiKey apiKey) {
return old != null
&& (old.isEnabled() != apiKey.isEnabled()
|| !Objects.equals(old.getPermissions(), apiKey.getPermissions()));
|| !Objects.equals(old.getPermissions(), apiKey.getPermissions())
|| !Objects.equals(old.getValue(), apiKey.getValue()));
}
@Override

68
dao/src/test/java/org/thingsboard/server/dao/pat/ApiKeyCacheEvictionTest.java

@ -3,6 +3,7 @@
// SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
package org.thingsboard.server.dao.pat;
import com.datastax.oss.driver.api.core.uuid.Uuids;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@ -10,7 +11,9 @@ import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.bean.override.mockito.MockitoSpyBean;
import org.thingsboard.server.cache.TbTransactionalCache;
import org.thingsboard.server.common.data.StringUtils;
import org.thingsboard.server.common.data.User;
import org.thingsboard.server.common.data.id.ApiKeyId;
import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.id.UserId;
import org.thingsboard.server.common.data.pat.ApiKey;
@ -21,7 +24,7 @@ import org.thingsboard.server.dao.service.DaoSqlTest;
import org.thingsboard.server.dao.user.UserService;
/**
* Verifies the exact cache interactions of {@link ApiKeyService} rotation: which {@link ApiKeyCacheKey}s are evicted
* Verifies the exact cache interactions of {@link ApiKeyService} saves and rotation: which {@link ApiKeyCacheKey}s are evicted
* and how many times. Lives in this package because {@link ApiKeyCacheKey} is package-private.
*/
@DaoSqlTest
@ -73,4 +76,67 @@ public class ApiKeyCacheEvictionTest extends AbstractServiceTest {
Mockito.verify(apiKeyCache, Mockito.times(1)).evict(Mockito.any(ApiKeyCacheKey.class));
}
@Test
public void testSaveApiKeyWithNewValue_evictsOldAndNewValueExactlyOnce() {
ApiKey savedApiKey = apiKeyService.saveApiKey(tenantId, createApiKeyInfo());
String originalValue = savedApiKey.getValue();
String newValue = "new-api-key-value-" + StringUtils.randomAlphanumeric(32);
Mockito.clearInvocations(apiKeyCache);
apiKeyService.saveApiKey(tenantId, savedApiKey, newValue, false);
Mockito.verify(apiKeyCache).evict(ApiKeyCacheKey.of(originalValue));
Mockito.verify(apiKeyCache).evict(ApiKeyCacheKey.of(newValue));
Mockito.verify(apiKeyCache, Mockito.times(2)).evict(Mockito.any(ApiKeyCacheKey.class));
}
@Test
public void testCreateApiKeyWithExplicitValue_evictsValueExactlyOnce() {
// the edge uplink creates the key on the cloud with a preset id and the value generated on the edge
ApiKeyInfo apiKeyInfo = createApiKeyInfo();
ApiKeyId apiKeyId = new ApiKeyId(Uuids.timeBased());
apiKeyInfo.setId(apiKeyId);
apiKeyInfo.setCreatedTime(Uuids.unixTimestamp(apiKeyId.getId()));
String value = "edge-api-key-value-" + StringUtils.randomAlphanumeric(32);
Mockito.clearInvocations(apiKeyCache);
apiKeyService.saveApiKey(tenantId, apiKeyInfo, value, false);
Mockito.verify(apiKeyCache).evict(ApiKeyCacheKey.of(value));
Mockito.verify(apiKeyCache, Mockito.times(1)).evict(Mockito.any(ApiKeyCacheKey.class));
}
@Test
public void testDisableApiKey_evictsValueExactlyOnce() {
ApiKey savedApiKey = apiKeyService.saveApiKey(tenantId, createApiKeyInfo());
String value = savedApiKey.getValue();
savedApiKey.setEnabled(false);
Mockito.clearInvocations(apiKeyCache);
apiKeyService.saveApiKey(tenantId, savedApiKey);
Mockito.verify(apiKeyCache).evict(ApiKeyCacheKey.of(value));
Mockito.verify(apiKeyCache, Mockito.times(1)).evict(Mockito.any(ApiKeyCacheKey.class));
}
@Test
public void testUpdateApiKeyDescription_noEviction() {
ApiKey savedApiKey = apiKeyService.saveApiKey(tenantId, createApiKeyInfo());
savedApiKey.setDescription("Updated description, cached state unchanged");
Mockito.clearInvocations(apiKeyCache);
apiKeyService.saveApiKey(tenantId, savedApiKey);
Mockito.verify(apiKeyCache, Mockito.never()).evict(Mockito.any(ApiKeyCacheKey.class));
}
private ApiKeyInfo createApiKeyInfo() {
ApiKeyInfo apiKeyInfo = new ApiKeyInfo();
apiKeyInfo.setTenantId(tenantId);
apiKeyInfo.setUserId(userId);
apiKeyInfo.setDescription("API key cache eviction test");
apiKeyInfo.setEnabled(true);
return apiKeyInfo;
}
}

53
dao/src/test/java/org/thingsboard/server/dao/service/ApiKeyServiceTest.java

@ -3,6 +3,7 @@
// SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
package org.thingsboard.server.dao.service;
import com.datastax.oss.driver.api.core.uuid.Uuids;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@ -10,6 +11,7 @@ import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.thingsboard.server.common.data.StringUtils;
import org.thingsboard.server.common.data.User;
import org.thingsboard.server.common.data.id.ApiKeyId;
import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.id.UserId;
import org.thingsboard.server.common.data.page.PageData;
@ -297,6 +299,57 @@ public class ApiKeyServiceTest extends AbstractServiceTest {
Assert.assertNull(foundApiKey);
}
@Test
public void testSaveApiKeyWithNewValue_oldValueEvictedFromCache() {
ApiKeyInfo apiKeyInfo = createApiKeyInfo(TEST_API_KEY_DESCRIPTION);
ApiKey savedApiKey = apiKeyService.saveApiKey(tenantId, apiKeyInfo);
String originalValue = savedApiKey.getValue();
// authentication resolves the key by value and caches the lookup
Assert.assertNotNull(apiKeyService.findApiKeyByValue(originalValue));
String newValue = "new-api-key-value-" + StringUtils.randomAlphanumeric(32);
apiKeyService.saveApiKey(tenantId, savedApiKey, newValue, false);
Assert.assertNull("Old API key value must not resolve after the value changed", apiKeyService.findApiKeyByValue(originalValue));
ApiKey foundByNewValue = apiKeyService.findApiKeyByValue(newValue);
Assert.assertNotNull(foundByNewValue);
Assert.assertEquals(savedApiKey.getId(), foundByNewValue.getId());
}
@Test
public void testSaveApiKeyWithNewValue_cachedMissForNewValueEvicted() {
ApiKeyInfo apiKeyInfo = createApiKeyInfo(TEST_API_KEY_DESCRIPTION);
ApiKey savedApiKey = apiKeyService.saveApiKey(tenantId, apiKeyInfo);
String newValue = "new-api-key-value-" + StringUtils.randomAlphanumeric(32);
// a failed authentication attempt caches the miss for the not-yet-saved value
Assert.assertNull(apiKeyService.findApiKeyByValue(newValue));
apiKeyService.saveApiKey(tenantId, savedApiKey, newValue, false);
ApiKey foundByNewValue = apiKeyService.findApiKeyByValue(newValue);
Assert.assertNotNull("New API key value must resolve after it is saved", foundByNewValue);
Assert.assertEquals(savedApiKey.getId(), foundByNewValue.getId());
}
@Test
public void testCreateApiKeyWithExplicitValue_cachedMissForValueEvicted() {
String value = "edge-api-key-value-" + StringUtils.randomAlphanumeric(32);
// a failed authentication attempt caches the miss before the edge uplink delivers the key
Assert.assertNull(apiKeyService.findApiKeyByValue(value));
// the edge uplink creates the key on the cloud with a preset id and the value generated on the edge
ApiKeyInfo apiKeyInfo = createApiKeyInfo(TEST_API_KEY_DESCRIPTION);
ApiKeyId apiKeyId = new ApiKeyId(Uuids.timeBased());
apiKeyInfo.setId(apiKeyId);
apiKeyInfo.setCreatedTime(Uuids.unixTimestamp(apiKeyId.getId()));
ApiKey savedApiKey = apiKeyService.saveApiKey(tenantId, apiKeyInfo, value, false);
ApiKey foundByValue = apiKeyService.findApiKeyByValue(value);
Assert.assertNotNull("API key value must resolve after the key is created with it", foundByValue);
Assert.assertEquals(savedApiKey.getId(), foundByValue.getId());
}
@Test
public void testFindApiKeysByUserId() {
int size = 3;

8
transport/coap/src/main/resources/tb-coap-transport.yml

@ -155,6 +155,14 @@ transport:
inactivity_timeout: "${TB_TRANSPORT_SESSIONS_INACTIVITY_TIMEOUT:600000}"
# Interval of periodic check for expired sessions and report of the changes to session last activity time
report_timeout: "${TB_TRANSPORT_SESSIONS_REPORT_TIMEOUT:3000}"
activity:
# This property specifies the strategy for reporting activity events within each reporting period.
# The accepted values are 'FIRST', 'LAST', 'FIRST_AND_LAST' and 'ALL'.
# <ul><li> 'FIRST': Only the first activity event in each reporting period is reported.</li>
# <li> 'LAST': Only the last activity event in the reporting period is reported.</li>
# <li> 'FIRST_AND_LAST': Both the first and last activity events in the reporting period are reported.</li>
# <li> 'ALL': All activity events in the reporting period are reported.</li></ul>
reporting_strategy: "${TB_TRANSPORT_ACTIVITY_REPORTING_STRATEGY:LAST}"
json:
# Cast String data types to Numeric if possible when processing Telemetry/Attributes JSON
type_cast_enabled: "${JSON_TYPE_CAST_ENABLED:true}"

8
transport/http/src/main/resources/tb-http-transport.yml

@ -186,6 +186,14 @@ transport:
inactivity_timeout: "${TB_TRANSPORT_SESSIONS_INACTIVITY_TIMEOUT:600000}"
# Interval of periodic check for expired sessions and report of the changes to session last activity time
report_timeout: "${TB_TRANSPORT_SESSIONS_REPORT_TIMEOUT:3000}"
activity:
# This property specifies the strategy for reporting activity events within each reporting period.
# The accepted values are 'FIRST', 'LAST', 'FIRST_AND_LAST' and 'ALL'.
# <ul><li> 'FIRST': Only the first activity event in each reporting period is reported.</li>
# <li> 'LAST': Only the last activity event in the reporting period is reported.</li>
# <li> 'FIRST_AND_LAST': Both the first and last activity events in the reporting period are reported.</li>
# <li> 'ALL': All activity events in the reporting period are reported.</li></ul>
reporting_strategy: "${TB_TRANSPORT_ACTIVITY_REPORTING_STRATEGY:LAST}"
json:
# Cast String data types to Numeric if possible when processing Telemetry/Attributes JSON
type_cast_enabled: "${JSON_TYPE_CAST_ENABLED:true}"

8
transport/lwm2m/src/main/resources/tb-lwm2m-transport.yml

@ -146,6 +146,14 @@ transport:
inactivity_timeout: "${TB_TRANSPORT_SESSIONS_INACTIVITY_TIMEOUT:600000}"
# Interval of periodic check for expired sessions and report of the changes to session last activity time
report_timeout: "${TB_TRANSPORT_SESSIONS_REPORT_TIMEOUT:3000}"
activity:
# This property specifies the strategy for reporting activity events within each reporting period.
# The accepted values are 'FIRST', 'LAST', 'FIRST_AND_LAST' and 'ALL'.
# <ul><li> 'FIRST': Only the first activity event in each reporting period is reported.</li>
# <li> 'LAST': Only the last activity event in the reporting period is reported.</li>
# <li> 'FIRST_AND_LAST': Both the first and last activity events in the reporting period are reported.</li>
# <li> 'ALL': All activity events in the reporting period are reported.</li></ul>
reporting_strategy: "${TB_TRANSPORT_ACTIVITY_REPORTING_STRATEGY:LAST}"
json:
# Cast String data types to Numeric if possible when processing Telemetry/Attributes JSON
type_cast_enabled: "${JSON_TYPE_CAST_ENABLED:false}"

8
transport/mqtt/src/main/resources/tb-mqtt-transport.yml

@ -209,6 +209,14 @@ transport:
inactivity_timeout: "${TB_TRANSPORT_SESSIONS_INACTIVITY_TIMEOUT:600000}"
# Interval of periodic check for expired sessions and report of the changes to session last activity time
report_timeout: "${TB_TRANSPORT_SESSIONS_REPORT_TIMEOUT:3000}"
activity:
# This property specifies the strategy for reporting activity events within each reporting period.
# The accepted values are 'FIRST', 'LAST', 'FIRST_AND_LAST' and 'ALL'.
# <ul><li> 'FIRST': Only the first activity event in each reporting period is reported.</li>
# <li> 'LAST': Only the last activity event in the reporting period is reported.</li>
# <li> 'FIRST_AND_LAST': Both the first and last activity events in the reporting period are reported.</li>
# <li> 'ALL': All activity events in the reporting period are reported.</li></ul>
reporting_strategy: "${TB_TRANSPORT_ACTIVITY_REPORTING_STRATEGY:LAST}"
json:
# Cast String data types to Numeric if possible when processing Telemetry/Attributes JSON
type_cast_enabled: "${JSON_TYPE_CAST_ENABLED:true}"

8
transport/snmp/src/main/resources/tb-snmp-transport.yml

@ -167,6 +167,14 @@ transport:
inactivity_timeout: "${TB_TRANSPORT_SESSIONS_INACTIVITY_TIMEOUT:600000}"
# Interval of periodic check for expired sessions and report of the changes to session last activity time
report_timeout: "${TB_TRANSPORT_SESSIONS_REPORT_TIMEOUT:3000}"
activity:
# This property specifies the strategy for reporting activity events within each reporting period.
# The accepted values are 'FIRST', 'LAST', 'FIRST_AND_LAST' and 'ALL'.
# <ul><li> 'FIRST': Only the first activity event in each reporting period is reported.</li>
# <li> 'LAST': Only the last activity event in the reporting period is reported.</li>
# <li> 'FIRST_AND_LAST': Both the first and last activity events in the reporting period are reported.</li>
# <li> 'ALL': All activity events in the reporting period are reported.</li></ul>
reporting_strategy: "${TB_TRANSPORT_ACTIVITY_REPORTING_STRATEGY:LAST}"
json:
# Cast String data types to Numeric if possible when processing Telemetry/Attributes JSON
type_cast_enabled: "${JSON_TYPE_CAST_ENABLED:true}"

2
ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-installed-items-table.component.html

@ -43,7 +43,7 @@
<td mat-cell *matCellDef="let item">
@if (updatesChecked) {
@let pubInfo = getPublishedVersionInfo(item);
@if (pubInfo && pubInfo.publishedVersionId !== item.itemVersionId) {
@if (pubInfo?.publishedVersionId && pubInfo.publishedVersionId !== item.itemVersionId) {
<div class="flex items-center gap-3">
@if (!itemVersion) {
<button mat-stroked-button color="warn" class="tb-installed-update-btn" (click)="updateItem(item, pubInfo)">

Loading…
Cancel
Save