core: refactor lbaas util functions#3075
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
3d13181 to
ab2defc
Compare
|
Hi @kayrus: I don't have +2 powers here, so I'm just exercising my review judgement as a long time OpenStack maintainer and sharing my 0.02 cents of opinion. I think the intent to address bugs is good, but, i'd like to suggest a different approach. You should break this down into multiple commits - get Claude to do it. I know we don't apply the same commit standards here as we do in OpenStack or core Kubernetes projects; but, for the sake of maintainability, seeing single-intent commits is preferred. |
I asked for the same thing 😅 Must be an OpenStack thing... |
What this PR does / why we need it:
This is an experimental code refactoring using Claude AI as a development assistant. Each change was discussed and reviewed by me during the development process, it took about 6h in total. The refactoring reduces code duplication, fixes several bugs (missing metrics, potential panics, double observations), and optimizes API call patterns while preserving all existing functionality. All tests pass without modification. @zetaab @dulek @stephenfin I'd like you to review this as well. What do you think about such AI-assisted PRs?
Below is AI summary:
Key improvements
Reduced code duplication (-118 lines, ~15% reduction) - Extracted common patterns into reusable generic helpers:
executeAndWaitActive/executeExtractAndWaitActive- Centralizes metrics tracking, error handling, and LB wait logiclist/listWithUniqueResult- Standardizes pagination with early-exit optimizationgetSingleResource- Consistent single-resource retrieval with metricsFixed bugs and inconsistencies:
GetPools,GetL7policies,GetL7Rules,GetListenersByLoadBalancerID,getOctaviaVersionextraction error)DeleteListenerGetPoolByNamePerformance optimization:
GetPoolByListenernow uses direct listener Get instead of listing all pools (major API call reduction)listWithUniqueResultimplements early-exit when multiple results detected on first pageImproved consistency:
Better organization:
UpdatePoolandDeletePoolto correct section (Pool Operations, not Pool Member Operations)GetMembersbyPool→GetPoolMembers)Testing
go test ./pkg/util/openstack/...Files changed
pkg/util/openstack/loadbalancer.go- Main refactoringSpecial notes for reviewers:
Release note: