Reputation: 373
I am trying to set the cleanup policy for my Docker repositories in Google Cloud Artifact Registry using the gcloud
command. However, when I try to set the policy, it appears to be setting an empty policy instead of the intended policy.
The policy I want to set is in the standard_cleanup_policy.json
file, which has the following content:
[
{
"name":"delete-older-than-30-days",
"action":{
"type":"Delete"
},
"condition":{
"olderThan":"30d"
}
},
{
"name":"keep-latest-3-images",
"action":{
"type":"Keep"
},
"mostRecentVersions":{
"keepCount":3
}
}
]
I run the following gcloud command to update the cleanup policy for a specific repository:
gcloud artifacts repositories set-cleanup-policies REPOSITORY --location=LOCATION --policy=standard_cleanup_policy.json --project=PROJECT_ID --verbosity debug
When I run this command, I get the following output with debug messages:
$ gcloud artifacts repositories set-cleanup-policies hypgen --location=us --policy=standard_cleanup_policy.json --verbosity debug
DEBUG: Running [gcloud.artifacts.repositories.set-cleanup-policies] with arguments: [--location: "us", --policy: "{'delete-older-than-30-days': {'id': 'delete-older-than-30-days', 'action': 'Delete', 'condition': {'olderThan': '2592
000.0s'}, 'mostRecentVersions': None}, 'keep-latest-3-images': {'id': 'keep-latest-3-images', 'action': 'Keep', 'condition': None, 'mostRecentVersions': {'keepCount': 3}}}", --verbosity: "debug", REPOSITORY: "hypgen"]
DEBUG: Starting new HTTPS connection (1): artifactregistry.googleapis.com:443
DEBUG: https://artifactregistry.googleapis.com:443 "GET /v1/projects/notartifacts/locations/us/repositories/hypgen?alt=json HTTP/1.1" 200 None
DEBUG: Starting new HTTPS connection (1): artifactregistry.googleapis.com:443
DEBUG: https://artifactregistry.googleapis.com:443 "PATCH /v1/projects/notartifacts/locations/us/repositories/hypgen?alt=json&updateMask=cleanup_policies HTTP/1.1" 200 None
Updated repository [hypgen].
DEBUG: Chosen display Format:json
INFO: Display format: "json"
[]
Despite not receiving any error messages, the command sets an empty policy []
instead of the policy in the JSON file. When I use the gcloud artifacts repositories list-cleanup-policies
command, it also returns an empty policy. Additionally, the Artifact Registry Web UI doesn't provide any way to add or update policies through the web browser.
I've tried various alternatives and workarounds, but I haven't been able to get the desired outcome. I'd appreciate it if someone could suggest alternative methods for setting the cleanup policies or help me identify the issue with the gcloud command.
Upvotes: 1
Views: 1486
Reputation: 1712
According to this documentation:
Feature availability: This feature is only available to users who signed up for Artifact Registry private preview. For more information, contact your Google representative.
If you are eligible to use this feature feel free to contact Google Cloud Support. You may also file a bug in this link if you're already using this feature and not working properly the Product Team will look into this. However, there is no ETA for it.
Upvotes: 3