Skip to content

feat(event): emit events for ingress,svc,pod,node,crd#6099

Merged
k8s-ci-robot merged 43 commits intokubernetes-sigs:masterfrom
gofogo:feat-event-101
Mar 15, 2026
Merged

feat(event): emit events for ingress,svc,pod,node,crd#6099
k8s-ci-robot merged 43 commits intokubernetes-sigs:masterfrom
gofogo:feat-event-101

Conversation

@ivankatliarchuk
Copy link
Copy Markdown
Member

@ivankatliarchuk ivankatliarchuk commented Jan 11, 2026

What does it do ?

Added emit events for

  • pod
  • node
  • service
  • ingress
  • crd

Interesting statistic for this PR

┌──────────┬───────┐
│ Category │ Lines │
├──────────┼───────┤
│ Non-test │ +77   │
├──────────┼───────┤
│ Test     │ +737  │
├──────────┼───────┤
│ Docs     │ +5    │
├──────────┼───────┤
│ Ratio    │ 1:9.5 │
└──────────┴───────┘

Tested

Events emitted for sources
Screenshot 2026-01-11 at 13 11 07

Capture record errors
Screenshot 2026-01-11 at 13 27 18

Follow-up

  • emit metrics related to events
  • all sources support
  • more unit-tests
  • event TTL is not displayed correctly
  • when endpoints merged, event should be sent to multiple objects if multiple objects where involved

Motivation

Adding support for event emitting

More

  • Yes, this PR title follows Conventional Commits
  • Yes, I added unit tests
  • Yes, I updated end user documentation accordingly

require: #6076
require: #6119

ivankatliarchuk and others added 10 commits January 2, 2026 10:02
…t client creation

Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
…t client creation

Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
…t client creation

Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
…t client creation

Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
…t client creation

Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
…t client creation

Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
…t client creation

Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
…t client creation

Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 11, 2026
@ivankatliarchuk ivankatliarchuk marked this pull request as draft January 11, 2026 10:06
@k8s-ci-robot k8s-ci-robot requested a review from szuecs January 11, 2026 10:06
@k8s-ci-robot k8s-ci-robot added the controller Issues or PRs related to the controller label Jan 11, 2026
@k8s-ci-robot k8s-ci-robot requested a review from vflaux January 11, 2026 10:06
@k8s-ci-robot k8s-ci-robot added source size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 11, 2026
@coveralls
Copy link
Copy Markdown

coveralls commented Jan 11, 2026

Pull Request Test Coverage Report for Build 23117764731

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 125 unchanged lines in 10 files lost coverage.
  • Overall coverage increased (+0.007%) to 79.695%

Files with Coverage Reduction New Missed Lines %
utils.go 4 95.35%
fakes/provider.go 6 0.0%
events/types.go 6 90.44%
pod.go 9 95.52%
node.go 12 90.4%
ingress.go 13 88.42%
testutils/endpoint.go 15 68.57%
crd.go 18 69.05%
unstructured.go 20 82.28%
service.go 22 94.07%
Totals Coverage Status
Change from base Build 23116604893: 0.007%
Covered Lines: 16642
Relevant Lines: 20882

💛 - Coveralls

Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 11, 2026
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 16, 2026
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 16, 2026
ivankatliarchuk and others added 6 commits February 26, 2026 20:18
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
@ivankatliarchuk
Copy link
Copy Markdown
Member Author

/test pull-external-dns-unit-test

ivankatliarchuk and others added 5 commits March 12, 2026 09:00
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
@ivankatliarchuk
Copy link
Copy Markdown
Member Author

/test pull-external-dns-unit-test

