Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: Refresh ISO cache when new guest agent installed #635

Merged
merged 1 commit into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to call getCopyVds() just to get the storage pool id?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, AFAIK. There is no other place where the storage pool ID is stored.

}
dbVm.updateRuntimeData(vdsmVm.getVmDynamic(), vdsManager.getVdsId());
saveDynamic(dbVm);
}
Expand Down