Skip to content

Add new config (non-dynamic) for agent connections monitor thread, and keep timeunit to secs (in sync with the earlier Wait config)#10525

Merged
DaanHoogland merged 3 commits into
apache:4.20from
shapeblue:agent-connections-monitor-in-secs
Apr 28, 2025
Merged

Add new config (non-dynamic) for agent connections monitor thread, and keep timeunit to secs (in sync with the earlier Wait config)#10525
DaanHoogland merged 3 commits into
apache:4.20from
shapeblue:agent-connections-monitor-in-secs

Conversation

@sureshanaparti

@sureshanaparti sureshanaparti commented Mar 7, 2025

Copy link
Copy Markdown
Contributor

Description

This PR adds new config 'agent.connections.monitor.interval' (non-dynamic) to monitor and cleanup new agent connections, instead of using 'Wait' which is dynamic, and updates the monitor thread timeunit to secs, in sync with the earlier Wait config.

New agent connections monitor thread introduced here: #9840

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • build/CI
  • test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

@sureshanaparti

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@sureshanaparti sureshanaparti added this to the 4.20.1 milestone Mar 7, 2025
@blueorangutan

Copy link
Copy Markdown

@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@codecov

codecov Bot commented Mar 7, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 0% with 15 lines in your changes missing coverage. Please review.

Project coverage is 16.01%. Comparing base (b8359e8) to head (448361b).
Report is 39 commits behind head on 4.20.

Files with missing lines Patch % Lines
...java/com/cloud/agent/manager/AgentManagerImpl.java 0.00% 15 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               4.20   #10525   +/-   ##
=========================================
  Coverage     16.00%   16.01%           
- Complexity    13104    13107    +3     
=========================================
  Files          5651     5651           
  Lines        495841   495840    -1     
  Branches      60044    60042    -2     
=========================================
+ Hits          79365    79384   +19     
+ Misses       407613   407592   -21     
- Partials       8863     8864    +1     
Flag Coverage Δ
uitests 4.00% <ø> (ø)
unittests 16.85% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 12699

@sureshanaparti

Copy link
Copy Markdown
Contributor Author

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@sureshanaparti a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian Build Failed (tid-12616)

@sureshanaparti sureshanaparti marked this pull request as ready for review March 10, 2025 12:27
@sureshanaparti

Copy link
Copy Markdown
Contributor Author

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@sureshanaparti a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@DaanHoogland DaanHoogland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

clgtm

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-12633)
Environment: kvm-ol8 (x2), Advanced Networking with Mgmt server ol8
Total time taken: 56917 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr10525-t12633-kvm-ol8.zip
Smoke tests completed. 140 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
ContextSuite context=TestSharedNetworkWithConfigDrive>:setup Error 1521.08 test_network.py

@Pearl1594 Pearl1594 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CLGTM

@shwstppr shwstppr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@sureshanaparti sorry it was my mistake considering wait config in minutes but can we also add the following change to fix cleanup time in seconds in the task and some optimisation. I'm happy to open a separate PR if needed

diff --git a/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java b/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java
index 818a3c5a23..1504af702b 100644
--- a/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java
+++ b/engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java
@@ -51,8 +51,8 @@ import org.apache.cloudstack.framework.jobs.AsyncJobExecutionContext;
 import org.apache.cloudstack.managed.context.ManagedContextRunnable;
 import org.apache.cloudstack.outofbandmanagement.dao.OutOfBandManagementDao;
 import org.apache.cloudstack.utils.identity.ManagementServerNode;
-import org.apache.commons.collections.MapUtils;
 import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;
+import org.apache.commons.collections.MapUtils;
 import org.apache.commons.lang3.BooleanUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.logging.log4j.ThreadContext;
@@ -1859,25 +1859,19 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
             logger.trace("Agent New Connections Monitor is started.");
             final int cleanupTime = Wait.value();
             Set<Map.Entry<String, Long>> entrySet = newAgentConnections.entrySet();
-            long cutOff = System.currentTimeMillis() - (cleanupTime * 60 * 1000L);
-            if (logger.isDebugEnabled()) {
-                List<String> expiredConnections = newAgentConnections.entrySet()
-                        .stream()
-                        .filter(e -> e.getValue() <= cutOff)
-                        .map(Map.Entry::getKey)
-                        .collect(Collectors.toList());
-                logger.debug(String.format("Currently %d active new connections, of which %d have expired - %s",
-                        entrySet.size(),
-                        expiredConnections.size(),
-                        StringUtils.join(expiredConnections)));
-            }
-            for (Map.Entry<String, Long> entry : entrySet) {
-                if (entry.getValue() <= cutOff) {
-                    if (logger.isTraceEnabled()) {
-                        logger.trace(String.format("Cleaning up new agent connection for %s", entry.getKey()));
-                    }
-                    newAgentConnections.remove(entry.getKey());
-                }
+            long cutOff = System.currentTimeMillis() - (cleanupTime * 1000L);
+            List<String> expiredConnections = newAgentConnections.entrySet()
+                    .stream()
+                    .filter(e -> e.getValue() <= cutOff)
+                    .map(Map.Entry::getKey)
+                    .collect(Collectors.toList());
+            logger.debug("Currently {} active new connections, of which {} have expired - {}",
+                    entrySet.size(),
+                    expiredConnections.size(),
+                    StringUtils.join(expiredConnections));
+            for (String connection : expiredConnections) {
+                logger.trace("Cleaning up new agent connection for {}", connection);
+                newAgentConnections.remove(connection);
             }
         }
     }

Co-authored-by: abhishek.mrt22@gmail.com
@sureshanaparti

Copy link
Copy Markdown
Contributor Author

@sureshanaparti sorry it was my mistake considering wait config in minutes but can we also add the following change to fix cleanup time in seconds in the task and some optimisation. I'm happy to open a separate PR if needed

updated @shwstppr, missed this, thanks for pointing out.

@sureshanaparti

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 12804

@Pearl1594 Pearl1594 moved this to In Progress in ACS 4.20.1 Mar 17, 2025
@Pearl1594

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@Pearl1594 a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian Build Failed (tid-12731)

@sureshanaparti

Copy link
Copy Markdown
Contributor Author

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@sureshanaparti a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian Build Failed (tid-12785)

@sureshanaparti

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✖️ el8 ✖️ el9 ✔️ debian ✖️ suse15. SL-JID 13031

@sureshanaparti

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 13035

@sureshanaparti

Copy link
Copy Markdown
Contributor Author

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@sureshanaparti a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-12976)
Environment: kvm-ol8 (x2), Advanced Networking with Mgmt server ol8
Total time taken: 53944 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr10525-t12976-kvm-ol8.zip
Smoke tests completed. 141 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

@DaanHoogland

Copy link
Copy Markdown
Contributor

@sureshanaparti @Pearl1594 , I added needs-testing to this PR, but I am not really convinced if we need to and how. Can you advise?

@sureshanaparti

Copy link
Copy Markdown
Contributor Author

@sureshanaparti @Pearl1594 , I added needs-testing to this PR, but I am not really convinced if we need to and how. Can you advise?

@DaanHoogland Update Wait config, to say 120 secs, enable trace log and check for the log "Agent New Connections Monitor is started", it has to be logged every 120 secs.

@sureshanaparti

Copy link
Copy Markdown
Contributor Author

@blueorangutan package

@sureshanaparti

sureshanaparti commented Apr 28, 2025

Copy link
Copy Markdown
Contributor Author

@sureshanaparti @Pearl1594 , I added needs-testing to this PR, but I am not really convinced if we need to and how. Can you advise?

@DaanHoogland Update Wait config, to say 120 secs, enable trace log and check for the log "Agent New Connections Monitor is started", it has to be logged every 120 secs.

@DaanHoogland The agent connections monitor task required restart, I've updated with new config 'agent.connections.monitor.interval' (non-dynamic) to monitor and cleanup new agent connections, instead of using 'Wait' which is dynamic.

@blueorangutan

Copy link
Copy Markdown

@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@sureshanaparti sureshanaparti changed the title Updated agent connections monitor thread timeunit to secs, in sync with the Wait config. Add new config (non-dynamic) for agent connections monitor thread, and keep timeunit to secs (in sync with the earlier Wait config) Apr 28, 2025
@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✖️ debian ✔️ suse15. SL-JID 13200

@DaanHoogland

Copy link
Copy Markdown
Contributor

tested:
set ‘agent.connections.monitor.interval’ to 59 seconds and had to restart to see it effected,
set ‘wait’ to 61 seconds, no restart adviced,
'Agent New Connections Monitor is started’ messages apeared aproximately every 59 seconds.

@DaanHoogland DaanHoogland merged commit 9f22960 into apache:4.20 Apr 28, 2025
@github-project-automation github-project-automation Bot moved this from In Progress to Done in ACS 4.20.1 Apr 28, 2025
@DaanHoogland DaanHoogland deleted the agent-connections-monitor-in-secs branch April 28, 2025 13:32
dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request Jun 19, 2025
…d keep timeunit to secs (in sync with the earlier Wait config) (apache#10525)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants