Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[bug]: ResourceWatcher stops working after leadership changes

See original GitHub issue

Describe the bug

When the leadership changes the ResourceWatcher throws an unobserved exception:

System.AggregateException: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. (Cannot access a disposed object.)
 ---> System.ObjectDisposedException: Cannot access a disposed object.
   at System.Reactive.Subjects.Subject`1.ThrowDisposed() in /_/Rx.NET/Source/src/System.Reactive/Subjects/Subject.cs:line 53
   at System.Reactive.Subjects.Subject`1.OnNext(T value) in /_/Rx.NET/Source/src/System.Reactive/Subjects/Subject.cs:line 141
   at KubeOps.Operator.Kubernetes.ResourceWatcher`1.OnException(Exception e)
   at k8s.Watcher`1.WatcherLoop(CancellationToken cancellationToken)
   at k8s.Watcher`1.<.ctor>b__9_0()

My suspicion is that this happens after calling the StartAsync again on the same instance after StopAsync.

The problem could be fixed by removing this line where the _reconnectHandler is disposed again outside of the previous if (!fromStop) clause.

To reproduce

Change the leadership from LeaderState.Leader to LeaderState.Candidate and back to LeaderState.Leader.

Expected behavior

The resource watcher should not stop watching after leadership changed.


No response

Additional Context

I can prepare a PR if you will confirm that the issue is legitimate. Could be related to #482.

Issue Analytics

  • State:closed
  • Created 8 months ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

tomasfabiancommented, Feb 6, 2023

Ok no problem if it is a hassle, we will upgrade our operator to v7.

buehlercommented, Feb 6, 2023

Hey @tomasfabian Hmm… are you not able to upgrade to 7? backporting is kind of a burden and I need more time to set up release/support branches for semantic release

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unhandled exception. System.NotSupportedException and ...
the operator project is run locally .. when a crd instance is created I get the notification ... Leadership state changed to: Leader....
Read more >
[Bug] Crusaders "Aura of Leadership" was does not work ...
The regenerative wards are still not working correctly and need to be recast in each zone/instance that is subject to healing mitigations.
Read more >
[Bug] Crusaders "Aura of Leadership" was does not work ...
You really should try recasting Aura of the Crusader and Blessing of the Paladin during combat when your stats are at their highest....
Read more >
Employees Are Losing Patience with Change Initiatives
Unfortunately, many leaders are approaching change management by applying short-term fixes, which is unsustainable. The Big Pitfall: Moving Too ...
Read more >
How Leaders Can Communicate Change to a Burned-Out ...
Navigate the pressures of organizational change with a communication technique called "chunking."
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found