Skip to content

Support converting repository type #6469

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

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open

Conversation

LucasG0
Copy link
Contributor

@LucasG0 LucasG0 commented May 14, 2025

This PR adds support for converting repository type, ie read-write to read-only and vice versa. It mainly contains some refactoring around the repository creation mutation so we can reuse this logic after converting an object.

@github-actions github-actions bot added the group/backend Issue related to the backend (API Server, Git Agent) label May 14, 2025
@LucasG0 LucasG0 force-pushed the lgu-convert-repos branch from 9b02ae9 to 389f21b Compare May 14, 2025 16:46
Copy link

codspeed-hq bot commented May 14, 2025

CodSpeed Performance Report

Merging #6469 will not alter performance

Comparing lgu-convert-repos (3cc29fa) with develop (8001fb5)

Summary

✅ 10 untouched benchmarks

@LucasG0 LucasG0 force-pushed the lgu-convert-repos branch 4 times, most recently from 48540b8 to 1cb2a46 Compare May 15, 2025 10:05
@LucasG0 LucasG0 marked this pull request as ready for review May 15, 2025 12:30
@LucasG0 LucasG0 requested a review from a team as a code owner May 15, 2025 12:30
@LucasG0 LucasG0 requested review from ogenstad and ajtmccarty May 19, 2025 08:18
parameters={"model": git_repo_add_model},
)

# TODO Validate that the creation of the repository went as expected
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can just delete this

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should be adding more files under infrahub.core, at least we should have a discussion around it. I think we can keep these changes here until we have decided but it but we should have some consistent thought around where things are placed.

@LucasG0 LucasG0 force-pushed the lgu-convert-repos branch from 356d6d3 to 4bdb07f Compare May 20, 2025 08:55
Copy link
Contributor

@ogenstad ogenstad left a comment

Choose a reason for hiding this comment

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

I think this looks good. I have two comments around the changes.

  1. Do we need to lock the repository for git operations while we are doing this conversion? Potentially there will be some tasks that could fail during the conversion. I.e. if the task starts off and expects a managed repository to exist but then it ends up being a read-only repository before the task has completed. The a worse problem would be if we're syncing the repo and a new commit is observed. It might be that this operation would simply fail, alternatively we'd wait until a mutation lock has been released. Do you have any thoughts around that?

  2. For a repository that lives on multiple branches where the commit value is different on a number of the branches, given the mappings we have in place would it be at all possible to set the expected commit values for the branches once we converted the repository or what would happen?

parameters={"model": git_repo_add_model},
)

# TODO Validate that the creation of the repository went as expected
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should be adding more files under infrahub.core, at least we should have a discussion around it. I think we can keep these changes here until we have decided but it but we should have some consistent thought around where things are placed.


assert repository.commit.value
assert repository.internal_status.value == "active"
# assert repository.operational_status.value == "online" --> it's unknown, is this an issue?
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this an issue in the tests or something that we'd see in production as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When we create a ReadOnlyRepository, fetch method is not called, which is responsible for setting the operational status, while it's the case for a read write Repository. I believe this may currently happen in production. I am not sure whether InfrahubReadOnlyRepository.sync_from_remote should call this fetch method or if this status should be set through another way.

@LucasG0 LucasG0 force-pushed the lgu-convert-repos branch from 4bdb07f to 3cc29fa Compare May 28, 2025 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
group/backend Issue related to the backend (API Server, Git Agent)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants