diff --git a/src/coordination/kubernetes/Akka.Coordination.KubernetesApi/Internal/KubernetesApiImpl.cs b/src/coordination/kubernetes/Akka.Coordination.KubernetesApi/Internal/KubernetesApiImpl.cs index 69d403e2f..8b998fd89 100644 --- a/src/coordination/kubernetes/Akka.Coordination.KubernetesApi/Internal/KubernetesApiImpl.cs +++ b/src/coordination/kubernetes/Akka.Coordination.KubernetesApi/Internal/KubernetesApiImpl.cs @@ -97,7 +97,7 @@ public async Task ReadOrCreateLeaseResource(string name) public async Task> UpdateLeaseResource( string leaseName, string ownerName, string version, DateTime? time = null) { - var cts = new CancellationTokenSource(_settings.BodyReadTimeout); + using var cts = new CancellationTokenSource(_settings.BodyReadTimeout); try { var leaseBody = new LeaseCustomResource( @@ -117,20 +117,20 @@ public async Task> UpdateLeaseResource( .ConfigureAwait(false); var newLease = operationResponse.Body; #else - var operationResponse = await _client.ReplaceNamespacedCustomObjectAsync( + var newLease = await _client.ReplaceNamespacedCustomObjectAsync( body: leaseBody, - @group: _crd.Group, + group: _crd.Group, version: _crd.Version, namespaceParameter: _namespace, plural: _crd.PluralName, name: leaseName, cancellationToken: cts.Token ); - var newLease = operationResponse; #endif - _log.Debug("Lease after update: {0}", JsonConvert.SerializeObject(newLease)); - return new Right(ToLeaseResource(newLease)); + var lease = ToLeaseResource(newLease); + _log.Debug("Lease after update: {0}", lease); + return new Right(lease); } catch (HttpOperationException e) { diff --git a/src/coordination/kubernetes/Akka.Coordination.KubernetesApi/KubernetesApi.cs b/src/coordination/kubernetes/Akka.Coordination.KubernetesApi/KubernetesApi.cs index 2658a2043..bfed70c9e 100644 --- a/src/coordination/kubernetes/Akka.Coordination.KubernetesApi/KubernetesApi.cs +++ b/src/coordination/kubernetes/Akka.Coordination.KubernetesApi/KubernetesApi.cs @@ -44,6 +44,9 @@ public LeaseResource(string? owner, string version, DateTime time) public DateTime Time { get; } public bool IsTaken => Owner != null; + + public override string ToString() + => $"{{owner:{Owner}, version:{Version}, time:{Time}}}"; } } \ No newline at end of file diff --git a/src/coordination/kubernetes/Akka.Coordination.KubernetesApi/KubernetesLease.cs b/src/coordination/kubernetes/Akka.Coordination.KubernetesApi/KubernetesLease.cs index 1ee245bc0..927a38a6a 100644 --- a/src/coordination/kubernetes/Akka.Coordination.KubernetesApi/KubernetesLease.cs +++ b/src/coordination/kubernetes/Akka.Coordination.KubernetesApi/KubernetesLease.cs @@ -66,7 +66,7 @@ public KubernetesLease(ExtendedActorSystem system, AtomicBoolean leaseTaken, Lea var client = new KubernetesApiImpl(system, kubernetesSettings); _timeout = _settings.TimeoutSettings.OperationTimeout; _leaseName = MakeDns1039Compatible(settings.LeaseName); - _leaseActor = system.ActorOf( + _leaseActor = system.SystemActorOf( LeaseActor.Props(client, settings, _leaseName, leaseTaken), $"KubernetesLease{LeaseCounter.GetAndIncrement()}"); diff --git a/src/coordination/kubernetes/Akka.Coordination.KubernetesApi/LeaseActor.cs b/src/coordination/kubernetes/Akka.Coordination.KubernetesApi/LeaseActor.cs index 3831ef931..29dfc4fd7 100644 --- a/src/coordination/kubernetes/Akka.Coordination.KubernetesApi/LeaseActor.cs +++ b/src/coordination/kubernetes/Akka.Coordination.KubernetesApi/LeaseActor.cs @@ -432,7 +432,7 @@ public LeaseActor(IKubernetesApi client, LeaseSettings settings, string leaseNam if (!(@event.FsmEvent is WriteResponse writeResponse)) return null; - // FIXME deal with failure from releasing the the lock, currently handled in whenUnhandled but could retry to remove: https://github.com/lightbend/akka-commercial-addons/issues/502 + // FIXME deal with failure from releasing the lock, currently handled in whenUnhandled but could retry to remove: https://github.com/lightbend/akka-commercial-addons/issues/502 var response = writeResponse.Response; var data = (OperationInProgress) @event.StateData; var who = data.ReplyTo; diff --git a/src/coordination/kubernetes/Akka.Coordination.KubernetesApi/Models/LeaseCustomResource.cs b/src/coordination/kubernetes/Akka.Coordination.KubernetesApi/Models/LeaseCustomResource.cs index d107212e7..ca2b17683 100644 --- a/src/coordination/kubernetes/Akka.Coordination.KubernetesApi/Models/LeaseCustomResource.cs +++ b/src/coordination/kubernetes/Akka.Coordination.KubernetesApi/Models/LeaseCustomResource.cs @@ -27,6 +27,9 @@ public LeaseCustomResource( Kind = "Lease"; ApiVersion = "akka.io/v1"; } + + public override string ToString() + => $"{{owner:{Spec.Owner}, version:{Metadata.ResourceVersion}, time:{Spec.Time}}}"; } internal sealed class LeaseSpec