buehler/dotnet-operator-sdk

[bug]: UHE when starting without connection to Kubernetes API server

vvitkovsky opened this issue · 2 comments

Describe the bug

If I start app with KubeOps while I don't have a connection to Kubernetes API server app just crash.

To reproduce

Start app with KubOps without a connection to Kubernetes API server

Expected behavior

Try to reconnect after some time

Screenshots

No response

Additional Context

UHE is here:
LeaderElector.cs

public async Task StartAsync(CancellationToken cancellationToken)
{
...
_operatorDeployment = (await _client.List<V1Deployment>(
            _namespace,
            new EqualsSelector("operator-deployment", _settings.Name))).FirstOrDefault();
...
}

As mentioned in #557, I don't think this is a real bug. When the application crashes because there is no connection to the Kubernetes API, Kubernetes will restart the application itself (automatic pod restart to match the manifest).

The leader elector is not the only part that accesses the Kubernetes API.

Hi Christoph,

Of course, app can be restarted with help of some other app - Kubentetes, OS etc., but this in only one place that just crash app if no connection, all other functionality (like watchers etc) works correctly and try to reconnect from time to time. This specific logic is needed only to apply your crds to Kubernetes API server, in most cases you don't even need this.

Anyway, even disabling this specific functionality with some log message in case of error will be better then just having an app crash, at least for my point of view. Or probably have some configuration parameter to disable such "risky" stuff like this if you really do not need that.

Best regards,
Victor