JCLOUDS-1307: Invalidate SG on removal even if already externally deleted

This commit is contained in:
Svetoslav Neykov 2017-06-09 12:41:16 +03:00
parent b77ea06950
commit 65ba26eca7
No known key found for this signature in database
GPG Key ID: 979090BE59D0A896
1 changed files with 9 additions and 3 deletions

View File

@ -24,6 +24,7 @@ import static com.google.common.collect.Iterables.transform;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import java.util.Map;
import java.util.Set; import java.util.Set;
import com.google.common.base.Function; import com.google.common.base.Function;
@ -105,12 +106,17 @@ public class AWSEC2SecurityGroupExtension extends EC2SecurityGroupExtension {
if (group != null) { if (group != null) {
client.getSecurityGroupApi().get().deleteSecurityGroupInRegionById(region, groupId); client.getSecurityGroupApi().get().deleteSecurityGroupInRegionById(region, groupId);
// TODO: test this clear happens
groupCreator.invalidate(new RegionNameAndIngressRules(region, group.getName(), null, false, null)); groupCreator.invalidate(new RegionNameAndIngressRules(region, group.getName(), null, false, null));
return true; return true;
} else {
for (Map.Entry<RegionAndName, String> cachedSg : groupCreator.asMap().entrySet()) {
if (groupId.equals(cachedSg.getValue())) {
groupCreator.invalidate(cachedSg.getKey());
break;
}
}
return false;
} }
return false;
} }
@Override @Override