Skip to content

Commit 5edb9c9

Browse files
authored
fix(lease): reworks the previous fix addressing renewal issues (#1105)
Signed-off-by: Nathan Klick <[email protected]>
1 parent 1297cb5 commit 5edb9c9

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

docs/content/User/StepByStepGuide.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## Advanced User Guide
2+
23
For those who would like to have more control or need some customized setups, here are some step by step instructions of how to setup and deploy a solo network.
4+
35
### Setup Kubernetes cluster
46

57
#### Remote cluster
@@ -28,6 +30,7 @@ Then run the following command to set the kubectl context to the new cluster:
2830
```bash
2931
kind create cluster -n "${SOLO_CLUSTER_NAME}"
3032
```
33+
3134
Example output
3235

3336
```
@@ -48,7 +51,6 @@ Thanks for using kind! 😊
4851

4952
You may now view pods in your cluster using `k9s -A` as below:
5053

51-
5254
```
5355
Context: kind-solo <0> all <a> Attach <ctr… ____ __.________
5456
Cluster: kind-solo <ctrl-d> Delete <l> | |/ _/ __ \______
@@ -75,7 +77,6 @@ You may now view pods in your cluster using `k9s -A` as below:
7577
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
7678
```
7779

78-
7980
### Step by Step Instructions
8081

8182
* Initialize `solo` directories:
@@ -136,13 +137,16 @@ Kubernetes Cluster : kind-solo
136137
✔ Generate gRPC TLS Keys
137138
✔ Finalize
138139
```
140+
139141
PEM key files are generated in `~/.solo/keys` directory.
142+
140143
```
141144
hedera-node1.crt hedera-node3.crt s-private-node1.pem s-public-node1.pem unused-gossip-pem
142145
hedera-node1.key hedera-node3.key s-private-node2.pem s-public-node2.pem unused-tls
143146
hedera-node2.crt hedera-node4.crt s-private-node3.pem s-public-node3.pem
144147
hedera-node2.key hedera-node4.key s-private-node4.pem s-public-node4.pem
145148
```
149+
146150
* Setup cluster with shared components
147151

148152
```

examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* make sure that your current kubeconfig context is pointing to the cluster that you want to deploy to
1111
* run `task` which will do the rest and deploy the network and take care of many of the pre-requisites
1212

13-
NOTES:
13+
NOTES:
1414

1515
* Some of these examples are for running against large clusters with a lot of resources available.
1616
* the `env` environment variables if set in your shell will take precedence over what is in the Taskfile.yml. e.g. `export HEDERA_SERVICES_ROOT=<path-to-hedera-services-root>`

src/core/lease/interval_lease.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {sleep} from '../helpers.js';
2323
import {Duration} from '../time/duration.js';
2424
import type {Lease, LeaseRenewalService} from './lease.js';
2525
import {StatusCodes} from 'http-status-codes';
26-
import chalk from 'chalk';
2726

2827
/**
2928
* Concrete implementation of a Kubernetes based time-based mutually exclusive lock via the Coordination API.
@@ -144,14 +143,16 @@ export class IntervalLease implements Lease {
144143
async acquire(): Promise<void> {
145144
const lease = await this.retrieveLease();
146145

147-
if (!lease || IntervalLease.checkExpiration(lease) || this.heldBySameProcess(lease)) {
146+
if (!lease || this.heldBySameProcess(lease)) {
148147
return this.createOrRenewLease(lease);
148+
} else if (IntervalLease.checkExpiration(lease)) {
149+
return this.transferLease(lease);
149150
}
150151

151152
const otherHolder: LeaseHolder = LeaseHolder.fromJson(lease.spec.holderIdentity);
152153

153154
if (this.heldBySameMachineIdentity(lease) && !otherHolder.isProcessAlive()) {
154-
return await this.transferLease(lease);
155+
return this.transferLease(lease);
155156
}
156157

157158
throw new LeaseAcquisitionError(
@@ -220,7 +221,6 @@ export class IntervalLease implements Lease {
220221
* @throws LeaseRelinquishmentError - If the lease is already acquired by another process or an error occurs during relinquishment.
221222
*/
222223
async release(): Promise<void> {
223-
this.client.logger.showUser(`${chalk.gray('releasing lease')}`);
224224
const lease = await this.retrieveLease();
225225

226226
if (this.scheduleId) {
@@ -329,10 +329,8 @@ export class IntervalLease implements Lease {
329329
this.leaseHolder.toJson(),
330330
this.durationSeconds,
331331
);
332-
} else if (this.leaseHolder.equals(LeaseHolder.fromJson(lease.spec.holderIdentity))) {
333-
await this.client.renewNamespaceLease(this.leaseName, this.namespace, lease);
334332
} else {
335-
await this.client.transferNamespaceLease(lease, this.leaseHolder.toJson());
333+
await this.client.renewNamespaceLease(this.leaseName, this.namespace, lease);
336334
}
337335

338336
if (!this.scheduleId) {

0 commit comments

Comments
 (0)