mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-25 19:56:09 +01:00
Add retry times for calling CVE data export execution list API (#18297)
1.Fixes #17879 2.Add retry times to avoid endless API calls for CVE data export execution list API Signed-off-by: AllForNothing <sshijun@vmware.com>
This commit is contained in:
parent
90db04e92d
commit
6f01d7480b
@ -27,6 +27,7 @@ const MAX_NUMBER: number = 500;
|
|||||||
const MAX_SAVING_TIME: number = 1000 * 60 * 60 * 24 * 30; // 30 days
|
const MAX_SAVING_TIME: number = 1000 * 60 * 60 * 24 * 30; // 30 days
|
||||||
const TIMEOUT = 7000;
|
const TIMEOUT = 7000;
|
||||||
const FILE_NAME_PREFIX: string = 'csv_file_';
|
const FILE_NAME_PREFIX: string = 'csv_file_';
|
||||||
|
const RETRY_TIMES: number = 50;
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'hbr-operation-model',
|
selector: 'hbr-operation-model',
|
||||||
templateUrl: './operation.component.html',
|
templateUrl: './operation.component.html',
|
||||||
@ -34,7 +35,6 @@ const FILE_NAME_PREFIX: string = 'csv_file_';
|
|||||||
animations: [SlideInOutAnimation],
|
animations: [SlideInOutAnimation],
|
||||||
})
|
})
|
||||||
export class OperationComponent implements OnInit, OnDestroy {
|
export class OperationComponent implements OnInit, OnDestroy {
|
||||||
fileNamePrefix: string = FILE_NAME_PREFIX;
|
|
||||||
batchInfoSubscription: Subscription;
|
batchInfoSubscription: Subscription;
|
||||||
resultLists: OperateInfo[] = [];
|
resultLists: OperateInfo[] = [];
|
||||||
exportJobs: OperateInfo[] = [];
|
exportJobs: OperateInfo[] = [];
|
||||||
@ -59,6 +59,7 @@ export class OperationComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
timeout;
|
timeout;
|
||||||
refreshExportJobSub: Subscription;
|
refreshExportJobSub: Subscription;
|
||||||
|
retryTimes: number = RETRY_TIMES;
|
||||||
constructor(
|
constructor(
|
||||||
private session: SessionService,
|
private session: SessionService,
|
||||||
private operationService: OperationService,
|
private operationService: OperationService,
|
||||||
@ -74,7 +75,7 @@ export class OperationComponent implements OnInit, OnDestroy {
|
|||||||
if (this.animationState === 'out') {
|
if (this.animationState === 'out') {
|
||||||
this._newMessageCount += 1;
|
this._newMessageCount += 1;
|
||||||
}
|
}
|
||||||
this.refreshExportJobs();
|
this.refreshExportJobs(false);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -148,7 +149,7 @@ export class OperationComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
init() {
|
init() {
|
||||||
if (this.session.getCurrentUser()) {
|
if (this.session.getCurrentUser()) {
|
||||||
this.refreshExportJobs();
|
this.refreshExportJobs(false);
|
||||||
const operationInfosString: string = localStorage.getItem(
|
const operationInfosString: string = localStorage.getItem(
|
||||||
`${OPERATION_KEY}-${this.session.getCurrentUser().user_id}`
|
`${OPERATION_KEY}-${this.session.getCurrentUser().user_id}`
|
||||||
);
|
);
|
||||||
@ -248,6 +249,7 @@ export class OperationComponent implements OnInit, OnDestroy {
|
|||||||
daysAgo
|
daysAgo
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
this.refreshExportJobs(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateTime(
|
calculateTime(
|
||||||
@ -268,8 +270,13 @@ export class OperationComponent implements OnInit, OnDestroy {
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
refreshExportJobs() {
|
refreshExportJobs(isRetry: boolean) {
|
||||||
if (this.session.getCurrentUser()) {
|
if (this.session.getCurrentUser()) {
|
||||||
|
if (isRetry) {
|
||||||
|
this.retryTimes--;
|
||||||
|
} else {
|
||||||
|
this.retryTimes = RETRY_TIMES;
|
||||||
|
}
|
||||||
this.scanDataExportService
|
this.scanDataExportService
|
||||||
.getScanDataExportExecutionList()
|
.getScanDataExportExecutionList()
|
||||||
.subscribe(res => {
|
.subscribe(res => {
|
||||||
@ -300,9 +307,13 @@ export class OperationComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.refreshTimestampForExportJob();
|
this.refreshTimestampForExportJob();
|
||||||
if (flag) {
|
if (flag && this.retryTimes > 0) {
|
||||||
|
if (this.timeout) {
|
||||||
|
clearTimeout(this.timeout);
|
||||||
|
this.timeout = null;
|
||||||
|
}
|
||||||
this.timeout = setTimeout(() => {
|
this.timeout = setTimeout(() => {
|
||||||
this.refreshExportJobs();
|
this.refreshExportJobs(true);
|
||||||
}, TIMEOUT);
|
}, TIMEOUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -346,7 +357,7 @@ export class OperationComponent implements OnInit, OnDestroy {
|
|||||||
.subscribe(
|
.subscribe(
|
||||||
res => {
|
res => {
|
||||||
downloadCVEs(res, info.data.name);
|
downloadCVEs(res, info.data.name);
|
||||||
this.refreshExportJobs();
|
this.refreshExportJobs(false);
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
this.msgHandler.error(error);
|
this.msgHandler.error(error);
|
||||||
|
Loading…
Reference in New Issue
Block a user