Commit 8d9b1e18 authored by AllForNothing's avatar AllForNothing
Browse files

Add dry run to gc page


Signed-off-by: default avatarAllForNothing <sshijun@vmware.com>
parent ee35e1ec
......@@ -1214,7 +1214,8 @@
"MSG_SCHEDULE_RESET": "Garbage Collection schedule has been reset",
"PARAMETERS": "Parameters",
"DELETE_UNTAGGED": "Allow garbage collection on untagged artifacts",
"EXPLAIN": "GC is a compute intensive operation that may impact registry performance"
"EXPLAIN": "GC is a compute intensive operation that may impact registry performance",
"DRY_RUN_SUCCESS": "Triggered dry run successfully"
},
"RETAG": {
"MSG_SUCCESS": "Copy artifact successfully",
......
......@@ -1208,7 +1208,8 @@
"MSG_SCHEDULE_RESET": "Garbage Collection schedule has been reset",
"PARAMETERS": "Parameters",
"DELETE_UNTAGGED": "Allow garbage collection on untagged artifacts",
"EXPLAIN": "GC is a compute intensive operation that may impact registry performance"
"EXPLAIN": "GC is a compute intensive operation that may impact registry performance",
"DRY_RUN_SUCCESS": "Triggered dry run successfully"
},
"RETAG": {
"MSG_SUCCESS": "Copy artifact successfully",
......
......@@ -1178,7 +1178,8 @@
"MSG_SCHEDULE_RESET": "Garbage Collection schedule has been reset",
"PARAMETERS": "Parameters",
"DELETE_UNTAGGED": "Allow garbage collection on untagged artifacts",
"EXPLAIN": "GC is a compute intensive operation that may impact registry performance"
"EXPLAIN": "GC is a compute intensive operation that may impact registry performance",
"DRY_RUN_SUCCESS": "Triggered dry run successfully"
},
"RETAG": {
"MSG_SUCCESS": "Copy artifact successfully",
......
......@@ -1206,7 +1206,8 @@
"MSG_SCHEDULE_RESET": "Agendamento de Garbage Collection foi redefinido",
"PARAMETERS": "Parameters",
"DELETE_UNTAGGED": "Allow garbage collection on untagged artifacts",
"EXPLAIN": "GC is a compute intensive operation that may impact registry performance"
"EXPLAIN": "GC is a compute intensive operation that may impact registry performance",
"DRY_RUN_SUCCESS": "Triggered dry run successfully"
},
"RETAG": {
"MSG_SUCCESS": "Copy artifact successfully",
......
......@@ -1210,7 +1210,8 @@
"MSG_SCHEDULE_RESET": "Çöp Toplama programı sıfırlandı",
"PARAMETERS": "Parameters",
"DELETE_UNTAGGED": "Allow garbage collection on untagged artifacts",
"EXPLAIN": "GC is a compute intensive operation that may impact registry performance"
"EXPLAIN": "GC is a compute intensive operation that may impact registry performance",
"DRY_RUN_SUCCESS": "Triggered dry run successfully"
},
"RETAG": {
"MSG_SUCCESS": "Copy artifact successfully",
......
......@@ -1207,7 +1207,8 @@
"MSG_SCHEDULE_RESET": "垃圾回收定时任务已被重置",
"PARAMETERS": "参数",
"DELETE_UNTAGGED": "允许回收无 tag 的 artifacts",
"EXPLAIN": "垃圾回收是一个计算密集型操作,可能会影响仓库性能"
"EXPLAIN": "垃圾回收是一个计算密集型操作,可能会影响仓库性能",
"DRY_RUN_SUCCESS": "触发模拟运行成功"
},
"RETAG": {
"MSG_SUCCESS": "Artifact 拷贝成功",
......
......@@ -1194,7 +1194,8 @@
"MSG_SCHEDULE_RESET": "垃圾回收定時任務已被重置",
"PARAMETERS": "參數",
"DELETE_UNTAGGED": "Allow garbage collection on untagged artifacts",
"EXPLAIN": "GC is a compute intensive operation that may impact registry performance"
"EXPLAIN": "GC is a compute intensive operation that may impact registry performance",
"DRY_RUN_SUCCESS": "Triggered dry run successfully"
},
"RETAG":{
"MSG_SUCCESS": "Artifact 拷貝成功",
......
......@@ -5,6 +5,7 @@
<clr-datagrid [clrDgLoading]="loading">
<clr-dg-column>{{'GC.JOB_ID' | translate}}</clr-dg-column>
<clr-dg-column>{{'GC.TRIGGER_TYPE' | translate}}</clr-dg-column>
<clr-dg-column>{{'TAG_RETENTION.DRY_RUN' | translate}}</clr-dg-column>
<clr-dg-column>{{'STATUS' | translate}}</clr-dg-column>
<clr-dg-column>{{'CREATION_TIME' | translate}}</clr-dg-column>
<clr-dg-column>{{'UPDATE_TIME' | translate}}</clr-dg-column>
......@@ -12,6 +13,7 @@
<clr-dg-row *ngFor="let job of jobs" [clrDgItem]='job'>
<clr-dg-cell>{{job.id }}</clr-dg-cell>
<clr-dg-cell>{{(job.type ? 'SCHEDULE.'+ job.type.toUpperCase() : '') | translate }}</clr-dg-cell>
<clr-dg-cell>{{isDryRun(job?.parameters)}}</clr-dg-cell>
<clr-dg-cell>{{job.status.toUpperCase() | translate}}</clr-dg-cell>
<clr-dg-cell>{{job.createTime | date:'medium'}}</clr-dg-cell>
<clr-dg-cell>{{job.updateTime | date:'medium'}}</clr-dg-cell>
......
......@@ -18,6 +18,7 @@ describe('GcHistoryComponent', () => {
job_kind: 'manual',
schedule: null,
job_status: 'pending',
job_parameters: '{"dry_run":true}',
job_uuid: 'abc',
creation_time: null,
update_time: null,
......@@ -29,6 +30,7 @@ describe('GcHistoryComponent', () => {
job_kind: 'manual',
schedule: null,
job_status: 'finished',
job_parameters: '{"dry_run":true}',
job_uuid: 'bcd',
creation_time: null,
update_time: null,
......
......@@ -9,6 +9,8 @@ const JOB_STATUS = {
PENDING: "pending",
RUNNING: "running"
};
const YES: string = 'Yes';
const NO: string = 'No';
@Component({
selector: 'gc-history',
templateUrl: './gc-history.component.html',
......@@ -59,6 +61,16 @@ export class GcHistoryComponent implements OnInit, OnDestroy {
});
}
isDryRun(param: string): string {
if (param) {
const paramObj: any = JSON.parse(param);
if (paramObj && paramObj.dry_run) {
return YES;
}
}
return NO;
}
ngOnDestroy() {
if (this.timerDelay) {
this.timerDelay.unsubscribe();
......
......@@ -21,7 +21,13 @@
</div>
</div>
<div class="clr-row">
<button class="btn btn-primary gc-start-btn" (click)="gcNow()"
[disabled]="disableGC">{{'GC.GC_NOW' | translate}}</button>
<div class="clr-col-2 flex-200">
<button class="btn btn-primary gc-start-btn" (click)="gcNow()"
[disabled]="disableGC">{{'GC.GC_NOW' | translate}}</button>
</div>
<div class="clr-col">
<button class="btn btn-outline gc-start-btn" (click)="dryRun()"
[disabled]="dryRunOnGoing">{{'TAG_RETENTION.WHAT_IF_RUN' | translate}}</button>
</div>
</div>
......@@ -6,7 +6,6 @@
.gc-start-btn {
width:150px;
margin-left: 0.5rem;
margin-top: 35px;
}
......
......@@ -25,6 +25,7 @@ describe('GcComponent', () => {
id: 22222,
schedule: null,
job_status: 'string',
job_parameters: '{"dry_run":true}',
creation_time: new Date().toDateString(),
update_time: new Date().toDateString(),
job_name: 'string',
......
......@@ -34,6 +34,7 @@ export class GcComponent implements OnInit {
@ViewChild(CronScheduleComponent, {static: false})
CronScheduleComponent: CronScheduleComponent;
shouldDeleteUntagged: boolean;
dryRunOnGoing: boolean = false;
constructor(
private gcRepoService: GcRepoService,
private gcViewModelFactory: GcViewModelFactory,
......@@ -90,7 +91,7 @@ export class GcComponent implements OnInit {
this.enableGc();
}, ONE_MINITUE);
this.gcRepoService.manualGc(this.shouldDeleteUntagged).subscribe(
this.gcRepoService.manualGc(this.shouldDeleteUntagged, false).subscribe(
response => {
this.translate.get("GC.MSG_SUCCESS").subscribe((res: string) => {
this.errorHandler.info(res);
......@@ -102,6 +103,22 @@ export class GcComponent implements OnInit {
);
}
dryRun() {
this.dryRunOnGoing = true;
this.gcRepoService.manualGc(this.shouldDeleteUntagged, true)
.pipe(finalize(() => this.dryRunOnGoing = false))
.subscribe(
response => {
this.translate.get("GC.DRY_RUN_SUCCESS").subscribe((res: string) => {
this.errorHandler.info(res);
});
},
error => {
this.errorHandler.error(error);
}
);
}
private enableGc() {
this.disableGC = false;
}
......
......@@ -14,13 +14,14 @@ export class GcRepoService {
private errorHandler: ErrorHandler) {
}
public manualGc(shouldDeleteUntagged: boolean): Observable<any> {
public manualGc(shouldDeleteUntagged: boolean, isDryRun: boolean): Observable<any> {
const param = {
"schedule": {
"type": "Manual"
},
parameters: {
delete_untagged: shouldDeleteUntagged
delete_untagged: shouldDeleteUntagged,
dry_run: isDryRun
}
};
return this.gcApiRepository.postSchedule(param);
......
......@@ -13,6 +13,7 @@ export class GcViewModelFactory {
id: job.id,
type: job.schedule ? job.schedule.type : null,
status: job.job_status,
parameters: job.job_parameters,
createTime: createTime,
updateTime: updateTime,
details: null
......
......@@ -4,6 +4,7 @@ export class GcJobData {
job_kind: string;
schedule: Schedule;
job_status: string;
job_parameters: string;
job_uuid: string;
creation_time: string;
update_time: string;
......@@ -18,6 +19,7 @@ export class GcJobViewModel {
id: number;
type: string;
status: string;
parameters: string;
createTime: Date;
updateTime: Date;
details: string;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment