Skip to content
This repository has been archived by the owner on Jan 4, 2022. It is now read-only.

Commit

Permalink
handle duplicate healthHostMaps
Browse files Browse the repository at this point in the history
delete duplicate healthcheck_instance_host_maps for same host and instance
  • Loading branch information
kinarashah authored and Alena Prokharchyk committed Aug 31, 2018
1 parent bac755e commit 86c94c4
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import io.cattle.platform.object.ObjectManager;
import io.cattle.platform.object.meta.ObjectMetaDataManager;
import io.cattle.platform.object.process.ObjectProcessManager;
import io.cattle.platform.object.process.StandardProcess;
import io.cattle.platform.util.type.CollectionUtils;

import java.util.ArrayList;
Expand Down Expand Up @@ -110,7 +111,6 @@ protected void processHealthcheckInstance(HealthcheckInstanceHostMap hcihm, Stri
updateInstanceHealthState(instance, updateWithState);
}


protected boolean shouldUpdate(HealthcheckInstanceHostMap hcihm, long externalTimestamp, String healthState) {
HealthcheckInstance hcInstance = objectManager.loadResource(HealthcheckInstance.class,
hcihm.getHealthcheckInstanceId());
Expand Down Expand Up @@ -239,10 +239,21 @@ protected void createHealthCheckHostMaps(HealthcheckInstanceType instanceType, l
HealthcheckInstance healthInstance) {
Long inferiorHostId = getInstanceHostId(instanceType, id);
List<Long> healthCheckHostIds = getHealthCheckHostIds(healthInstance, inferiorHostId);
List<HealthcheckInstanceHostMap> healthHostMaps = objectManager.find(HealthcheckInstanceHostMap.class,
HEALTHCHECK_INSTANCE_HOST_MAP.HEALTHCHECK_INSTANCE_ID, healthInstance.getId(),
HEALTHCHECK_INSTANCE_HOST_MAP.REMOVED, null);
for (Long healthCheckHostId : healthCheckHostIds) {
HealthcheckInstanceHostMap healthHostMap = mapDao.findNonRemoved(HealthcheckInstanceHostMap.class,
Host.class, healthCheckHostId, HealthcheckInstance.class,
healthInstance.getId());
HealthcheckInstanceHostMap healthHostMap = null;
for(HealthcheckInstanceHostMap hostMap : healthHostMaps) {
if(!hostMap.getHostId().equals(healthCheckHostId)) {
continue;
}
if (healthHostMap == null) {
healthHostMap = hostMap;
} else if (!hostMap.getState().equals(CommonStatesConstants.REMOVING)) {
objectProcessManager.scheduleStandardProcess(StandardProcess.REMOVE, hostMap, null);
}
}
Long instanceId = (instanceType == HealthcheckInstanceType.INSTANCE ? id : null);
if (healthHostMap == null) {
resourceDao.createAndSchedule(HealthcheckInstanceHostMap.class, HEALTHCHECK_INSTANCE_HOST_MAP.HOST_ID,
Expand Down

0 comments on commit 86c94c4

Please sign in to comment.