Fix hostname parsing and improve decommission process#773
Conversation
tomach
left a comment
There was a problem hiding this comment.
👍 nice work! maybe in the tests, it might be safer to call extractNodeName() directly instead of re-implementing the parsing logic? then the tests will break if the function ever changes unexpectedly.
| } | ||
| } | ||
|
|
||
| func TestSplitHostname(t *testing.T) { |
There was a problem hiding this comment.
Isn't this already tested by the test for extractNodeName as the splitHostname function is used there already?
There was a problem hiding this comment.
Good point. splitHostname() is indeed called within extractNodeName(), so it is covered indirectly. I'd still lean toward keeping it for clarity and explicitly testing the helper in isolation.
There was a problem hiding this comment.
Shouldn't the splitHostname() NOT be called anymore as its supersede by extractHostName? If so, testing it dedicated may not make any sense. Not sure about Go, but can this method then be even declared private?
There was a problem hiding this comment.
Actually, I'd remove the splitHostName method at all and inline the split call. Any tests related to this method is testing the library split method (which doesn't make sense, this is tested elsewhere already) rather than any application logic.
There was a problem hiding this comment.
agreed. it makes sense to inline the call and remove both the function and the dedicated test.
| } | ||
| } | ||
|
|
||
| func TestSplitHostname(t *testing.T) { |
There was a problem hiding this comment.
Good point. splitHostname() is indeed called within extractNodeName(), so it is covered indirectly. I'd still lean toward keeping it for clarity and explicitly testing the helper in isolation.
d64c72e to
79cd722
Compare
4fa5486 to
bf7bfad
Compare
bf7bfad to
04fe731
Compare
Summary of changes
Added
Persistent Logging: Dual logging to both STDOUT and persistent file with automatic rotation
--log-fileCLI flag (default:/resource/heapdump/dc_util.log)PostStart Hook Detection: Intelligent detection of StatefulSet PostStart hooks
dc_util --reset-routingNEW_PRIMARIESrouting allocation could not be reliably reset-reset-routing) and double dash (--reset-routing) flag formatsSingle Node Cluster Detection: Automatic detection and handling of single node clusters
Configurable Lock File Path: New
--lock-fileCLI flag/resource/heapdump/dc_util.lockEnhanced Flag Support: Improved command-line flag handling
-reset-routingand--reset-routingformats now supportedMulti-Architecture Support: Automatic CPU architecture detection in hook configurations
dc_util-linux-amd64ordc_util-linux-arm64)Changed
Routing Allocation Logic: Enhanced PreStop process with PostStart hook detection
Replica Count Handling: Improved logic for different cluster sizes
Function Signatures: Updated internal functions to support configurable paths
createLockFile()now accepts lock file path parameterremoveLockFile()now accepts lock file path parameterlockFileExists()now accepts lock file path parameterhandleResetRouting()now accepts lock file path parameterImproved
Logging Experience: Comprehensive logging improvements
Documentation: Extensively updated README.md
Testing: Comprehensive test coverage for all new features
TestHasPostStartHookWithResetRouting: PostStart hook detection with various scenariosTestPostStopRoutingAllocationIntegration: Integration tests for routing allocation logicTestLoggingIntegration: Dual logging functionality verificationTestLogRotation: File rotation behavior validationTestSingleNodeClusterBehavior: Single node cluster detection testsTestReplicaCountBehavior: Comprehensive replica count handling testsChecklist
CHANGES.rst