Fix backpressure report #60

Closed
hurui200320 wants to merge 1 commits from fix/bp-report into feat-58-backpressure-reactive-streams
Member

During testing the cleverswarm image, I noticed that python adapter has an internal conflict when reporting backpressure:

2025-07-15 07:37:38,367 - root - INFO - 139968513025728:0.2.33 [*] Service Message Published to cleverthis.clevermicro.management, msg: b'{\n "version": 1,\n "serviceId": "x21vwlc7vcd5rjbxlex5u82j8",\n "taskId": "9nnss5kkj5wvpxng53ugfviq0",\n "maxAvailability": 100,\n "currentAvailability": 1.72,\n "requestType": "UPDATE"\n}'
2025-07-15 07:37:28,299 - root - INFO - 139968513025728:0.2.33 [*] Service Message Published to cleverthis.clevermicro.management, msg: b'{\n "version": 1,\n "serviceId": "x21vwlc7vcd5rjbxlex5u82j8",\n "taskId": "9nnss5kkj5wvpxng53ugfviq0",\n "maxAvailability": 100,\n "currentAvailability": 1.6666666666666667,\n "requestType": "UPDATE"\n}'
2025-07-15 07:37:18,229 - root - INFO - 139968513025728:0.2.33 [*] Service Message Published to cleverthis.clevermicro.management, msg: b'{\n "version": 1,\n "serviceId": "x21vwlc7vcd5rjbxlex5u82j8",\n "taskId": "9nnss5kkj5wvpxng53ugfviq0",\n "maxAvailability": 1,\n "currentAvailability": 1,\n "requestType": "IDLE"\n}'
2025-07-15 07:37:08,160 - root - INFO - 139968513025728:0.2.33 [*] Service Message Published to cleverthis.clevermicro.management, msg: b'{\n "version": 1,\n "serviceId": "x21vwlc7vcd5rjbxlex5u82j8",\n "taskId": "9nnss5kkj5wvpxng53ugfviq0",\n "maxAvailability": 100,\n "currentAvailability": 1.65,\n "requestType": "UPDATE"\n}'
2025-07-15 07:36:58,092 - root - INFO - 139968513025728:0.2.33 [*] Service Message Published to cleverthis.clevermicro.management, msg: b'{\n "version": 1,\n "serviceId": "x21vwlc7vcd5rjbxlex5u82j8",\n "taskId": "9nnss5kkj5wvpxng53ugfviq0",\n "maxAvailability": 100,\n "currentAvailability": 1.6533333333333333,\n "requestType": "UPDATE"\n}'

Sometimes it reports the correct bp message with integer value, which is corresponding to the remaining available from the counter. Sometimes it reports the CPU usage as availability in a float form.

