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

Add fly clear-versions command #8196

Merged
merged 8 commits into from
May 13, 2022
Merged

Add fly clear-versions command #8196

merged 8 commits into from
May 13, 2022

Conversation

clarafu
Copy link
Contributor

@clarafu clarafu commented Mar 24, 2022

Changes proposed by this PR

closes #5418

I added a fly command that will clear the version history for a resource or a resource type. It will print out a warning message before it executes the deletion in order to show the user which other resources/resource-types are affected if they are sharing the same version history.

Only admin users will be able to use this command because of how it can be used to delete version histories of resources/resource-types across pipelines/teams.

Through adding this fly command, I had to add 4 API endpoints. 2 are for listing out the resources/resource-types that share the same resource_config_scope_id (meaning that they are sharing the same version history). The other 2 endpoints are for clearing the version history for the resource or resource type.

  • done
  • todo

Release Note

  • Can be used to clear version history of a resource or resource type
  • Can only be used by an admin user
  • If you have global-resources enabled, it can possibly delete version histories of other resources/resource-types in other pipelines so there is a warning message that will show any resources or resource types that are affected.

I created two endpoints, one for clearing resource versions and the
other for clearing resource type versions. They both do the same thing
where if an admin runs the endpoint, it will trust and clear the
resource/resource type versions through it's scope. This means that if
the resource is sharing the scope with other resources, it will also
clear the versions for the other resources as well. There will be a
validation phase in the fly command that I will implement in the next
commit that will tell the user which resources will be affected by this
clearing of versions and if the user is sure they want to continue with
the clearing of versions.

[#5418]

Signed-off-by: Clara Fu <fclara@vmware.com>
Added two endpoints for fetching the resources or resource types that
are sharing the same resource config scope id as the one that is passed
into the endpoint. There are two endpoints because one is for finding
the shared resources/resource types of a resource and the other is for a
resource type. The endpoints are basically the exact same though.

These endpoints are added for the fly clear-versions command that will
be added because it will be used to display to the user what
resources/resource types will be affected by the clearing of versions.

[#5418]

Signed-off-by: Clara Fu <fclara@vmware.com>
Modify the clear versions for resource and resource type to return the
number of versions that were deleted. This will be shown in the fly
command after you have deleted versions using the clear versions fly
command.

[#5418]

Signed-off-by: Clara Fu <fclara@vmware.com>
The clear-versions command can take in either a resource or a resource
type to clear the versions for. It will also print a warning message
with all the resources/resource types that the clearing of versions will
affect.

Also added the endpoints to the go-concourse package so that they can be
used by fly.

[#5418]

Signed-off-by: Clara Fu <fclara@vmware.com>
thanks rui!

[#5418]

Signed-off-by: Clara Fu <fclara@vmware.com>
Addresses review comment to write the error to stdout when it fails with
500 in the api endpoints. I only added it to the db methods that have a
higher chance of erroring vs the other db methods that is only for
information gathering.

[#5418]

Signed-off-by: Clara Fu <fclara@vmware.com>
[#5418]

Signed-off-by: Clara Fu <fclara@vmware.com>
[#5418]

Signed-off-by: Clara Fu <fclara@vmware.com>
@clarafu
Copy link
Contributor Author

clarafu commented Apr 20, 2022

@xtremerui Should be ready to be re-reviewed! :)

Copy link
Contributor

@xtremerui xtremerui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manually run the concourse and build fly to test the new command. Works good for me!

@clarafu clarafu merged commit c9178ef into master May 13, 2022
@clarafu clarafu deleted the fly-clear-versions branch May 13, 2022 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clear resource versions fly command
2 participants