-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Improve logging to include more identifiable information #9873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5bea350
e388764
bd59153
e1b9862
c4dcb2b
0bbc2cb
6b6ae03
7e0d848
d28ffab
2bf838b
20dbdaa
a639d3c
6557a3d
9146221
785c064
c197b83
b903796
7ba32df
499df2d
74124af
b47db16
1cb1962
f0ee884
8af0b13
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -132,6 +132,8 @@ | |||||
| ServerResource _resource; | ||||||
| Link _link; | ||||||
| Long _id; | ||||||
| String _uuid; | ||||||
| String _name; | ||||||
|
|
||||||
| Timer _timer = new Timer("Agent Timer"); | ||||||
| Timer certTimer; | ||||||
|
|
@@ -182,8 +184,10 @@ | |||||
| 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<>(); | ||||||
|
|
||||||
|
|
@@ -212,8 +216,9 @@ | |||||
| 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 = {}", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| ObjectUtils.defaultIfNull(_id, "new"), _uuid, _name, getResourceName(), | ||||||
| _shell.getZone(), _shell.getPod(), _shell.getWorkers(), host, _shell.getPort()); | ||||||
| } | ||||||
|
|
||||||
| public String getVersion() { | ||||||
|
|
@@ -377,11 +382,28 @@ | |||||
| } | ||||||
|
|
||||||
| 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(); | ||||||
|
|
@@ -594,17 +616,21 @@ | |||||
| 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) { | ||||||
|
|
@@ -860,15 +886,17 @@ | |||||
| 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) { | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -125,8 +125,9 @@ | |||||
| 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); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, String.format("Failed to update host: %s with id %d, %s", host, getId(), e.getMessage())); | ||||||
|
Check warning on line 130 in api/src/main/java/org/apache/cloudstack/api/command/admin/host/UpdateHostCmd.java
|
||||||
| } | ||||||
| } | ||||||
| } | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.