This PR aims to fix the issue and also update the reporting message (changes in ticket clevermicro/management-service#14). This PR contains the following changes:

  • Remove the loop for monitoring the CPU usage, now the loop does periodically report of the availability counter with no condition
  • Report availability change when the counter changes, this aligns the latest java adapter implementation (ref: clevermicro/amq-adapter-java#37)
  • Update the reporting message to remove max availability and request type fields
  • Update unit tests, fix or disable the broken ones

This PR is part of the efforts for ticket clevermicro/amq-adapter-python#58 to integrate clevermicro with cleverswarm.

During testing the cleverswarm image, I noticed that python adapter has an internal conflict when reporting backpressure: ``` 2025-07-15 07:37:38,367 - root - INFO - 139968513025728:0.2.33 [*] Service Message Published to cleverthis.clevermicro.management, msg: b'{\n "version": 1,\n "serviceId": "x21vwlc7vcd5rjbxlex5u82j8",\n "taskId": "9nnss5kkj5wvpxng53ugfviq0",\n "maxAvailability": 100,\n "currentAvailability": 1.72,\n "requestType": "UPDATE"\n}' 2025-07-15 07:37:28,299 - root - INFO - 139968513025728:0.2.33 [*] Service Message Published to cleverthis.clevermicro.management, msg: b'{\n "version": 1,\n "serviceId": "x21vwlc7vcd5rjbxlex5u82j8",\n "taskId": "9nnss5kkj5wvpxng53ugfviq0",\n "maxAvailability": 100,\n "currentAvailability": 1.6666666666666667,\n "requestType": "UPDATE"\n}' 2025-07-15 07:37:18,229 - root - INFO - 139968513025728:0.2.33 [*] Service Message Published to cleverthis.clevermicro.management, msg: b'{\n "version": 1,\n "serviceId": "x21vwlc7vcd5rjbxlex5u82j8",\n "taskId": "9nnss5kkj5wvpxng53ugfviq0",\n "maxAvailability": 1,\n "currentAvailability": 1,\n "requestType": "IDLE"\n}' 2025-07-15 07:37:08,160 - root - INFO - 139968513025728:0.2.33 [*] Service Message Published to cleverthis.clevermicro.management, msg: b'{\n "version": 1,\n "serviceId": "x21vwlc7vcd5rjbxlex5u82j8",\n "taskId": "9nnss5kkj5wvpxng53ugfviq0",\n "maxAvailability": 100,\n "currentAvailability": 1.65,\n "requestType": "UPDATE"\n}' 2025-07-15 07:36:58,092 - root - INFO - 139968513025728:0.2.33 [*] Service Message Published to cleverthis.clevermicro.management, msg: b'{\n "version": 1,\n "serviceId": "x21vwlc7vcd5rjbxlex5u82j8",\n "taskId": "9nnss5kkj5wvpxng53ugfviq0",\n "maxAvailability": 100,\n "currentAvailability": 1.6533333333333333,\n "requestType": "UPDATE"\n}' ``` Sometimes it reports the correct bp message with integer value, which is corresponding to the remaining available from the counter. Sometimes it reports the CPU usage as availability in a float form. This PR aims to fix the issue and also update the reporting message (changes in ticket clevermicro/management-service#14). This PR contains the following changes: + Remove the loop for monitoring the CPU usage, now the loop does periodically report of the availability counter with no condition + Report availability change when the counter changes, this aligns the latest java adapter implementation (ref: clevermicro/amq-adapter-java#37) + Update the reporting message to remove max availability and request type fields + Update unit tests, fix or disable the broken ones This PR is part of the efforts for ticket clevermicro/amq-adapter-python#58 to integrate clevermicro with cleverswarm.
hurui200320 self-assigned this 2025-07-15 07:47:33 +00:00
hurui200320 added 1 commit 2025-07-15 07:47:35 +00:00
fix(General): fix availability report
/ build-and-push (push) Successful in 1m21s
Unit test coverage / pytest (push) Failing after 1m27s
Unit test coverage / pytest (pull_request) Failing after 1m17s
45941de6b1
Remove the loop for monitoring the CPU usage, adopt changes in the management service for the

reporting message format, update the timing for sending out report, similar to java adapter.

ISSUES RELATED: clevermicro/amq-adapter-python#58
hurui200320 requested review from stanislav.hejny 2025-07-15 07:47:58 +00:00
hurui200320 added a new dependency 2025-07-15 07:48:29 +00:00

Coverage is 79%

Coverage is 79%
hurui200320 added a new dependency 2025-07-15 07:48:53 +00:00
Member

I have adopted and applied the mentioned changes individually and selectively to ensure that the intended functionality allowing application to set the backpressure/currently available value and that it will still trigger correct even reporting periodicwally

I have adopted and applied the mentioned changes individually and selectively to ensure that the intended functionality allowing application to set the backpressure/currently available value and that it will still trigger correct even reporting periodicwally
stanislav.hejny closed this pull request 2025-07-23 17:46:50 +00:00
Some checks are pending
/ build-and-push (push) Successful in 1m21s
Unit test coverage / pytest (push) Failing after 1m27s
Unit test coverage / pytest (pull_request) Failing after 1m17s

Pull request closed

Sign in to join this conversation.
No Reviewers
No Label
3 Participants
Notifications
Due Date
No due date set.
Reference: clevermicro/amq-adapter-python#60