Skip to content

Commit

Permalink
fix: max session policy is not shown for 20 sec
Browse files Browse the repository at this point in the history
- If the resource broker is not ready (when `globalThis`.backendaiclient
  is `undefined`), retry to get the `concurrency_max` after 2500 ms.
- Prevent silent failure in resource aggregation in the broker.
  • Loading branch information
adrysn committed Nov 4, 2023
1 parent 0594256 commit 1e2f2ba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/components/backend-ai-resource-broker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,10 @@ export default class BackendAiResourceBroker extends BackendAIPage {
*
*/
async _refreshResourcePolicy() {
if (!globalThis.backendaiclient) {
// To prevent a silent failure when the client is not ready in aggregating resources.
return Promise.resolve(false);
}
if (Date.now() - this.lastResourcePolicyQueryTime < 2000) {
return Promise.resolve(false);
}
Expand Down Expand Up @@ -482,7 +486,7 @@ export default class BackendAiResourceBroker extends BackendAIPage {
* @param {string} from - set the value for debugging purpose.
*/
async _aggregateCurrentResource(from = '') {
if (this.aggregate_updating) {
if (!globalThis.backendaiclient || this.aggregate_updating) {
return Promise.resolve(false);
}
if (Date.now() - this.lastQueryTime < 1000) {
Expand Down
11 changes: 10 additions & 1 deletion src/components/backend-ai-resource-monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,16 @@ export default class BackendAiResourceMonitor extends BackendAIPage {
}
return this.resourceBroker
._refreshResourcePolicy()
.then(() => {
.then((resolvedValue) => {
if (resolvedValue === false) {
setTimeout(() => {
// Retry to get the concurrency_max after a while if resource broker
// is not ready. When the timeout is 2000, it delays the display of
// other resource's allocation status. I don't know why, but I just
// set it to 2500.
this._refreshResourcePolicy();
}, 2500);
}
this.concurrency_used = this.resourceBroker.concurrency_used;
// this.userResourceLimit = this.resourceBroker.userResourceLimit;
this.concurrency_max =
Expand Down

0 comments on commit 1e2f2ba

Please sign in to comment.