Skip to content

fix(project): stop stamping mirror_user on non-mirrored projects - #415

Merged
henrysachs merged 1 commit into
crossplane-contrib:masterfrom
elaine-mattos:fix/project-mirror-user-stamped-on-every-reconcile
Oct 8, 2026
Merged

henrysachs merged 1 commit into
crossplane-contrib:masterfrom
elaine-mattos:fix/project-mirror-user-stamped-on-every-reconcile

Conversation

@elaine-mattos

@elaine-mattos elaine-mattos commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

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::UpdateService treats the mere presence of any pull-mirror attribute as intent to change mirroring and assigns mirror_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 nil unless 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 by isProjectUpToDate, 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;
  • Regenerated the cluster-scope equivalents (zz_project.go, zz_project_test.go);
  • Added TestLateInitializeSkipsMirrorFields asserting the fields stay nil after late-init when a project has mirroring enabled upstream but unset in spec.

Fixes #416

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable test to ensure this PR is ready for review.

How has this code been tested

  • Added TestLateInitializeSkipsMirrorFields.
  • make reviewable test passes (generate is a no-op / in sync, lint and go test ./... green).

   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
elaine-mattos marked this pull request as ready for review October 1, 2026 10:51
@henrysachs
henrysachs merged commit c2d1d26 into crossplane-contrib:master Oct 8, 2026
8 of 9 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

provider-gitlab unconditionally sends pull-mirror attributes on Project edit, causing GitLab to assign mirror_user on every reconcile

3 participants