Skip to content

Commit

Permalink
Merge release branch 4.20 to main
Browse files Browse the repository at this point in the history
* 4.20:
  merge errors fixed
  Restrict the migration of volumes attached to VMs in Starting state (#9725)
  server, plugin: enhance storage stats for IOPS (#10034)
  Introducing granular command timeouts global setting (#9659)
  Improve logging to include more identifiable information (#9873)
  • Loading branch information
DaanHoogland committed Jan 8, 2025
2 parents d1cf453 + ab76d3c commit fadb39e
Show file tree
Hide file tree
Showing 495 changed files with 6,646 additions and 4,887 deletions.
44 changes: 36 additions & 8 deletions agent/src/main/java/com/cloud/agent/Agent.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ public int value() {
ServerResource _resource;
Link _link;
Long _id;
String _uuid;
String _name;

Timer _timer = new Timer("Agent Timer");
Timer certTimer;
Expand Down Expand Up @@ -182,8 +184,10 @@ public Agent(final IAgentShell shell, final int localAgentId, final ServerResour
resource.setAgentControl(this);

final String value = _shell.getPersistentProperty(getResourceName(), "id");
_uuid = _shell.getPersistentProperty(getResourceName(), "uuid");
_name = _shell.getPersistentProperty(getResourceName(), "name");
_id = value != null ? Long.parseLong(value) : null;
logger.info("id is {}", ObjectUtils.defaultIfNull(_id, ""));
logger.info("Initialising agent [id: {}, uuid: {}, name: {}]", ObjectUtils.defaultIfNull(_id, ""), _uuid, _name);

final Map<String, Object> params = new HashMap<>();

Expand Down Expand Up @@ -212,8 +216,9 @@ public Agent(final IAgentShell shell, final int localAgentId, final ServerResour
new ThreadPoolExecutor(_shell.getWorkers(), 5 * _shell.getWorkers(), 1, TimeUnit.DAYS, new LinkedBlockingQueue<Runnable>(), new NamedThreadFactory(
"agentRequest-Handler"));

logger.info("Agent [id = {} : type = {} : zone = {} : pod = {} : workers = {} : host = {} : port = {}", ObjectUtils.defaultIfNull(_id, "new"), getResourceName(),
_shell.getZone(), _shell.getPod(), _shell.getWorkers(), host, _shell.getPort());
logger.info("Agent [id = {}, uuid: {}, name: {}] : type = {} : zone = {} : pod = {} : workers = {} : host = {} : port = {}",
ObjectUtils.defaultIfNull(_id, "new"), _uuid, _name, getResourceName(),
_shell.getZone(), _shell.getPod(), _shell.getWorkers(), host, _shell.getPort());
}

public String getVersion() {
Expand Down Expand Up @@ -377,11 +382,28 @@ public Long getId() {
}

public void setId(final Long id) {
logger.debug("Set agent id {}", id);
_id = id;
_shell.setPersistentProperty(getResourceName(), "id", Long.toString(id));
}

public String getUuid() {
return _uuid;
}

public void setUuid(String uuid) {
this._uuid = uuid;
_shell.setPersistentProperty(getResourceName(), "uuid", uuid);
}

public String getName() {
return _name;
}

public void setName(String name) {
this._name = name;
_shell.setPersistentProperty(getResourceName(), "name", name);
}

private synchronized void scheduleServicesRestartTask() {
if (certTimer != null) {
certTimer.cancel();
Expand Down Expand Up @@ -594,17 +616,21 @@ public void processStartupAnswer(final Answer answer, final Response response, f
return;
}

logger.info("Process agent startup answer, agent id = {}", startup.getHostId());
logger.info("Process agent startup answer, agent [id: {}, uuid: {}, name: {}] connected to the server",
startup.getHostId(), startup.getHostUuid(), startup.getHostName());

setId(startup.getHostId());
setUuid(startup.getHostUuid());
setName(startup.getHostName());
_pingInterval = (long)startup.getPingInterval() * 1000; // change to ms.

setLastPingResponseTime();
scheduleWatch(link, response, _pingInterval, _pingInterval);

_ugentTaskPool.setKeepAliveTime(2 * _pingInterval, TimeUnit.MILLISECONDS);

logger.info("Startup Response Received: agent id = {}", getId());
logger.info("Startup Response Received: agent [id: {}, uuid: {}, name: {}]",
startup.getHostId(), startup.getHostUuid(), startup.getHostName());
}

protected void processRequest(final Request request, final Link link) {
Expand Down Expand Up @@ -860,15 +886,17 @@ public void processReadyCommand(final Command cmd) {
NumbersUtil.enableHumanReadableSizes = humanReadable;
}

logger.info("Processing agent ready command, agent id = {}", ready.getHostId());
logger.info("Processing agent ready command, agent id = {}, uuid = {}, name = {}", ready.getHostId(), ready.getHostUuid(), ready.getHostName());
if (ready.getHostId() != null) {
setId(ready.getHostId());
setUuid(ready.getHostUuid());
setName(ready.getHostName());
}

verifyAgentArch(ready.getArch());
processManagementServerList(ready.getMsHostList(), ready.getLbAlgorithm(), ready.getLbCheckInterval());

logger.info("Ready command is processed for agent id = {}", getId());
logger.info("Ready command is processed for agent [id: {}, uuid: {}, name: {}]", getId(), getUuid(), getName());
}

private void verifyAgentArch(String arch) {
Expand Down
24 changes: 21 additions & 3 deletions api/src/main/java/com/cloud/agent/api/to/LoadBalancerTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,15 @@ public String getMonitorState() {
public static class CounterTO implements Serializable {
private static final long serialVersionUID = 2L;
private final Long id;
private final String uuid;
private final String name;
private final Counter.Source source;
private final String value;
private final String provider;

public CounterTO(Long id, String name, Counter.Source source, String value, String provider) {
public CounterTO(Long id, String uuid, String name, Counter.Source source, String value, String provider) {
this.id = id;
this.uuid = uuid;
this.name = name;
this.source = source;
this.value = value;
Expand All @@ -391,6 +393,10 @@ public Long getId() {
return id;
}

public String getUuid() {
return uuid;
}

public String getName() {
return name;
}
Expand All @@ -411,12 +417,14 @@ public String getProvider() {
public static class ConditionTO implements Serializable {
private static final long serialVersionUID = 2L;
private final Long id;
private final String uuid;
private final long threshold;
private final Condition.Operator relationalOperator;
private final CounterTO counter;

public ConditionTO(Long id, long threshold, Condition.Operator relationalOperator, CounterTO counter) {
public ConditionTO(Long id, String uuid, long threshold, Condition.Operator relationalOperator, CounterTO counter) {
this.id = id;
this.uuid = uuid;
this.threshold = threshold;
this.relationalOperator = relationalOperator;
this.counter = counter;
Expand All @@ -426,6 +434,10 @@ public Long getId() {
return id;
}

public String getUuid() {
return uuid;
}

public long getThreshold() {
return threshold;
}
Expand All @@ -442,15 +454,17 @@ public CounterTO getCounter() {
public static class AutoScalePolicyTO implements Serializable {
private static final long serialVersionUID = 2L;
private final long id;
private final String uuid;
private final int duration;
private final int quietTime;
private final Date lastQuietTime;
private AutoScalePolicy.Action action;
boolean revoked;
private final List<ConditionTO> conditions;

public AutoScalePolicyTO(long id, int duration, int quietTime, Date lastQuietTime, AutoScalePolicy.Action action, List<ConditionTO> conditions, boolean revoked) {
public AutoScalePolicyTO(long id, String uuid, int duration, int quietTime, Date lastQuietTime, AutoScalePolicy.Action action, List<ConditionTO> conditions, boolean revoked) {
this.id = id;
this.uuid = uuid;
this.duration = duration;
this.quietTime = quietTime;
this.lastQuietTime = lastQuietTime;
Expand All @@ -463,6 +477,10 @@ public long getId() {
return id;
}

public String getUuid() {
return uuid;
}

public int getDuration() {
return duration;
}
Expand Down
8 changes: 8 additions & 0 deletions api/src/main/java/com/cloud/agent/api/to/NfsTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.cloud.agent.api.to;

import com.cloud.storage.DataStoreRole;
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;

public class NfsTO implements DataStoreTO {

Expand All @@ -41,6 +42,13 @@ public NfsTO(String url, DataStoreRole role) {

}

@Override
public String toString() {
return String.format("NfsTO %s",
ReflectionToStringBuilderUtils.reflectOnlySelectedFields(
this, "uuid", "_url", "_role", "nfsVersion"));
}

@Override
public String getUrl() {
return _url;
Expand Down
8 changes: 8 additions & 0 deletions api/src/main/java/com/cloud/agent/api/to/S3TO.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.cloud.agent.api.LogLevel.Log4jLevel;
import com.cloud.storage.DataStoreRole;
import com.cloud.utils.storage.S3.ClientOptions;
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;

public final class S3TO implements ClientOptions, DataStoreTO {

Expand Down Expand Up @@ -68,6 +69,13 @@ public S3TO(final Long id, final String uuid, final String accessKey, final Stri

}

@Override
public String toString() {
return String.format("S3TO %s",
ReflectionToStringBuilderUtils.reflectOnlySelectedFields(
this, "id", "uuid", "bucketName"));
}

public Long getId() {
return this.id;
}
Expand Down
3 changes: 2 additions & 1 deletion api/src/main/java/com/cloud/agent/api/to/StorageFilerTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.cloud.agent.api.LogLevel;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.StoragePool;
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;

public class StorageFilerTO {
long id;
Expand Down Expand Up @@ -73,6 +74,6 @@ protected StorageFilerTO() {

@Override
public String toString() {
return new StringBuilder("Pool[").append(id).append("|").append(host).append(":").append(port).append("|").append(path).append("]").toString();
return String.format("Pool %s", ReflectionToStringBuilderUtils.reflectOnlySelectedFields(this, "id", "uuid", "host", "port", "path"));
}
}
8 changes: 8 additions & 0 deletions api/src/main/java/com/cloud/agent/api/to/SwiftTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.cloud.storage.DataStoreRole;
import com.cloud.utils.SwiftUtil;
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;

public class SwiftTO implements DataStoreTO, SwiftUtil.SwiftClientCfg {
Long id;
Expand All @@ -41,6 +42,13 @@ public SwiftTO(Long id, String url, String account, String userName, String key,
this.storagePolicy = storagePolicy;
}

@Override
public String toString() {
return String.format("SwiftTO %s",
ReflectionToStringBuilderUtils.reflectOnlySelectedFields(
this, "id", "account", "userName"));
}

public Long getId() {
return id;
}
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/com/cloud/network/Ipv6Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public interface Ipv6Service extends PluggableService, Configurable {

Pair<Integer, Integer> getUsedTotalIpv6SubnetForZone(long zoneId);

Pair<String, String> preAllocateIpv6SubnetForNetwork(long zoneId) throws ResourceAllocationException;
Pair<String, String> preAllocateIpv6SubnetForNetwork(DataCenter zone) throws ResourceAllocationException;

void assignIpv6SubnetToNetwork(String subnet, long networkId);

Expand Down
8 changes: 8 additions & 0 deletions api/src/main/java/com/cloud/network/NetworkProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.Mode;
import com.cloud.network.Networks.TrafficType;
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;

public class NetworkProfile implements Network {
private final long id;
Expand Down Expand Up @@ -384,4 +385,11 @@ public Integer getNetworkCidrSize() {
return networkCidrSize;
}

@Override
public String toString() {
return String.format("NetworkProfile %s",
ReflectionToStringBuilderUtils.reflectOnlySelectedFields(
this, "id", "uuid", "name", "networkOfferingId"));
}

}
4 changes: 4 additions & 0 deletions api/src/main/java/com/cloud/network/lb/LoadBalancingRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ public long getId() {
return lb.getId();
}

public LoadBalancer getLb() {
return lb;
}

public String getName() {
return lb.getName();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public interface RemoteAccessVpnService {

VpnUser addVpnUser(long vpnOwnerId, String userName, String password);

boolean removeVpnUser(long vpnOwnerId, String userName, Account caller);
boolean removeVpnUser(Account vpnOwner, String userName, Account caller);

List<? extends VpnUser> listVpnUsers(long vpnOwnerId, String userName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.util.List;

import com.cloud.user.Account;
import org.apache.cloudstack.api.command.user.region.ha.gslb.AssignToGlobalLoadBalancerRuleCmd;
import org.apache.cloudstack.api.command.user.region.ha.gslb.CreateGlobalLoadBalancerRuleCmd;
import org.apache.cloudstack.api.command.user.region.ha.gslb.DeleteGlobalLoadBalancerRuleCmd;
Expand All @@ -39,7 +40,7 @@ public interface GlobalLoadBalancingRulesService {

GlobalLoadBalancerRule updateGlobalLoadBalancerRule(UpdateGlobalLoadBalancerRuleCmd updateGslbCmd);

boolean revokeAllGslbRulesForAccount(com.cloud.user.Account caller, long accountId) throws com.cloud.exception.ResourceUnavailableException;
boolean revokeAllGslbRulesForAccount(com.cloud.user.Account caller, Account account) throws com.cloud.exception.ResourceUnavailableException;

/*
* methods for managing sites participating in global load balancing
Expand Down
3 changes: 3 additions & 0 deletions api/src/main/java/com/cloud/storage/StorageStats.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ public interface StorageStats {
* @return bytes capacity of the storage server
*/
public long getCapacityBytes();

Long getCapacityIops();
Long getUsedIops();
}
5 changes: 4 additions & 1 deletion api/src/main/java/com/cloud/vm/NicProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,9 @@ public void deallocate() {

@Override
public String toString() {
return String.format("NicProfile %s", ReflectionToStringBuilderUtils.reflectOnlySelectedFields(this, "id", "vmId", "deviceId", "broadcastUri", "reservationId", "iPv4Address"));
return String.format("NicProfile %s",
ReflectionToStringBuilderUtils.reflectOnlySelectedFields(
this, "id", "uuid", "vmId", "deviceId",
"broadcastUri", "reservationId", "iPv4Address"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ public class ApiConstants {
public static final String URL = "url";
public static final String USAGE_INTERFACE = "usageinterface";
public static final String USED_SUBNETS = "usedsubnets";
public static final String USED_IOPS = "usediops";
public static final String USER_DATA = "userdata";

public static final String USER_DATA_NAME = "userdataname";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@ public void execute() {
hostResponse.setResponseName(getCommandName());
this.setResponseObject(hostResponse);
} catch (Exception e) {
logger.debug("Failed to update host:" + getId(), e);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update host:" + getId() + "," + e.getMessage());
Host host = _entityMgr.findById(Host.class, getId());
logger.debug("Failed to update host: {} with id {}", host, getId(), e);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, String.format("Failed to update host: %s with id %d, %s", host, getId(), e.getMessage()));
}
}
}
Loading

0 comments on commit fadb39e

Please sign in to comment.