Skip to content

Commit

Permalink
add details for gc dry-run (#19050)
Browse files Browse the repository at this point in the history
* add details for gc dry-run

fixes 19040
Gives the make details for the dry-run

Signed-off-by: wang yan <[email protected]>

* Update details column for gc history (#164)

1.Fixes #19038

Signed-off-by: AllForNothing <[email protected]>

---------

Signed-off-by: wang yan <[email protected]>
Signed-off-by: AllForNothing <[email protected]>
Co-authored-by: Shijun Sun <[email protected]>
  • Loading branch information
wy65701436 and AllForNothing authored Jul 31, 2023
1 parent ae33dbd commit 638c26c
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 81 deletions.
9 changes: 9 additions & 0 deletions src/jobservice/job/impl/gc/garbage_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ func (gc *GarbageCollector) mark(ctx job.Context) error {
blobs = append(blobs, orphanBlobs...)
}
if len(blobs) == 0 {
if err := saveGCRes(ctx, int64(0), int64(0), int64(0)); err != nil {
gc.logger.Errorf("failed to save the garbage collection results, errMsg=%v", err)
}
gc.logger.Info("no need to execute GC as there is no non referenced artifacts.")
return nil
}
Expand Down Expand Up @@ -269,6 +272,12 @@ func (gc *GarbageCollector) mark(ctx job.Context) error {
}
gc.logger.Infof("%d blobs and %d manifests eligible for deletion", blobCt, mfCt)
gc.logger.Infof("The GC could free up %d MB space, the size is a rough estimation.", makeSize/1024/1024)

if gc.dryRun {
if err := saveGCRes(ctx, makeSize, int64(blobCt), int64(mfCt)); err != nil {
gc.logger.Errorf("failed to save the garbage collection results, errMsg=%v", err)
}
}
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,54 +52,26 @@ <h5 class="history-header mt-3 font-style" id="history-header">
job.job_status.toUpperCase() | translate
}}</clr-dg-cell>
<clr-dg-cell>
<div>
<span
*ngIf="
getBlobs(job?.job_parameters) &&
getManifest(job?.job_parameters)
"
>{{
'GC.DELETE_BLOB_AND_MANIFEST'
| translate
: {
blob: getBlobs(job?.job_parameters),
manifest: getManifest(job?.job_parameters)
}
}}</span
>
<span
*ngIf="
getBlobs(job?.job_parameters) &&
!getManifest(job?.job_parameters)
"
>{{
'GC.DELETE_BLOB'
| translate
: {
blob: getBlobs(job?.job_parameters),
}
}}</span
>
<span
*ngIf="
!getBlobs(job?.job_parameters) &&
getManifest(job?.job_parameters)
"
>{{
'GC.DELETE_MANIFEST'
| translate
: {
manifest: getManifest(job?.job_parameters)
}
}}</span
>
</div>
<div *ngIf="getSize(job?.job_parameters)">
{{
'GC.FREE_UP_SIZE'
| translate : { size: getSize(job?.job_parameters) }
}}
</div>
<ng-container *ngIf="shouldShowDetails(job?.job_status)">
<span *ngIf="isDryRun(job?.job_parameters) === NO">{{
'GC.DELETE_DETAIL'
| translate
: {
blob: getBlobs(job?.job_parameters),
manifest: getManifest(job?.job_parameters),
size: getSize(job?.job_parameters)
}
}}</span>
<span *ngIf="isDryRun(job?.job_parameters) === YES">{{
'GC.DELETE_DETAIL_DRY_RUN'
| translate
: {
blob: getBlobs(job?.job_parameters),
manifest: getManifest(job?.job_parameters),
size: getSize(job?.job_parameters)
}
}}</span>
</ng-container>
</clr-dg-cell>
<clr-dg-cell>{{
job.creation_time | harborDatetime : 'medium'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export class GcHistoryComponent implements OnInit, OnDestroy {
selectedRow: GCHistory[] = [];
isStopOnGoing: boolean = false;
subscription: Subscription;
protected readonly NO = NO;
protected readonly YES = YES;
constructor(
private gcService: GcService,
private errorHandler: ErrorHandler,
Expand Down Expand Up @@ -154,6 +156,8 @@ export class GcHistoryComponent implements OnInit, OnDestroy {
item2.job_status = item.job_status;
item2.update_time =
item.update_time;
item2.job_parameters =
item.job_parameters;
}
});
});
Expand Down Expand Up @@ -230,7 +234,7 @@ export class GcHistoryComponent implements OnInit, OnDestroy {
return formatSize(paramObj.freed_space);
}
}
return null;
return '0';
}

getLogLink(id): string {
Expand Down Expand Up @@ -265,4 +269,8 @@ export class GcHistoryComponent implements OnInit, OnDestroy {
);
this.confirmationDialogService.openComfirmDialog(StopExecutionsMessage);
}

shouldShowDetails(status: string): boolean {
return status !== JOB_STATUS.PENDING && status !== JOB_STATUS.RUNNING;
}
}
6 changes: 2 additions & 4 deletions src/portal/src/i18n/lang/de-de-lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -1233,10 +1233,8 @@
"EXPLAIN": "Speicherbereinigung (Garbage Collection / GC) ist eine rechenintensive Operation, die die Registry-Leistung beeinflussen kann",
"EXPLAIN_TIME_WINDOW": "Artifacts uploaded in the past 2 hours(the default window) are excluded from garbage collection",
"DRY_RUN_SUCCESS": "Probelauf erfolgreich gestartet",
"DELETE_BLOB_AND_MANIFEST": "{{blob}} blob(s) and {{manifest}} manifest(s) deleted",
"DELETE_BLOB": "{{blob}} blob(s) deleted",
"DELETE_MANIFEST": "{{manifest}} manifest(s) deleted",
"FREE_UP_SIZE": "{{size}} space freed up",
"DELETE_DETAIL": "{{blob}} blob(s) and {{manifest}} manifest(s) deleted, {{size}} space freed up",
"DELETE_DETAIL_DRY_RUN": "{{blob}} blob(s) and {{manifest}} manifest(s) could be deleted, {{size}} space could be freed up",
"WORKERS_TOOLTIP": "Set the number of workers that can execute GC tasks in parallel, the default value is 1."
},
"RETAG": {
Expand Down
6 changes: 2 additions & 4 deletions src/portal/src/i18n/lang/en-us-lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -1234,10 +1234,8 @@
"EXPLAIN": "GC is a compute intensive operation that may impact registry performance",
"EXPLAIN_TIME_WINDOW": "Artifacts uploaded in the past 2 hours(the default window) are excluded from garbage collection",
"DRY_RUN_SUCCESS": "Triggered dry run successfully",
"DELETE_BLOB_AND_MANIFEST": "{{blob}} blob(s) and {{manifest}} manifest(s) deleted",
"DELETE_BLOB": "{{blob}} blob(s) deleted",
"DELETE_MANIFEST": "{{manifest}} manifest(s) deleted",
"FREE_UP_SIZE": "{{size}} space freed up",
"DELETE_DETAIL": "{{blob}} blob(s) and {{manifest}} manifest(s) deleted, {{size}} space freed up",
"DELETE_DETAIL_DRY_RUN": "{{blob}} blob(s) and {{manifest}} manifest(s) could be deleted, {{size}} space could be freed up",
"WORKERS_TOOLTIP": "Set the number of workers that can execute GC tasks in parallel, the default value is 1."
},
"RETAG": {
Expand Down
6 changes: 2 additions & 4 deletions src/portal/src/i18n/lang/es-es-lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -1230,10 +1230,8 @@
"EXPLAIN": "GC is a compute intensive operation that may impact registry performance",
"EXPLAIN_TIME_WINDOW": "Artifacts uploaded in the past 2 hours(the default window) are excluded from garbage collection",
"DRY_RUN_SUCCESS": "Triggered dry run successfully",
"DELETE_BLOB_AND_MANIFEST": "{{blob}} blob(s) and {{manifest}} manifest(s) deleted",
"DELETE_BLOB": "{{blob}} blob(s) deleted",
"DELETE_MANIFEST": "{{manifest}} manifest(s) deleted",
"FREE_UP_SIZE": "{{size}} space freed up",
"DELETE_DETAIL": "{{blob}} blob(s) and {{manifest}} manifest(s) deleted, {{size}} space freed up",
"DELETE_DETAIL_DRY_RUN": "{{blob}} blob(s) and {{manifest}} manifest(s) could be deleted, {{size}} space could be freed up",,
"WORKERS_TOOLTIP": "Set the number of workers that can execute GC tasks in parallel, the default value is 1."
},
"RETAG": {
Expand Down
6 changes: 2 additions & 4 deletions src/portal/src/i18n/lang/fr-fr-lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -1200,10 +1200,8 @@
"EXPLAIN": "GC est une opération gourmande en puissance de calcul qui peut impacter les performances du registre",
"EXPLAIN_TIME_WINDOW": "Artifacts uploaded in the past 2 hours(the default window) are excluded from garbage collection",
"DRY_RUN_SUCCESS": "Exécution à blanc déclenchée avec succès",
"DELETE_BLOB_AND_MANIFEST": "{{blob}} blob(s) and {{manifest}} manifest(s) deleted",
"DELETE_BLOB": "{{blob}} blob(s) deleted",
"DELETE_MANIFEST": "{{manifest}} manifest(s) deleted",
"FREE_UP_SIZE": "{{size}} space freed up",
"DELETE_DETAIL": "{{blob}} blob(s) and {{manifest}} manifest(s) deleted, {{size}} space freed up",
"DELETE_DETAIL_DRY_RUN": "{{blob}} blob(s) and {{manifest}} manifest(s) could be deleted, {{size}} space could be freed up",
"WORKERS_TOOLTIP": "Set the number of workers that can execute GC tasks in parallel, the default value is 1."
},
"RETAG": {
Expand Down
6 changes: 2 additions & 4 deletions src/portal/src/i18n/lang/pt-br-lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -1230,10 +1230,8 @@
"EXPLAIN": "A limpeza exige recursos computacionais e pode impactar performance.",
"EXPLAIN_TIME_WINDOW": "Artifacts uploaded in the past 2 hours(the default window) are excluded from garbage collection",
"DRY_RUN_SUCCESS": "Teste executado com sucesso",
"DELETE_BLOB_AND_MANIFEST": "{{blob}} blob(s) and {{manifest}} manifest(s) deleted",
"DELETE_BLOB": "{{blob}} blob(s) deleted",
"DELETE_MANIFEST": "{{manifest}} manifest(s) deleted",
"FREE_UP_SIZE": "{{size}} space freed up",
"DELETE_DETAIL": "{{blob}} blob(s) and {{manifest}} manifest(s) deleted, {{size}} space freed up",
"DELETE_DETAIL_DRY_RUN": "{{blob}} blob(s) and {{manifest}} manifest(s) could be deleted, {{size}} space could be freed up",
"WORKERS_TOOLTIP": "Set the number of workers that can execute GC tasks in parallel, the default value is 1."
},
"RETAG": {
Expand Down
6 changes: 2 additions & 4 deletions src/portal/src/i18n/lang/tr-tr-lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -1233,10 +1233,8 @@
"EXPLAIN": "GC is a compute intensive operation that may impact registry performance",
"EXPLAIN_TIME_WINDOW": "Artifacts uploaded in the past 2 hours(the default window) are excluded from garbage collection",
"DRY_RUN_SUCCESS": "Triggered dry run successfully",
"DELETE_BLOB_AND_MANIFEST": "{{blob}} blob(s) and {{manifest}} manifest(s) deleted",
"DELETE_BLOB": "{{blob}} blob(s) deleted",
"DELETE_MANIFEST": "{{manifest}} manifest(s) deleted",
"FREE_UP_SIZE": "{{size}} space freed up",
"DELETE_DETAIL": "{{blob}} blob(s) and {{manifest}} manifest(s) deleted, {{size}} space freed up",
"DELETE_DETAIL_DRY_RUN": "{{blob}} blob(s) and {{manifest}} manifest(s) could be deleted, {{size}} space could be freed up",
"WORKERS_TOOLTIP": "Set the number of workers that can execute GC tasks in parallel, the default value is 1."
},
"RETAG": {
Expand Down
6 changes: 2 additions & 4 deletions src/portal/src/i18n/lang/zh-cn-lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -1230,10 +1230,8 @@
"EXPLAIN": "垃圾回收是一个计算密集型操作,可能会影响仓库性能",
"EXPLAIN_TIME_WINDOW": "在最近的两小时(默认窗口期)内被推送的 Artifacts 不会被当做垃圾回收的目标",
"DRY_RUN_SUCCESS": "触发模拟运行成功",
"DELETE_BLOB_AND_MANIFEST": "{{blob}}个 blob(s) 和 {{manifest}}个 manifest(s) 已删除",
"DELETE_BLOB": "{{blob}}个 blob(s) 已删除",
"DELETE_MANIFEST": "{{manifest}}个 manifest(s) 已删除",
"FREE_UP_SIZE": "{{size}}的空间已清理",
"DELETE_DETAIL": "{{blob}}个 blob(s) 和 {{manifest}}个 manifest(s) 已删除,{{size}}的空间已清理",
"DELETE_DETAIL_DRY_RUN": "{{blob}}个 blob(s) 和 {{manifest}}个 manifest(s) 将被删除,{{size}}的空间将被清理",
"WORKERS_TOOLTIP": "设置可并行执行垃圾回收任务的工作者数量,默认值为1。"
},
"RETAG": {
Expand Down
6 changes: 2 additions & 4 deletions src/portal/src/i18n/lang/zh-tw-lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -1222,10 +1222,8 @@
"EXPLAIN": "清理垃圾是一個計算密集的操作,可能影響註冊表的效能",
"EXPLAIN_TIME_WINDOW": "Artifacts uploaded in the past 2 hours(the default window) are excluded from garbage collection",
"DRY_RUN_SUCCESS": "成功觸發測試執行",
"DELETE_BLOB_AND_MANIFEST": "{{blob}} blob(s) and {{manifest}} manifest(s) deleted",
"DELETE_BLOB": "{{blob}} blob(s) deleted",
"DELETE_MANIFEST": "{{manifest}} manifest(s) deleted",
"FREE_UP_SIZE": "{{size}} space freed up",
"DELETE_DETAIL": "{{blob}} blob(s) and {{manifest}} manifest(s) deleted, {{size}} space freed up",
"DELETE_DETAIL_DRY_RUN": "{{blob}} blob(s) and {{manifest}} manifest(s) could be deleted, {{size}} space could be freed up",
"WORKERS_TOOLTIP": "Set the number of workers that can execute GC tasks in parallel, the default value is 1."
},
"RETAG": {
Expand Down

0 comments on commit 638c26c

Please sign in to comment.