Skip to content

Commit

Permalink
return store without checking all
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel authored and GaOrtiga committed Sep 18, 2024
1 parent 51b2b50 commit 65e4a7d
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import org.apache.cloudstack.storage.image.store.ImageStoreImpl;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Component;

import com.cloud.server.StatsCollector;
Expand Down Expand Up @@ -180,14 +179,16 @@ public DataStore getRandomImageStore(List<DataStore> imageStores) {

@Override
public DataStore getImageStoreWithFreeCapacity(List<DataStore> imageStores) {
List<DataStore> orderedImageStores = orderImageStoresOnFreeCapacity(imageStores);
if (CollectionUtils.isEmpty(orderedImageStores)) {
logger.error(String.format("Could not find an image storage in zone with less than %d usage",
Math.round(_statsCollector.getImageStoreCapacityThreshold() * 100)));
return null;
imageStores.sort((store1, store2) -> Long.compare(_statsCollector.imageStoreCurrentFreeCapacity(store2),
_statsCollector.imageStoreCurrentFreeCapacity(store1)));

Check warning on line 183 in engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/manager/ImageStoreProviderManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/manager/ImageStoreProviderManagerImpl.java#L182-L183

Added lines #L182 - L183 were not covered by tests
for (DataStore imageStore : imageStores) {
if (_statsCollector.imageStoreHasEnoughCapacity(imageStore)) {
return imageStore;

Check warning on line 186 in engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/manager/ImageStoreProviderManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/manager/ImageStoreProviderManagerImpl.java#L186

Added line #L186 was not covered by tests
}
}

return orderedImageStores.get(0);
logger.error(String.format("Could not find an image storage in zone with less than %d usage",

Check warning on line 189 in engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/manager/ImageStoreProviderManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/manager/ImageStoreProviderManagerImpl.java#L189

Added line #L189 was not covered by tests
Math.round(_statsCollector.getImageStoreCapacityThreshold() * 100)));
return null;
}

@Override
Expand Down

0 comments on commit 65e4a7d

Please sign in to comment.