Repository navigation
web: Small refactors - #9096
Merged
Merged
web: Small refactors#9096
Conversation
1. Fixes improper use of defer Close(rows) inside loops in the JobsToSchedule method which would cause resource leaks, as deferred calls would only execute when the function returns, not at the end of loop iterations. 2. Removes redundant database query in GetPendingBuilds method that was re-fetching job information already available in the job struct. 3. Adds missing defer Close(rows) calls in multiple methods 4. Ensures proper error handling when scanning database rows. Signed-off-by: Mathias Bogaert <[email protected]> Co-authored-by: Taylor Silva <[email protected]>
This commit adds implementations for the context-aware methods in the logConn wrapper that were previously missing. The DbConn interface requires several context-aware methods (ExecContext, QueryContext, QueryRowContext, PrepareContext, BeginTx) which were not explicitly implemented in logConn. Without these implementations, any context-aware database operations would bypass the logging functionality, leading to inconsistent logging behavior. The fix ensures that all database operations, both with and without context, are properly logged. Additionally, this commit completes the logDbTx implementation by adding missing context methods to maintain consistency throughout the entire logging wrapper system. Signed-off-by: Mathias Bogaert <[email protected]> Co-authored-by: Taylor Silva <[email protected]>
Refactored the CleanUpInvalidTaskCaches function to use a single SQL operation instead of two separate queries. This change improves code readability and efficiency by using a subquery directly within the DELETE statement to identify and remove inactive task caches in a single database operation. Signed-off-by: Mathias Bogaert <[email protected]> Co-authored-by: Taylor Silva <[email protected]>
Signed-off-by: Mathias Bogaert <[email protected]> Co-authored-by: Taylor Silva <[email protected]>
- Apply early continue pattern in constrainingCandidates() to reduce nesting and improve code clarity - Pre-allocate slice capacity in orderJobs() to avoid multiple allocations during append operations These changes maintain identical functionality while making the code more maintainable and slightly more efficient. Signed-off-by: Mathias Bogaert <[email protected]> Co-authored-by: Taylor Silva <[email protected]>
The Get and Set methods of ContainerSpec incorrectly used strings.SplitN with arguments in the wrong order (separator and string were swapped). This bug would prevent proper parsing of environment variables for tracing propagation. - Fixed strings.SplitN call in Get method - Fixed strings.SplitN call in Set method Signed-off-by: Mathias Bogaert <[email protected]> Co-authored-by: Taylor Silva <[email protected]>
Fix several issues in pipeline cycle detection: - Reset visited state for each root job to prevent false positives - Replace numeric constants with JobState enum for better clarity - Ensure immediate error propagation when cycle is detected Signed-off-by: Mathias Bogaert <[email protected]> Co-authored-by: Taylor Silva <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes proposed by this PR
This PR makes a bunch of minor fixes and improvements across the atc package. All existing behaviour is still maintained here.
Release Notes
GetPendingBuilds()