Skip to content

refactor: replace abandoned github.com/imkira/go-observer dependency with internal observer package - #7064

Merged
amartinezfayo merged 3 commits into
spiffe:mainfrom
mvanhorn:fix/6893-replace-imkira-go-observer
Jul 2, 2026
Merged

amartinezfayo merged 3 commits into
spiffe:mainfrom
mvanhorn:fix/6893-replace-imkira-go-observer

Conversation

@mvanhorn

Copy link
Copy Markdown
Contributor

Summary

Removes the abandoned github.com/imkira/go-observer dependency and replaces it with a minimal internal pkg/common/observer package implementing the API surface SPIRE actually uses: NewProperty, Property.Value/Update, and Stream.Value/Changes/Next/WaitNext/Clone. No behavior change for the agent manager, agent bundle cache, or the agent/server SVID rotators that consume it.

Why this matters

#6893 flagged imkira/go-observer as likely abandoned: last release in 2016, last commits on main ~3 years ago, and the untagged v2 module is itself 3 years stale. That leaves SPIRE's supply chain carrying a dependency with no realistic path for security patches or Go-compatibility fixes. Rather than migrating to the equally unmaintained v2, this removes the dependency entirely; the used API surface is ~120 lines of mutex+channel code that fits SPIRE's pkg/common/ convention.

The implementation uses a linked list of immutable states: each stream holds a pointer into the list and the property only retains the head node, so memory stays bounded by what live streams can still reach (matching the original library's design), Update is O(1), and there is no stream registry to leak when subscribers disconnect.

Testing

Unit tests in pkg/common/observer/observer_test.go cover value propagation, multiple streams, clone semantics, skipped-update coalescing via WaitNext, and concurrent update/observe. go build ./... and the existing agent/server rotator + bundle cache test suites pass unchanged. go mod tidy drops the module from go.mod/go.sum.

Pull Request check list

  • Commit conforms to CONTRIBUTING.md?
  • Proper tests/regressions included?
  • Documentation updated?

Affected functionality

Internal observable-property plumbing: pkg/agent/manager, pkg/agent/manager/cache, and the agent/server SVID rotators.

Description of change

See Summary above. All commits carry DCO sign-off.

Which issue this PR fixes

fixes #6893

mvanhorn added 2 commits June 11, 2026 01:17
…with internal observer package

Fixes spiffe#6893

Signed-off-by: Matt Van Horn <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR removes the external github.com/imkira/go-observer dependency by introducing an internal pkg/common/observer package and updating agent/server SVID rotator code to use it.

Changes:

  • Added new internal pkg/common/observer implementation and unit tests.
  • Updated agent/server rotator and related code to import the internal observer package.
  • Removed github.com/imkira/go-observer from go.mod/go.sum.

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pkg/common/observer/observer.go Introduces internal observer Property/Stream implementation to replace external dependency.
pkg/common/observer/observer_test.go Adds tests validating observer semantics (updates, blocking, cloning).
pkg/server/svid/rotator.go Switches server rotator to internal observer import.
pkg/server/svid/rotator_config.go Switches server rotator config to internal observer import.
pkg/server/svid/rotator_test.go Switches server rotator tests to internal observer import.
pkg/agent/svid/rotator.go Switches agent rotator to internal observer import.
pkg/agent/svid/rotator_config.go Switches agent rotator config to internal observer import.
pkg/agent/svid/rotator_test.go Switches agent rotator tests to internal observer import.
pkg/agent/manager/manager.go Switches manager to internal observer import.
pkg/agent/manager/cache/bundle_cache.go Switches bundle cache to internal observer import.
go.mod Removes external go-observer dependency.
go.sum Removes checksum entries for external go-observer.

Comment thread pkg/common/observer/observer.go Resolved
Comment thread pkg/common/observer/observer.go Resolved
Comment thread pkg/common/observer/observer.go Resolved
Comment thread pkg/common/observer/observer_test.go Resolved
Comment thread pkg/common/observer/observer_test.go Resolved
amartinezfayo
amartinezfayo previously approved these changes Jun 30, 2026

@amartinezfayo amartinezfayo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you @mvanhorn for this contribution, it looks great!
Could you resolve the merge conflicts in go.mod/go.sum so we can merge this?

@MarcosDY MarcosDY added this to the 1.15.2 milestone Jul 2, 2026
Signed-off-by: Agustín Martínez Fayó <[email protected]>

# Conflicts:
#	go.mod
#	go.sum
@amartinezfayo
amartinezfayo added this pull request to the merge queue Jul 2, 2026
Merged via the queue into spiffe:main with commit fc9f1ac Jul 2, 2026
53 checks passed
@kerlenton kerlenton mentioned this pull request Aug 19, 2026
3 tasks done
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.

Usage of github.com/imkira/go-observer

4 participants