-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Allow counters to be created with same name, provider and source as a deleted one #10223
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
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #10223 +/- ##
============================================
+ Coverage 17.56% 17.94% +0.38%
- Complexity 15500 15900 +400
============================================
Files 5899 5908 +9
Lines 527793 540565 +12772
Branches 64479 69702 +5223
============================================
+ Hits 92714 97026 +4312
- Misses 424653 432806 +8153
- Partials 10426 10733 +307
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@blueorangutan package |
|
@Pearl1594 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. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 12137 |
|
@blueorangutan test |
|
@rohityadavcloud a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
DaanHoogland
left a comment
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.
one comment,
Also the issue reported that deleteCounter doesn't work. Is that genuine?
engine/schema/src/main/resources/META-INF/db/schema-41910to41920.sql
Outdated
Show resolved
Hide resolved
|
[SF] Trillian test result (tid-12142)
|
engine/schema/src/main/resources/META-INF/db/schema-41910to41920.sql
Outdated
Show resolved
Hide resolved
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
engine/schema/src/main/resources/META-INF/db/schema-41910to41920.sql
Outdated
Show resolved
Hide resolved
|
@blueorangutan package |
|
@Pearl1594 |
@weizhouapache It allows to create a counter with same name provider and source - as long as the value is different. Is that not expected? |
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
…create-counters-dup
|
@blueorangutan package |
|
@Pearl1594 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. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 15406 |
|
@blueorangutan test |
|
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
[SF] Trillian Build Failed (tid-14641) |
|
@blueorangutan test |
|
@weizhouapache a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
[SF] Trillian test result (tid-14643)
|
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.
Pull Request Overview
This PR fixes a bug that prevented counters from being created with the same name, provider and source as a previously deleted counter. The fix involves modifying the database unique constraint to include the "removed" field and updating the counter creation logic to allow recreation of counters with matching properties when the original has been soft-deleted.
Key Changes:
- Modified database schema to change unique constraint from (provider, source, value) to (provider, source, value, removed)
- Updated counter creation validation to check for existing non-deleted counters only
- Refactored counter creation flow to separate creation and response generation
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| AutoScaleManagerImpl.java | Added validation logic and separated counter creation from response generation |
| schema-42100to42200.sql | Modified database unique constraint to include 'removed' field |
| cloud.idempotent_drop_unique_key.sql | Added new stored procedure for safely dropping unique keys |
| CounterDaoImpl.java | Added method to find counters by name, provider and value |
| CounterDao.java | Added interface method for the new search functionality |
| CreateCounterCmd.java | Refactored to separate creation and execution phases |
| AutoScaleService.java | Added getCounter method to service interface |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| @Override | ||
| @ActionEvent(eventType = EventTypes.EVENT_COUNTER_CREATE, eventDescription = "Creating a counter", async = true) | ||
| public Counter getCounter(long counterId) { | ||
| return counterDao.findById(counterId); | ||
| } |
Copilot
AI
Oct 14, 2025
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.
The getCounter method has incorrect event annotation. It should use EVENT_COUNTER_GET or similar since this is a read operation, not a create operation.
|
|
||
| CounterVO existingCounter = counterDao.findByNameProviderValue(name, value, provider.getName()); | ||
| if (existingCounter != null) { | ||
| throw new InvalidParameterValueException(String.format("Counter with name %s and value %s already exists. ", name,value)); |
Copilot
AI
Oct 14, 2025
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.
Missing space before 'value' parameter in the error message format string.
| throw new InvalidParameterValueException(String.format("Counter with name %s and value %s already exists. ", name,value)); | |
| throw new InvalidParameterValueException(String.format("Counter with name %s and value %s already exists. ", name, value)); |
rosi-shapeblue
left a comment
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.
LGTM. The PR fixes the initial bug and introduces correct behavior for counter re-creation.
Verification Checklist
- Pre-Fix Behavior – re-creation after deletion not possible FAIL (expected)
- Create counter PASS
- Delete counter PASS
- Recreate same counter after deletion PASS
- Duplicate creation with active value blocked PASS
- Same name with different value works PASS
- Verify listing shows multiple counters PASS
- Delete one and recreate again PASS
- DB entries properly marked as removed PASS
Detailed Test Results
Pre-Fix Behavior - re-creation after deletion not possible.
(localcloud) 🐱 > list counters name=Linux System CPU - percentage
{
"count": 1,
"counter": [
{
"id": "4e450db5-a8ba-11f0-86a0-1e00f00003ce",
"name": "Linux User CPU - percentage - native",
"provider": "Netscaler",
"source": "CPU",
"value": "1.3.6.1.4.1.2021.11.9.1"
}
]
}
(localcloud) 🐱 >
(localcloud) 🐱 > delete counter id=4e450db5-a8ba-11f0-86a0-1e00f00003ce
{
"success": true
}
(localcloud) 🐱 > list counters name=Linux System CPU - percentage
(localcloud) 🐱 >
(localcloud) 🐱 > create counter name="Linux System CPU - percentage" provider="Netscaler" source="SNMP" value="1.3.6.1.4.1.2021.11.10.0"
🙈 Error: (HTTP 530, error code 9999) Entity already exists
(localcloud) 🐱 >
Verification with Fix
1. Create counter - counter can be created
(localcloud) 🐱 > list counters name=Linux System CPU - percentage
(localcloud) 🐱 >
(localcloud) 🐱 > create counter name="Linux System CPU - percentage" provider="Netscaler" source="SNMP" value="1.3.6.1.4.1.2021.11.10.0"
{
"counter": {
"id": "20faa221-c51b-43be-96b2-b4fe8037b561",
"name": "Linux System CPU - percentage",
"provider": "Netscaler",
"source": "SNMP",
"value": "1.3.6.1.4.1.2021.11.10.0"
}
}
(localcloud) 🐱 > list counters name=Linux System CPU - percentage
{
"count": 1,
"counter": [
{
"id": "20faa221-c51b-43be-96b2-b4fe8037b561",
"name": "Linux System CPU - percentage",
"provider": "Netscaler",
"source": "SNMP",
"value": "1.3.6.1.4.1.2021.11.10.0"
}
]
}
2. Delete counter - counter is deleted
(localcloud) 🐱 > delete counter id=20faa221-c51b-43be-96b2-b4fe8037b561
{
"success": true
}
(localcloud) 🐱 > list counters name=Linux System CPU - percentage
(localcloud) 🐱 >
3. Recreate same counter after delete
(localcloud) 🐱 > create counter name="Linux System CPU - percentage" provider="Netscaler" source="SNMP" value="1.3.6.1.4.1.2021.11.10.0"
{
"counter": {
"id": "83209340-7e4b-4edc-9791-3d5d24920e85",
"name": "Linux System CPU - percentage",
"provider": "Netscaler",
"source": "SNMP",
"value": "1.3.6.1.4.1.2021.11.10.0"
}
}
4. Try duplicate creation - fails
(localcloud) 🐱 > create counter name="Linux System CPU - percentage" provider="Netscaler" source="SNMP" value="1.3.6.1.4.1.2021.11.10.0"
🙈 Error: (HTTP 431, error code 4350) Counter with name Linux System CPU - percentage and value 1.3.6.1.4.1.2021.11.10.0 already exists.
5. Create same name with different value - succeeds
(localcloud) 🐱 > create counter name="Linux System CPU - percentage" provider="Netscaler" source="SNMP" value="1.3.6.1.4.1.2021.11.12.0"
{
"counter": {
"id": "8a96b886-c533-4abb-b491-630014964947",
"name": "Linux System CPU - percentage",
"provider": "Netscaler",
"source": "SNMP",
"value": "1.3.6.1.4.1.2021.11.12.0"
}
}
6. Verify listing
(localcloud) 🐱 > list counters name=Linux System CPU - percentage
{
"count": 2,
"counter": [
{
"id": "8a96b886-c533-4abb-b491-630014964947",
"name": "Linux System CPU - percentage",
"provider": "Netscaler",
"source": "SNMP",
"value": "1.3.6.1.4.1.2021.11.12.0"
},
{
"id": "83209340-7e4b-4edc-9791-3d5d24920e85",
"name": "Linux System CPU - percentage",
"provider": "Netscaler",
"source": "SNMP",
"value": "1.3.6.1.4.1.2021.11.10.0"
}
]
}
7. Delete one and recreate it again - recreation succeeds
(localcloud) 🐱 > delete counter id=8a96b886-c533-4abb-b491-630014964947
{
"success": true
}
(localcloud) 🐱 > create counter name="Linux System CPU - percentage" provider="Netscaler" source="SNMP" value="1.3.6.1.4.1.2021.11.12.0"
{
"counter": {
"id": "b5cc257e-9958-4e6a-ad23-66a93936d7a4",
"name": "Linux System CPU - percentage",
"provider": "Netscaler",
"source": "SNMP",
"value": "1.3.6.1.4.1.2021.11.12.0"
}
}
8. DB Verification Deleted counters have removed timestamps.; Active counters have NULL in removed.
mysql> select id,name,value,removed from cloud.counter where name='Linux System CPU - percentage';
+-----+-------------------------------+--------------------------+---------------------+
| id | name | value | removed |
+-----+-------------------------------+--------------------------+---------------------+
| 2 | Linux System CPU - percentage | 1.3.6.1.4.1.2021.11.10.0 | 2025-10-14 13:11:08 |
| 121 | Linux System CPU - percentage | 1.3.6.1.4.1.2021.11.10.0 | 2025-10-14 13:52:41 |
| 122 | Linux System CPU - percentage | 1.3.6.1.4.1.2021.11.10.0 | NULL |
| 123 | Linux System CPU - percentage | 1.3.6.1.4.1.2021.11.12.0 | 2025-10-14 13:54:35 |
| 124 | Linux System CPU - percentage | 1.3.6.1.4.1.2021.11.12.0 | NULL |
+-----+-------------------------------+--------------------------+---------------------+
5 rows in set (0.00 sec)
|



Description
This PR fixes: #10043
Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
How did you try to break this feature and the system with this change?