Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5bea350
Improve logging to include more identifiable information for kvm plugin
vishesh92 Oct 17, 2024
e388764
Update logging for scaleio plugin
vishesh92 Oct 18, 2024
bd59153
Improve logging to include more identifiable information for default …
vishesh92 Oct 21, 2024
e1b9862
Improve logging to include more identifiable information for agent ma…
vishesh92 Oct 22, 2024
c4dcb2b
Fixup
vishesh92 Oct 23, 2024
0bbc2cb
Improve logging to include more identifiable information for Listeners
vishesh92 Oct 23, 2024
6b6ae03
fixup
vishesh92 Nov 13, 2024
7e0d848
Address comments
vishesh92 Nov 14, 2024
d28ffab
Replace ids with objects or uuids
vishesh92 Nov 27, 2024
2bf838b
fixup
vishesh92 Dec 3, 2024
20dbdaa
Improve logging to include more identifiable information for engine
vishesh92 Nov 12, 2024
a639d3c
Improve logging to include more identifiable information for server
vishesh92 Nov 14, 2024
6557a3d
Fixups in engine
vishesh92 Dec 9, 2024
9146221
Improve logging to include more identifiable information for plugins
vishesh92 Dec 16, 2024
785c064
Improve logging to include more identifiable information for Cmd classes
vishesh92 Dec 16, 2024
c197b83
Minor fixups
vishesh92 Dec 17, 2024
b903796
Merge branch '4.20' into improve-logging
vishesh92 Dec 23, 2024
7ba32df
Update remaining files
vishesh92 Dec 24, 2024
499df2d
Fixups
vishesh92 Dec 27, 2024
74124af
Merge branch '4.20' into improve-logging
vishesh92 Dec 27, 2024
b47db16
fixups
vishesh92 Dec 27, 2024
1cb1962
monir fixups
vishesh92 Dec 31, 2024
f0ee884
Address comments
vishesh92 Jan 2, 2025
8af0b13
Fix toString method for StorageFilterTO.java
vishesh92 Jan 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.info("Initialising agent [id: {}, uuid: {}, name: {}]", ObjectUtils.defaultIfNull(_id, ""), _uuid, _name);
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 = {}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.info("Agent [id = {}, uuid: {}, name: {}] : type = {} : zone = {} : pod = {} : workers = {} : host = {} : port = {}",
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
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 @@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.debug("Failed to update host: {} with id {}", host, getId(), e);
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