Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retention Policy Not Working When Configured via Harbor User Interface #19046

Closed
CrazyMushu opened this issue Jul 27, 2023 · 1 comment · Fixed by #19080
Closed

Retention Policy Not Working When Configured via Harbor User Interface #19046

CrazyMushu opened this issue Jul 27, 2023 · 1 comment · Fixed by #19080

Comments

@CrazyMushu
Copy link

CrazyMushu commented Jul 27, 2023

Description: I encountered an issue with the retention policy in Harbor version 2.8.1, where setting the policy through the user interface does not work as expected.

Steps to Reproduce:

I accessed the Harbor user interface.
In the repository settings, I configured a retention policy to retain 0 artifacts for specific tags or patterns (e.g., "-feature", "-hotfix", "*-bugfix", etc.).
As an example, for the tag "unknown," I set the retention policy to retain the most recently pushed 0 artifacts using the configuration: "For the repositories matching **, retain the most recently pushed 0 artifacts with tags matching *-unknown."
I saved the changes through the user interface and expected the policy to take effect immediately.
However, after checking the repository, I noticed that the artifacts with the "unknown" tag are not being deleted, and they remain in the Harbor repository.

Expected Behavior: I expected the artifacts with the "unknown" tag to be deleted, following the retention policy configured through the Harbor user interface.

Environment:

Harbor Version: 2.8.3

Additional Information:
I have tried configuring the retention policy for different tags and patterns, including "*-unknown," and none of them are being deleted as per the specified "retain: 0" configuration. The rest of the Harbor functionality appears to be working correctly.

Upon further investigation, I noticed that the retention policy works correctly when the "retain" value is set to a number greater than 1. For example, when I configured the policy to retain "2" artifacts with tags like "-feature", "-hotfix", etc., they were successfully retained.

However, setting the "retain" value to "0" for the retention policy, specifically for the "unknown" tag, does not lead to the expected behavior, and the artifacts are not deleted.

Please let me know if you need any further information to investigate this problem. Thank you!

@zyyw
Copy link
Contributor

zyyw commented Jul 31, 2023

This is because when update retention policy via UI with most recently pushed 0 artifacts, the 0 is double quoted, while the retention policy is most recently pushed 1 artifacts, the 1 is not double quoted. We may need to update the param to a a json integer (without double quotes) sent to backend.
Screenshot 2023-07-31 at 15 22 31
Screenshot 2023-07-31 at 15 23 21

AllForNothing pushed a commit to AllForNothing/harbor that referenced this issue Aug 2, 2023
1. Fixes goharbor#19046

Signed-off-by: AllForNothing <[email protected]>
AllForNothing pushed a commit to AllForNothing/harbor that referenced this issue Aug 2, 2023
1. Fixes goharbor#19046

Signed-off-by: AllForNothing <[email protected]>
AllForNothing pushed a commit to AllForNothing/harbor that referenced this issue Aug 2, 2023
1. Fixes goharbor#19046

Signed-off-by: AllForNothing <[email protected]>
AllForNothing added a commit that referenced this issue Aug 3, 2023
Convert the string "0" to number 0
1. Fixes #19046

Signed-off-by: AllForNothing <[email protected]>
AllForNothing pushed a commit to AllForNothing/harbor that referenced this issue Aug 3, 2023
AllForNothing added a commit that referenced this issue Aug 3, 2023
Convert the string "0" to number 0
1. Fixes #19046

Signed-off-by: AllForNothing <[email protected]>
AllForNothing pushed a commit to AllForNothing/harbor that referenced this issue Aug 3, 2023
1. Fixes goharbor#19046

Signed-off-by: AllForNothing <[email protected]>
AllForNothing added a commit that referenced this issue Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants