bernardodemarco commented on code in PR #11076:
URL: https://github.com/apache/cloudstack/pull/11076#discussion_r2676430323
##########
engine/schema/src/main/java/com/cloud/network/dao/PublicIpQuarantineDaoImpl.java:
##########
@@ -47,8 +51,18 @@ public void init() {
publicIpAddressByIdSearch.join("quarantineJoin",
ipAddressSearchBuilder, ipAddressSearchBuilder.entity().getId(),
publicIpAddressByIdSearch.entity().getPublicIpAddressId(),
JoinBuilder.JoinType.INNER);
+ quarantinedIpAddressesSearch = createSearchBuilder();
+ quarantinedIpAddressesSearch.and("previousOwnerId",
quarantinedIpAddressesSearch.entity().getPreviousOwnerId(),
SearchCriteria.Op.NEQ);
+ quarantinedIpAddressesSearch.and();
+ quarantinedIpAddressesSearch.op("removedIsNull",
quarantinedIpAddressesSearch.entity().getRemoved(), SearchCriteria.Op.NULL);
+ quarantinedIpAddressesSearch.and("endDate",
quarantinedIpAddressesSearch.entity().getEndDate(), SearchCriteria.Op.GT);
+ quarantinedIpAddressesSearch.or("removedIsNotNull",
quarantinedIpAddressesSearch.entity().getRemoved(), SearchCriteria.Op.NNULL);
+ quarantinedIpAddressesSearch.and("removedDateGt",
quarantinedIpAddressesSearch.entity().getRemoved(), SearchCriteria.Op.GT);
Review Comment:
@erikbocks, I did not understand this `OR` operation here.
The public IP will not be available for the user if the previous owner is
different than them and if it is still in quarantine (`removed` equal to `NULL`
and `end_date` is greater than the current date).
If the `removed` field is set to a value different than `NULL`, it means
that the public IP is not in quarantine anymore, doesn't it?
##########
engine/schema/src/main/java/com/cloud/network/dao/PublicIpQuarantineDao.java:
##########
@@ -19,9 +19,21 @@
import com.cloud.network.vo.PublicIpQuarantineVO;
import com.cloud.utils.db.GenericDao;
+import java.util.Date;
+import java.util.List;
+
public interface PublicIpQuarantineDao extends
GenericDao<PublicIpQuarantineVO, Long> {
PublicIpQuarantineVO findByPublicIpAddressId(long publicIpAddressId);
PublicIpQuarantineVO findByIpAddress(String publicIpAddress);
+
+ /**
+ * Returns a list of public IP addresses that are actively quarantined at
the specified date and the previous owner differs from the specified user.
+ *
+ * @param userId used to check against the IP's previous owner.
+ * @param date used to check if the quarantine is active;
+ * @return a list of PublicIpQuarantineVOs
+ */
Review Comment:
```suggestion
* @param userId used to check against the IP's previous owner;
* @param date used to check if the quarantine is active;
* @return a list of PublicIpQuarantineVOs.
*/
```
##########
server/src/main/java/com/cloud/network/IpAddressManagerImpl.java:
##########
@@ -883,22 +886,35 @@ public List<IPAddressVO> listAvailablePublicIps(final
long dcId, final Long podI
if (podId != null) {
sc = AssignIpAddressFromPodVlanSearch.create();
sc.setJoinParameters("podVlanMapSB", "podId", podId);
- errorMessage.append(" pod id=" + podId);
+ errorMessage.append(" pod id=").append(podId);
} else {
sc = AssignIpAddressSearch.create();
- errorMessage.append(" zone id=" + dcId);
+ errorMessage.append(" zone id=").append(dcId);
+ }
+
+ if (lockOneRow) {
+ logger.debug("Listing quarantined public IPs to ignore on search
for public IP for system VM. The IPs ignored will be the ones that: were not
associated to account [{}]; were not removed yet; and with quarantine end dates
after [{}].", owner.getUuid(), new Date());
+
+ List<PublicIpQuarantineVO> quarantinedAddresses =
publicIpQuarantineDao.listQuarantinedIpAddressesToUser(owner.getId(), new
Date());
+ List<Long> quarantinedAddressesIDs =
quarantinedAddresses.stream().map(PublicIpQuarantineVO::getPublicIpAddressId).collect(Collectors.toList());
+
+ logger.debug("Found addresses with the following IDs: {}.",
quarantinedAddressesIDs);
Review Comment:
```suggestion
logger.debug("Found addresses with the following IDs: [{}] that
will be ignored when searching for available public IPs.",
quarantinedAddressesIDs);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]