Skip to content

Conversation

@jasonopslevel
Copy link
Contributor

@jasonopslevel jasonopslevel commented Jan 21, 2026

Issues

This fixes some security / correctness issues.

All three P0 bugs are fixed:                                                                                                                                                                                                               
  ┌──────────────────────────┬──────────────────────────────────┬──────────────────────────────┐                                                                                                                                                   
  │           Bug            │               File               │             Fix              │                                                                                                                                                   
  ├──────────────────────────┼──────────────────────────────────┼──────────────────────────────┤                                                                                                                                                   
  │ Elapsed time never reset │ opslevelAppendLogProcessor.go:62 │ time.Since(time.Now()) → 0   │                                                                                                                                                   
  ├──────────────────────────┼──────────────────────────────────┼──────────────────────────────┤                                                                                                                                                   
  │ Hardcoded image version  │ k8s.go:208                       │ Use ImageTagVersion variable │                                                                                                                                                   
  ├──────────────────────────┼──────────────────────────────────┼──────────────────────────────┤                                                                                                                                                   
  │ Memory calculation typo  │ k8s_config.go:46                 │ 1024*1204 → 1024*1024        │                                                                                                                                                   
  └──────────────────────────┴──────────────────────────────────┴──────────────────────────────┘ 
Both P1 bugs are fixed:                                                                                                                                                                                                                    
  ┌────────────────────────────┬───────────────────┬───────────────────────────────────────────────────────────────────────────┐                                                                                                                   
  │            Bug             │       File        │                                    Fix                                    │                                                                                                                   
  ├────────────────────────────┼───────────────────┼───────────────────────────────────────────────────────────────────────────┤                                                                                                                   
  │ Defer before error check   │ k8s.go:299-324    │ Moved defer after error check so cleanup only runs on successful creation │                                                                                                                   
  ├────────────────────────────┼───────────────────┼───────────────────────────────────────────────────────────────────────────┤                                                                                                                   
  │ Race condition on isLeader │ leaderElection.go │ Added sync.RWMutex with setLeader()/getLeader() for thread-safe access    │                                                                                                                   
  └────────────────────────────┴───────────────────┴───────────────────────────────────────────────────────────────────────────┘      

Changelog

  • List your changes here
  • Make a changie entry

Tophatting

jasonopslevel and others added 4 commits January 21, 2026 09:43
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix elapsed time reset in opslevelAppendLogProcessor.go: time.Since(time.Now())
  always returns ~0, so elapsed never reset. Changed to `s.elapsed = 0`
- Use dynamic ImageTagVersion in k8s.go instead of hardcoded v2024.1.3 for the
  init container image to prevent version mismatches
- Fix memory calculation typo in k8s_config.go: 1024*1204 → 1024*1024
  (was allocating ~17% more memory than intended)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Move defer cleanup after error checks in k8s.go Run() method
  Previously, defer was called before error check, causing delete
  attempts on failed/nil resources
- Add sync.RWMutex protection for isLeader variable in leaderElection.go
  The variable was accessed from multiple goroutines without synchronization
  Added setLeader()/getLeader() functions for thread-safe access

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Tests added:
- TestSetLeaderGetLeader: basic setLeader/getLeader functionality
- TestSetLeaderGetLeader_ConcurrentAccess: race condition verification
- TestSetLeaderGetLeader_ConcurrentReadWrite: simulates callback pattern
- TestDeleteConfigMap_NilSafe, TestDeletePDB_NilSafe, TestDeletePod_NilSafe
- TestGetConfigMapObject, TestGetPBDObject: verify object creation
- TestDeleteFunctions_RequireClientset: documents expected behavior

Additional fixes:
- Add nil guards to DeleteConfigMap, DeletePDB, DeletePod for defensive safety
- Fix log message typo in DeletePDB ("configmap" -> "pod disruption budget")

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
{
Name: "helper",
Image: "public.ecr.aws/opslevel/opslevel-runner:v2024.1.3", // TODO: fmt.Sprintf("public.ecr.aws/opslevel/opslevel-runner:v%s", ImageTagVersion),
Image: fmt.Sprintf("public.ecr.aws/opslevel/opslevel-runner:v%s", ImageTagVersion),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goreleaser config doesn't explicitly set ldflags, but goreleaser has default behavior that automatically injects:

-X main.version={{.Version}}
-X main.commit={{.Commit}}
-X main.date={{.Date}}

@@ -0,0 +1,44 @@
# SQLite databases
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trying out using beads. This adds a bunch of boilerplate. I can do in a separate MR, but the actual fixes are relatively small.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants