简体   繁体   English

为什么我的神器存储量这么高? 我怎样才能摆脱它?

[英]Why is my artifact storage so high? How can I get rid of it?

I am trying to get my namespace storage <5GB, but I have one project that is using up almost all of the space because it's artifact storage is 4.5GB.我试图让我的命名空间存储 <5GB,但我有一个项目几乎用完了所有空间,因为它的工件存储是 4.5GB。

Screenshot of my usage quota我的使用配额截图

We have pipelines set to run every push to GitLab, but the pipelines are quite simple: install necessary packages and run tests.我们设置了管道来运行每次推送到 GitLab,但管道非常简单:安装必要的包并运行测试。 The only artifacts we explicitly save are log files (usually only a few KB, if anything), and screenshots of failed browser tests (again, a couple of MB at most).我们明确保存的唯一工件是日志文件(通常只有几 KB,如果有的话)和失败的浏览器测试的屏幕截图(同样,最多几 MB)。 We also have artifacts set to expire after 24 hours.我们还将工件设置为在 24 小时后过期。

We have a small team, so even on our busiest day, we won't have more than 15 pipelines run, and if each pipeline saves 5MB (way more than reality), it should be 75MB a day -- which should expire down to 0 MB after 24 hours.我们有一个小团队,所以即使在我们最忙碌的一天,我们运行的管道也不会超过 15 个,如果每个管道节省 5MB(比实际多),那么每天应该是 75MB——到期时间应该是24 小时后为 0 MB。

I recently unchecked "Keep artifacts from most recent successful jobs" in Settings > Usage Quotas > CI/CD > Artifacts but it had been checked for a year or so (since we started the project).我最近在“设置”>“使用配额”>“CI/CD”>“工件”中取消选中“保留来自最近成功工作的工件”,但它已经检查了一年左右(自从我们开始项目以来)。

Other steps I've tried is making API calls to delete all artifacts in the project and I wrote a script to get all job IDs and delete all artifacts for each job ID .我尝试过的其他步骤是进行 API 调用以删除项目中的所有工件,我编写了一个脚本来获取所有作业 ID删除每个作业 ID 的所有工件

Is it possible that we have GB of old successful job artifacts clogging up our storage?我们是否有可能有 GB 的旧成功作业工件堵塞了我们的存储空间? Is it possible to browse & delete artifacts manually?是否可以手动浏览和删除工件?

Edit: this is using Gitlab.com, not self-hosted.编辑:这是使用 Gitlab.com,不是自托管的。

As per sytech's comment above , I wrote a PHP script to get all pipeline IDs and delete any pipelines that are older than 1 week. 根据上面 sytech 的评论,我编写了一个 PHP 脚本来获取所有管道 ID 并删除任何超过 1 周的管道。 This removed around 3000 old pipelines, and my storage quota went from from ~5GB to ~150MB.这删除了大约 3000 个旧管道,我的存储配额从 ~5GB 变为 ~150MB。 Here's the script in case anyone is interested:如果有人感兴趣,这是脚本:

<?php

/**
 * Keep all pipelines 7 days and newer
 */
$cutoffTime = time() - (7 * 24 * 60 * 60);

$ids = [];
$page = 1;

/**
 * Get list of all pipeline IDs and store old IDs in array
 */
do {
    $response = `curl --header 'PRIVATE-TOKEN: <API_KEY>' 'https://gitlab.com/api/v4/projects/<PROJECT_ID>/pipelines?page=$page&per_page=100' -s`;
    $pipelines = json_decode($response);
    foreach ($pipelines as $pipeline) {
        if (strtotime($pipeline->updated_at) < $cutoffTime) {
            $ids[] = $pipeline->id;
        }
    }
    $page++;
} while ($pipelines);

/**
 * Delete all pipelines in IDs array
 */
$count = 0;
foreach ($ids as $id) {
    echo "Deleting $id ($pipeline->updated_at): ";
    $response = `curl --header 'PRIVATE-TOKEN: <API_KEY>' --request 'DELETE' 'https://gitlab.com/api/v4/projects/<PROJECT_ID>/pipelines/$id' -s`;
    if (!$response) {
        echo "Done\n";
        $count++;
    } else {
        echo json_decode($response)->message . "\n";
    }
}

/**
 * Print results
 */
if ($ids) {
    echo "\nDeleted $count pipelines.\n\nDone.\n";
} else {
    echo "\nNo pipelines found older than 1 week\n\nDone.\n";
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我无法从 Firebase 存储中获取数据? - Why I can't get data from Firebase Storage? 如何在基于 YML 的部署管道中获取特定工件的最后一次成功部署的构建 ID - How can I get last successfully deployed build id of specific artifact in YML based deploy pipeline GCP:如何修剪/维护工件注册表存储? - GCP: How to prune/maintain Artifact Registry storage? 我如何(或可以)备份 Google Artifact Registry 实例? - How (or can) I backup a Google Artifact Registry instance? awscli 中的 ls 返回“PRE”。 为什么以及如何摆脱它 - ls in awscli returns "PRE". Why and how to get rid of it 如何摆脱导致我的域出错的 firebase 证书? - how to get rid of firebase cert causing an error on my domain? GitLab 做了一个“主”分支,我不能推到那个,我只能推到“主”。 如何摆脱“主要”分支? - GitLab made a "main" branch and I cannot push to that, I can only push to "master". How do I get rid of the "main" branch? 如何获取 Firebase 存储可下载链接数组并将其设置为 object 以存储在 mongodb 数据库中? - How can I get Firebase Storage downloadable array of links and set it to object for storing in mongodb database? 如何在 Data Studio 中删除所有这些 null 值? - How do I get rid of all these null values in Data Studio? 如何获取我的 firebase 存储项的完整路径? (包括 gs://) - How do I get the full path of my firebase storage item? (including the gs://)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM