Skip to content

Commit

Permalink
core: Refresh ISO cache when new guest agent installed
Browse files Browse the repository at this point in the history
The latest available guest tools version is figured out by analyzing ISO
disks available on ISO and data storage domains. The list of available
ISO disks is cached and this cache is refreshed when user queries the
list of images on a storage domain. At that moment, the latest guest
tools version is refreshed and the guest agent installation hint
(presented to the user) is updated.

But ISO cache refresh does not happen after a new guest agent is
installed. That's why the guest agent installation hint is still shown
after installing the latest guest agent in the VM.

To fix that, this patch adds ISO cache refresh when the list of
applications for a particular VM is changed.

Change-Id: I6c25a97ae14cc40d073b3873c6bae9db3216204d
Bug-Url: https://bugzilla.redhat.com/1983401
Bug-Url: https://bugzilla.redhat.com/2120381
Signed-off-by: Shmuel Melamud <smelamud@redhat.com>
  • Loading branch information
smelamud authored and mwperina committed Sep 20, 2022
1 parent d7adf05 commit 89a8939
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.ovirt.engine.core.bll.interfaces.BackendInternal;
import org.ovirt.engine.core.bll.job.ExecutionHandler;
import org.ovirt.engine.core.bll.scheduling.SchedulingManager;
import org.ovirt.engine.core.bll.storage.domain.IsoDomainListSynchronizer;
import org.ovirt.engine.core.bll.storage.pool.StoragePoolStatusHandler;
import org.ovirt.engine.core.bll.tasks.CommandCoordinatorUtil;
import org.ovirt.engine.core.common.AuditLogType;
Expand Down Expand Up @@ -50,6 +51,7 @@
import org.ovirt.engine.core.common.businessentities.IVdsEventListener;
import org.ovirt.engine.core.common.businessentities.NonOperationalReason;
import org.ovirt.engine.core.common.businessentities.StorageDomainStatic;
import org.ovirt.engine.core.common.businessentities.StorageDomainType;
import org.ovirt.engine.core.common.businessentities.StoragePool;
import org.ovirt.engine.core.common.businessentities.StoragePoolStatus;
import org.ovirt.engine.core.common.businessentities.VDS;
Expand All @@ -61,6 +63,7 @@
import org.ovirt.engine.core.common.businessentities.storage.Disk;
import org.ovirt.engine.core.common.businessentities.storage.DiskImage;
import org.ovirt.engine.core.common.businessentities.storage.DiskStorageType;
import org.ovirt.engine.core.common.businessentities.storage.ImageFileType;
import org.ovirt.engine.core.common.errors.EngineError;
import org.ovirt.engine.core.common.errors.EngineException;
import org.ovirt.engine.core.common.eventqueue.Event;
Expand All @@ -79,6 +82,7 @@
import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable;
import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl;
import org.ovirt.engine.core.dao.DiskDao;
import org.ovirt.engine.core.dao.StorageDomainDao;
import org.ovirt.engine.core.dao.StorageDomainStaticDao;
import org.ovirt.engine.core.dao.StoragePoolDao;
import org.ovirt.engine.core.dao.VdsDao;
Expand Down Expand Up @@ -118,6 +122,8 @@ public class VdsEventListener implements IVdsEventListener {
@Inject
private StoragePoolDao storagePoolDao;
@Inject
private StorageDomainDao storageDomainDao;
@Inject
private CpuQosDao cpuQosDao;
@Inject
private StorageQosDao storageQosDao;
Expand Down Expand Up @@ -147,6 +153,8 @@ public class VdsEventListener implements IVdsEventListener {
private StoragePoolStatusHandler storagePoolStatusHandler;
@Inject
private HostLocking hostLocking;
@Inject
private IsoDomainListSynchronizer isoDomainListSynchronizer;

private static final Logger log = LoggerFactory.getLogger(VdsEventListener.class);

Expand Down Expand Up @@ -613,6 +621,18 @@ public void restartVmsWithLease(List<Guid> vmIds, Guid hostId) {
});
}

@Override
public void refreshIsoCache(Guid storagePoolId) {
ThreadPoolUtil.execute(() -> {
storageDomainDao.getAllForStoragePool(storagePoolId)
.stream()
.filter(sd -> sd.getStorageDomainType() == StorageDomainType.ISO
|| sd.getStorageDomainType().isDataDomain())
.forEach(sd -> isoDomainListSynchronizer
.getUserRequestForStorageDomainRepoFileList(sd.getId(), ImageFileType.ISO, true));
});
}

public Map<String, Pair<String, String>> getVdsPoolAndStorageConnectionsLock(Guid vdsId) {
return hostLocking.getVdsPoolAndStorageConnectionsLock(vdsId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ void storagePoolStatusChange(Guid storagePoolId, StoragePoolStatus status, Audit

void restartVmsWithLease(List<Guid> vmIds, Guid hostId);

void refreshIsoCache(Guid storagePoolId);

Map<String, Pair<String, String>> getVdsPoolAndStorageConnectionsLock(Guid vdsId);

ActionReturnValue saveExternalData(SaveVmExternalDataParameters parameters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,10 @@ public void subscribe(EventSubscriber subscriber) {
ReactorFactory.getWorker(this.parallelism, this.eventTimeoutInHours).getPublisher().subscribe(subscriber);
}

public void refreshIsoCache(Guid storagePoolId) {
getEventListener().refreshIsoCache(storagePoolId);
}

@Inject
@ThreadPools(ThreadPools.ThreadPoolType.EngineThreadMonitoringThreadPool)
private ManagedScheduledExecutorService monitoringExecutor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,9 @@ private void updateRuntimeData() {
vmGuestAgentNics = filterGuestAgentInterfaces(nullToEmptyList(vdsmVm.getVmGuestAgentInterfaces()));
dbVm.setIp(extractVmIps(vmGuestAgentNics));
}

if (!Objects.equals(vdsmVm.getVmDynamic().getAppList(), dbVm.getAppList())) {
resourceManager.refreshIsoCache(vdsManager.getCopyVds().getStoragePoolId());
}
dbVm.updateRuntimeData(vdsmVm.getVmDynamic(), vdsManager.getVdsId());
saveDynamic(dbVm);
}
Expand Down

0 comments on commit 89a8939

Please sign in to comment.