Repository navigation
fix(project): stop stamping mirror_user on non-mirrored projects - #415
Merged
henrysachs merged 1 commit intoOct 8, 2026
Conversation
Pull-mirror fields were late-initialized, so every reconcile sent them in the project edit request. GitLab EE treats the presence of any pull-mirror attribute as intent to change mirroring and assigns mirror_user_id to the caller. Deleting that user later disables mirroring and emails owners. Skip late-initializing mirror fields so they stay nil unless set by the user. Signed-off-by: ElaineDeMattosSilvaB <elaine.mattos@gmail.com>
elaine-mattos
marked this pull request as ready for review
October 1, 2026 10:51
dariozachow
approved these changes
Oct 2, 2026
This was referenced Oct 8, 2026
henrysachs
added a commit
that referenced
this pull request
Oct 13, 2026
GitLab EE resets the mirror user to the caller whenever an edit request contains any pull-mirror attribute, and probes the remote when import_url is sent. Update sends the whole spec on any drift, so CRs late-initialized before #415 kept stamping mirror users, and import_url rode along on unrelated updates. Cache the observed project in Observe and drop pull-mirror attributes in Update that equal it. Keep sub-settings while enabling a mirror, since GitLab hides them for non-mirrors, and keep import_url for mirrors, since credential rotation is unobservable. Also move the late-init comment to where the fields used to be and make TestLateInitializeSkipsMirrorFields check a non-mirror field still late-initializes. Signed-off-by: Henry Sachs <henry.sachs@deutschebahn.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note: this change was developed with AI assistance (investigation, drafting, and tests). I have reviewed and tested it, and I take responsibility for its correctness.
When a project does not manage pull mirroring, provider-gitlab still sent the pull-mirror attributes on every reconcile. GitLab EE's
Projects::UpdateServicetreats the mere presence of any pull-mirror attribute as intent to change mirroring and assignsmirror_user_id = current_user.id. When that user is later removed, GitLab disables mirroring and emails the project owners, even though mirroring was never configured.This change stops late-initializing the pull-mirror fields so they stay
nilunless the user sets them. Nil pointers are omitted from the edit request, so GitLab no longer stamps a mirror user on non-mirrored projects. Nil values are treated as up-to-date byisProjectUpToDate, so this does not cause drift, and user-configured mirrors are unaffected (their values are non-nil and still sent).Description of your changes
pkg/namespaced/controller/projects/projects/project.go: remove late-init of pull-mirror attributes;zz_project.go,zz_project_test.go);TestLateInitializeSkipsMirrorFieldsasserting the fields stay nil after late-init when a project has mirroring enabled upstream but unset in spec.Fixes #416
I have:
make reviewable testto ensure this PR is ready for review.How has this code been tested
TestLateInitializeSkipsMirrorFields.make reviewable testpasses (generate is a no-op / in sync, lint andgo test ./...green).