Comment on lines +109 to +128
func TestEmit_RecordError(t *testing.T) {
refObj := &events.ObjectReference{}
changes := plan.Changes{
Create: []*endpoint.Endpoint{
endpoint.NewEndpoint("one.example.com", endpoint.RecordTypeA, "10.10.10.0").
WithRefObject(refObj),
},
UpdateNew: []*endpoint.Endpoint{
endpoint.NewEndpoint("two.example.com", endpoint.RecordTypeA, "10.10.10.1").
WithRefObject(refObj),
},
}
emitter := fake.NewFakeEventEmitter()

emitChangeEvent(emitter, changes, events.RecordError)

emitter.AssertCalled(t, "Add", events.NewEventFromEndpoint(changes.Create[0], events.ActionCreate, events.RecordError))
emitter.AssertCalled(t, "Add", events.NewEventFromEndpoint(changes.UpdateNew[0], events.ActionUpdate, events.RecordError))
emitter.AssertNumberOfCalls(t, "Add", 2)
}
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.

Why no test for ``Delete` changes too?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yep, looks like missed that gap. Deletes have unique behavior: the reason is overridden. On success they emit RecordDeleted (not RecordReady); on failure they emit RecordError. This is a deliberate branch that differs from Create/Update.

Restructured test, and added new sub-case to explicitly documents the contract

}
}

func TestMergeEndpoints_RefObjects(t *testing.T) {
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.

Why not test this in TestMergeEndpoints()?

Copy link
Copy Markdown
Member Author

@ivankatliarchuk ivankatliarchuk Mar 15, 2026

Choose a reason for hiding this comment

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

Same as #6099 (comment). This is cosmetics at the moment, but I share pros/cons for merging

Pros of merging:

  • One place to look for all MergeEndpoints behavior
  • Reduces test function count

Cons:

  • Table struct becomes a union with optional fields or changes entirely - hurts readability of the simple cases
  • assert.ElementsMatch can't verify RefObject: you'd need per-case assertion logic regardless
  • Mixes two concerns: target merging vs. metadata preservation after merge
  • TestMergeEndpointsLogging is already split out for the same reason (third concern: side effects)

TestMergeEndpoints owns output shape, TestMergeEndpoints_RefObjects owns metadata fidelity, TestMergeEndpointsLogging owns side effects. Each has its own assertion style that would conflict if combined.

}
}

func TestDedupSource_RefObjects(t *testing.T) {
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.

Why not include this in testDedupEndpoints()?

Copy link
Copy Markdown
Member Author

@ivankatliarchuk ivankatliarchuk Mar 15, 2026

Choose a reason for hiding this comment

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

Techically, it could be done. I could say this is more a preference how to unit tests in isolation, keep tests focused etc

The outcome is same --> Different concerns:

  • TestDedupEndpoints: which endpoints survive dedup (DNS name + target identity)
  • TestDedupSource_RefObjects: which metadata is preserved on the survivor (RefObject fidelity)
  • The expected field is different

When test cases start to require slightly different setup, you’ve crossed a concern boundary and should keep them in separate tests. In follow up TestDedupSource_RefObjects may become a bit more complex as well, as deduplicated endpoint may have multiple references to kubernets objects.

ivankatliarchuk and others added 3 commits March 15, 2026 18:56
Co-authored-by: vflaux <38909103+vflaux@users.noreply.github.com>
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
@ivankatliarchuk ivankatliarchuk requested a review from vflaux March 15, 2026 19:43
@vflaux
Copy link
Copy Markdown
Contributor

vflaux commented Mar 15, 2026

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 15, 2026
@ivankatliarchuk
Copy link
Copy Markdown
Member Author

/approve

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ivankatliarchuk

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 15, 2026
@k8s-ci-robot k8s-ci-robot merged commit e1f8484 into kubernetes-sigs:master Mar 15, 2026
18 checks passed
@ivankatliarchuk ivankatliarchuk deleted the feat-event-101 branch March 15, 2026 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. controller Issues or PRs related to the controller docs internal Issues or PRs related to internal code lgtm "Looks good to me", indicates that a PR is ready to be merged. provider Issues or PRs related to a provider size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. source

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants