Documentation
¶
Overview ¶
Package usage computes the storage summary (GET /api/storageinfo): blob totals, item totals per repository and for the trash can, and the capacity of the volume a local blob store lives on.
Role ¶
artifacts module, core layer: the storage summary behind GET /api/storageinfo. It computes the values, and the HTTP layer renders them in 7.x's JSON. As artifacts core, it never imports the module's adapters or an ecosystem http package (decision 0044, dependency rule 8).
Inputs ¶
- Driving: the storage summary handler of GET /api/storageinfo, after its access check.
- Driven: the metadata store, through Store, for the blob totals, the item totals of each repository and remote cache, the repositories, and the trash can's entries, a page at a time.
- The hot blob store's Location, which the application derives from the blob store configuration and hands to the server: the name Artifactory gives its binary provider chain, the directory it reports, and the local root whose volume reports capacity.
- The volume's capacity, from the operating system: statfs on Unix (space_unix.go) and GetDiskFreeSpaceEx on Windows (space_windows.go). Elsewhere it is unknown (space_other.go).
Outputs ¶
- Summarize's Summary: the blob count and size; the file count and size before deduplication, and the item count with the folders, the trash can's included; the Location; the volume's Space, nil when unknown; and the Rows, sorted by key. There is one Row per repository, a remote repository's under its cache alias ("<key>-cache", type CACHE), and one for the trash can.
- DefaultProject, the project key of a repository in no project and of the trash can's row, and NoFilesystem, the directory an object store reports.
Invariants ¶
- The summary is computed on every request rather than cached, so it never lags writes.
- The trash can counts as the repository 7.x keeps it in (auto-trashcan), in its row and in every total, as its storage listing shows it: a path trashed twice is one file, of the size last trashed, and the folders above a trashed item, its repository's among them, are folders. A count of trash entries would differ on both.
- The capacity of object storage is unknown, as is that of a volume the operating system cannot read; Space is then nil.
References ¶
- Decision 0010: docs/research/decisions/0010-retention-trash-and-gc.md, "Implementation (P3)" (the storage summary, computed on every request, with the trash can in an auto-trashcan row and in the totals).
- Research 15: docs/research/15-data-model.md, section 2.2 (7.x's storage summary and the captures that settle its fields).
- Research 02: docs/research/02-artifactory-core-api-inventory.md (the storage summary's endpoints and access).
- https://docs.jfrog.com/artifactory/reference/getstoragesummaryinfo.md
- Decision 0044: docs/research/decisions/0044-modular-monolith-migration.md, "Dependency rules".
- Target layout: docs/research/architecture-options/5-modular-monolith.md, line 210 (core/usage), line 1038 (the mapping row) and rule 2 at lines 35 to 36.
- Plan: docs/implementation/plan.md#p3-repositories-generic-artifacts-cli-aql-shape (task 2, storageinfo), #p2b-cloud-blob-storage-and-mirroring and #p9d-modular-monolith-migration, epic ART (https://github.com/weaveplatform/artifactweave/issues/941).
- https://github.com/weaveplatform/artifactweave/issues/973 and https://github.com/weaveplatform/artifactweave/issues/1088
Status ¶
Implemented P3, with 7.x's fields from follow-ups filed under P2b. P3 added Summarize over the blob totals and the item totals per repository, and the volume's capacity (https://github.com/weaveplatform/artifactweave/issues/48). The follow-ups added the trash can's row and totals, project keys and the binary provider chain names (https://github.com/weaveplatform/artifactweave/issues/390), and NoFilesystem for an object store (https://github.com/weaveplatform/artifactweave/issues/461). Moved here in P9d, which narrowed Summarize's store to Store (https://github.com/weaveplatform/artifactweave/issues/1088).
Testing ¶
- TestUnitSummarize: the totals; the rows with their types, package types and project keys; the trash can's row, while it is empty and once items are trashed; and the capacity of a local volume, unknown for object storage and for a volume that cannot be read.
- TestUnitSummarizeReadsTheWholeTrash: more trash entries than one page of the trash listing holds.
- TestUnitSummarizeFailures: every store failure surfaces.
Index ¶
Constants ¶
const DefaultProject = "default"
DefaultProject is the project key of a repository in no project.
const NoFilesystem = "Filesystem storage is not used"
NoFilesystem is the directory Artifactory reports for a binary provider chain with no file-system or cache-fs provider in it, as an object store is here: it keeps no local copy (6.20's StorageSummaryImpl).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Location ¶
type Location struct {
// Type names the store as Artifactory names a binary provider chain:
// its template, such as file-system or s3-storage-v3-direct, or
// user-chain for a chain no template describes.
Type string
// Directory is the root directory, NoFilesystem for an object store, or
// the mirror's members.
Directory string
// Root is the local directory whose volume reports capacity; empty for
// object storage, whose capacity is unknown.
Root string
}
Location describes the hot blob store for the summary.
type Row ¶
type Row struct {
Key string
// Type is LOCAL, CACHE, VIRTUAL or FEDERATED, or NA for the trash can.
Type string
// PackageType is empty for the trash can.
PackageType repo.PackageType
// ProjectKey is DefaultProject for a repository in no project and for
// the trash can.
ProjectKey string
Files int64
Folders int64
Bytes int64
}
Row is one repository's line, a remote repository's cache under its "<key>-cache" alias, or the trash can's.
type Store ¶
type Store interface {
Blobs() port.BlobIndex
Repos() port.RepoStore
Items() port.ItemStore
Trash() port.TrashStore
}
Store is what the summary reads: the blob index's totals, the repositories, the items' usage and the trash can's entries. Each composite store in app is a Store.
type Summary ¶
type Summary struct {
BinariesCount, BinariesSize int64
// ArtifactsCount and ArtifactsSize count every file as stored before
// deduplication, the trash can's included; ItemsCount adds the folders.
ArtifactsCount, ArtifactsSize, ItemsCount int64
Location Location
// Space is nil when the capacity is unknown.
Space *Space
// Rows are sorted by key, the trash can's among them.
Rows []Row
}
Summary is the storage summary.