Loading
Write audit events when Artifact Registry repositories change
What does this MR do and why?
Artifact Registry repository changes now write audit events. Today only role changes do (!268575 (merged)). This is the same pattern, applied to the repository mutations.
| Event | Written when | Extra details |
|---|---|---|
artifact_registry_repository_created |
A repository is created | format, kind, visibility |
artifact_registry_repository_updated |
A repository is updated | changed field names, visibility after the change |
artifact_registry_repository_deleted |
A repository and its artifacts are deleted | none |
artifact_registry_repository_artifacts_deleted |
Deletion of every artifact is requested | format, kind |
artifact_registry_upstream_repository_dissociated |
An upstream is removed from a virtual repository | format, association ID |
- Same scope as role events. The organization's top-level group, or Instance scope when there isn't exactly one. The scope logic moves to
ArtifactRegistry::TopLevelGroups.audit_scopeso both share it. - Written after Artifact Registry succeeds. No event for a refused or failed change.
- No event for a no-op. Deleting a repository or removing an upstream that's already gone writes nothing. To support this,
Client#delete_repositoryand#dissociate_upstream_repositorynow returnfalseon the idempotent 404. Each has one caller. - Never blocks the change. Building and writing the event both happen inside one rescue. A failure goes to error tracking, and the mutation still succeeds.
- No credentials. Updates record field names only, because
settingscan hold upstream credentials.
What it doesn't cover: changes made through the GitLab UI or GraphQL API write these events. A user can also exchange a personal access token for an Artifact Registry token and call the AR management API directly. Those calls write no event here. Auditing them on the AR side is gitlab-org/ops/artifact-registry#718.
Not in this MR:
- Artifact deletes (versions, manifests, tags, dist-tags). Users can send these straight to Artifact Registry, so they need work on that side too. See https://gitlab.com/gitlab-org/ops/artifact-registry/-/work_items/1949.
- Previous values on update. The mutation doesn't know them without an extra read.
- A changelog entry. All five mutations are mounted as experiments.
References
- Related to gitlab-org/ops/artifact-registry#718
- Related to gitlab-org/ops/artifact-registry#707
- Related to #605696
How to set up and validate locally
- Enable Artifact Registry for an organization that has one top-level group.
- Create a repository with
artifactRegistryRepositoryCreate, change its description withartifactRegistryRepositoryUpdate, then delete it withartifactRegistryRepositoryDelete. - Open the top-level group's Secure > Audit events. You should see one created, one updated, and one deleted event.
- Run the delete again. No new event appears.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist.
Edited by Tim Rizzi