Skip to content

Commit

Permalink
fix(Cluster):fixed status check
Browse files Browse the repository at this point in the history
  • Loading branch information
dweinholz committed Nov 24, 2023
1 parent c8cda2e commit c013279
Showing 1 changed file with 5 additions and 28 deletions.
33 changes: 5 additions & 28 deletions src/app/virtualmachines/clustercard/clustercard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class ClustercardComponent extends SharedModal implements OnInit, OnDestr
* Default wait time between status checks if no other value specified.
* @private
*/
private checkStatusTimeout: number = 10000;
private checkStatusTimeout: number = 15000;

/**
* Default time in ms to show an error message if no other value specified.
Expand All @@ -98,6 +98,8 @@ export class ClustercardComponent extends SharedModal implements OnInit, OnDestr
}

ngOnInit() {
this.statusSubscription = new Subscription();

this.check_status_loop();
}

Expand Down Expand Up @@ -150,8 +152,6 @@ export class ClustercardComponent extends SharedModal implements OnInit, OnDestr

check_status_loop(): void {
this.all_worker_loaded = this.get_all_batches_loaded();
this.stopAllCheckStatusTimer();
this.statusSubscription = new Subscription();
this.checkStatusTimer = setTimeout((): void => {
this.statusSubscription.add(
this.virtualmachineservice
Expand All @@ -162,33 +162,10 @@ export class ClustercardComponent extends SharedModal implements OnInit, OnDestr
this.cluster.password = password;
if (
this.cluster.status !== VirtualMachineStates.DELETED
|| this.cluster.status !== VirtualMachineStates.MIGRATED
&& this.cluster.status !== VirtualMachineStates.NOT_FOUND
&& this.cluster.status !== VirtualMachineStates.MIGRATED
) {
this.check_status_loop();
this.check_worker_count_loop();
}
}),
);
}, this.checkStatusTimeout);
}

check_worker_count_loop(): void {
this.stopCheckWorkerStatusTimer();
this.statusSubscription = new Subscription();
this.checkWorkerStatusTimer = setTimeout((): void => {
this.statusSubscription.add(
this.virtualmachineservice
.getClusterInfo(this.cluster.cluster_id)
.subscribe((updated_cluster: Clusterinfo): void => {
const password: string = this.cluster.password;
this.cluster = new Clusterinfo(updated_cluster);
this.cluster.password = password;
this.all_worker_loaded = this.get_all_batches_loaded();
for (const batch of this.cluster.worker_batches) {
if (batch.running_worker < batch.worker_count) {
this.check_worker_count_loop();
break;
}
}
}),
);
Expand Down

0 comments on commit c013279

Please sign in to comment.