Skip to content

web: Small refactors - #9096

Merged
taylorsilva merged 7 commits into
masterfrom
small-fixes
Mar 5, 2025
Merged

taylorsilva merged 7 commits into
masterfrom
small-fixes

Conversation

@taylorsilva

@taylorsilva taylorsilva commented Mar 5, 2025 •

Copy link
Copy Markdown
Member

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

  • Remove unused query from GetPendingBuilds()
  • Add context aware functions to DB connection logger for more consistent logging from DB functions
  • Improve template asset caching when developing the web frontend

analytically and others added 7 commits March 5, 2025 14:43
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]>
@taylorsilva
taylorsilva requested a review from a team March 5, 2025 20:14
@taylorsilva taylorsilva changed the title web: various small fixes again web: Small refactors Mar 5, 2025
@taylorsilva
taylorsilva merged commit d82595f into master Mar 5, 2025
@taylorsilva
taylorsilva deleted the small-fixes branch March 5, 2025 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants