Commit Graph

8 Commits

Author SHA1 Message Date
Ian Wienand 73951559fc upload-git-mirror: no_log around key writing
Add no_log here as a fallback against ever leaving the output in the
logs.

Change-Id: Ia3d518d915705b40e0e12e25e0a0787a8cf614d7
2022-07-28 09:31:49 +10:00
Ian Wienand 6d23d20f2f linters: add names to blocks
This is preparation for a later version of ansbile-lint, which finds
missing names on blocks.  This seems a reasonable rule, and the
Ansible manual says [1]

  Names for blocks have been available since Ansible 2.3. We recommend
  using names in all tasks, within blocks or elsewhere, for better
  visibility into the tasks being executed when you run the playbook.

This simply adds a name tag for blocks that are missing it.  This
should have no operational change, but allows us to update the linter
in a follow-on change.

[1] https://docs.ansible.com/ansible/latest/user_guide/playbooks_blocks.html

Change-Id: I92ed4616775650aced352bc9088a07e919f1a25f
2022-07-27 17:13:39 +10:00
Ian Wienand 0956167b8c upload-git-mirror: fix ssh key newline
I don't think this testing has been run of Focal before, and the ssh
there is more picky about trailing newlines in the ssh private key.
Ensure it has a newline to avoid problems.

While we're here, clean up an old unused argument

Change-Id: If300083b9bc8e5538dcb1eeeaa896ba22c21232e
2022-07-27 14:42:00 +10:00
Thierry Carrez a6fab9c48f upload-git-mirror: use retries to avoid races
To avoid errors in case of mirror race conditions, we currently
(try to) ignore mirror errors, and check for presence of the
reference after the mirror try. This requires having to play
tricks to avoid errors when the job is run in the check pipeline,
due to missing zuul.newrev. And for some reason, it does not seem
to work[1].

Instead of ignoring errors and running an additional check, let's
just retry the mirror operation three times.

The race is rare-enough that it's very unlikely that we would
hit it three times in a row.

[1] https://zuul.openstack.org/build/4966cd5617624d348fa0048de14f1f96

Change-Id: Ifa4f25ad8c961a1b2dbd9f07a3a1e4652b790c9c
2020-06-26 13:15:41 +02:00
Thierry Carrez e53fe850c8 upload-git-mirror: check after mirror operation
The upload-git-mirror job currently reports failure when multiple
jobs run concurrently for the same repository (one of them succeeds,
the other fails because the state of the mirror was changed by the
successful one).

However, since the job generally runs a few minutes after the commit
that triggered it merged, the successful job usually mirrored the two
needed commits, so the failed mirror operation does not mean the
mirror is out-of-sync. This results in false negatives.

If zuul.newrev is provided, rather than report failure if the mirror
operation fails, we should report failure if, after the mirror operation,
the commit that triggered the job is still not present on the mirror.

Change-Id: Iadae26473f4c937384c8cea74329e389c563aeed
2020-06-24 18:01:10 +02:00
David Moreau Simard ed9f1d14a0
Add parameter to upload-git-mirror to specify ssh host key
If we attempt to push a mirror to a host we've never connected to
before, it won't be in the SSH known hosts and the mirror will fail.

This makes a new host_key parameter required and the role takes care
of setting it up in the known_hosts for the duration of the job.

Change-Id: I4bd40a289003fe3e88c9af4029576236c064fc3d
Depends-On: https://review.openstack.org/#/c/649183/
2019-04-01 16:34:59 -04:00
David Moreau Simard 61cd01cb77
Fix typo in upload-git-mirror README
Change-Id: I71db9faa488ce496862e1487e615401df467909f
2019-03-28 10:39:25 -04:00
David Moreau Simard 614c6c043e Add a role to mirror a git repository to a remote git server
This role is meant to replicate a successfully tested git repository
to a remote git server over SSH during the POST pipeline.

Change-Id: I562802ede7358c809c915f09f229884d81cc5b31
Depends-On: https://review.openstack.org/643435
2019-03-26 09:24:19 -07:00