Commit Graph

32 Commits

Author SHA1 Message Date
Felix Edel 7761396303 mirror-workspace-git-repos: Retry on failure in git update task
We occasionally see the this task fail for the first element in the
zuul.projects list with a MODULE FAILURE and a return code of -13
(SIGPIPE) [1]. So far we couldn't identify the root cause, so try to
mitigate this issue by retrying on failure. This solution is similar to
the one used for the "Synchronize repos" task[2].

There is a bug report in Ansible that fits

Since it's only the first element in the loop that is failing while
subsequent elements are successful, we currently have two assumptions:

  1. As the task before is using a `delegate_to: localhost' [3],
     there might be a problem with Ansible when switching the connection
     from localhost to the remote host (node).
  2. Since the task before is using the same SSH connection [4] that is
     used by Ansible to push the git repository, there might be some
     "leftovers" on the connection that make the next task fail.
  3. There is also a bug report in Ansible [5] which might be causing
     that error.

[1]:
    {
        "ansible_loop_var": "zj_project",
        "changed": false,
        "failed": true,
        "module_stderr": "",
        "module_stdout": "",
        "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
        "rc": -13,
        "zj_project": {...}
    }

[2]: 3b3495e255/roles/mirror-workspace-git-repos/tasks/main.yaml (L32)
[3]: 3b3495e255/roles/mirror-workspace-git-repos/tasks/main.yaml (L25)
[4]: 3b3495e255/roles/mirror-workspace-git-repos/tasks/main.yaml (L16)
[5]: https://github.com/ansible/ansible/issues/81777

Change-Id: I0c4cb87bb076b9b40c9c446dbe5db437daff5897
2023-12-08 06:37:55 -08:00
Lukas Kranz ce2bea51d4 Deprecate mirror-workspace-git-repos
This change is preparation for https://review.opendev.org/c/zuul/zuul-jobs/+/887917

In the beginning, there was only prepare-workspace[0] which rsynced repos.

Then we added mirror-workspace-git[1] to make it more efficient by using git operation, but it required some openstack-specific code in project-config to work.

Then we added prepare-workspace-git[2] which completed the git-based sync solution by locating everything requried in zuul-jobs.  It used mirror-workspace-git by reference and added this TODO:

  # TODO(tobiash): we might want to deprecate the role mirror-workspace-git-repos
  # and move it here.

This change completes that TODO by moving the mirror-workspace-git-repos code into prepare-workspace-git and places the repo in a sensible and maintainable state with two simple and good options:

 * prepare-workspace (rsync)
 * prepare-workspace-git (git)

In the unlikely event anyone is still using mirror-workspace-git-repos standalone (OpenStack/OpenDev is not, and that solution was haphazard as described above) they would be well served by a notification that there is a better alternative which is what most of the community actually uses now.

[0] cfffd4431b
[1] 348598e96a
[2] 7cee7156bc

Change-Id: Ib80e0447d49363182fd0d4c4d4e269841bc3aa95
2023-09-25 14:51:26 -07:00
Benedikt Loeffler 7f400a0d32 Use zuul_workspace_root for prepare/mirror workspace roles
Use zuul_workspace_root as the destination folder for preparing and
mirroring the workspace, which points to ansible_user_dir by default.
(As is currently the case).
The override of this variable can be useful when using a static node
with multiple slots to use a separate workspace for each slot.

Change-Id: If50abc7ccc2dfb6f4ea9f9d5c6a5091ff6967aef
2023-06-27 14:22:08 +02:00
James E. Blair 09d493916a Correct git config item name in mirror-workspace-git-repos
It appears this setting inadvertently had an extra word "ignore"
included in the key name, and later versions of the git module in
Ansible (5) throw an error in that case.  Remove it so that this
role will work in all versions.

This has been previously tested in a base-test cycle via
test-mirror-workspace-git-repos.

Change-Id: I597aa8d331e53955e826f09aa51a579e12c94f85
2022-05-23 13:13:00 -07:00
Tobias Henkel 3cc366c9c6
Fail mirror-workspace-git-repos if checkout failed
If the checkout failed the mirror-workspace-git-repos must fail the
job. Otherwise this can lead to a broken gate because a different
state than the state that should be tested can be tested silently.

Change-Id: I98e948776ec4b749bc1475ee3a17e37007591118
2021-01-18 14:27:52 +01:00
Benjamin Schanzel 5b66292c55 Multi Node/Context support for mirroring Git workspaces via kubectl
The mirroring of git workspaces to k8s pod nodes is done by piping a git
push command through `kubectl exec`. Without specifying a k8s context
for kubectl, the `current-context` from the kubeconfig is used. This is
problematic in multi-node scenarios where different nodes reside in
different namespaces and thus, are reachable via separate contexts.
Ansible cannot handle the context switch automatically as it would via
the inventory and its kubectl connection plugin because we are running
the git push from the executor/localhost.
This change makes sure the correct context of the corresponding node is
passed to `kubectl exec` explicitly, thus pushing the git repos to the
correct k8s pod.

Change-Id: Ic0b11b5860bb0062b3a1c068f4f963fb76018715
2020-08-17 15:48:14 +02:00
Albin Vass 9062289151 Check for loop_control in with_ type loops
Change-Id: I191265df7709a6262b44a428d78fe28ffaeb4b75
2020-05-01 13:45:34 +02:00
Benjamin Schanzel f18644891d Kubernetes Node Support for Mirroring Git Repos
The `mirror-workspace-git-repos` uses Git to mirror repos from the
executor to build nodes. This comes in handy when the node already
holds a copy of the repo(s), as Git can incrementally update them.
Currently, `mirror-workspace-git-repos` assumes the build node is
directly reachable via ssh. This is (usually) not the case when
running against a Kubernetes Pod build node, thus we can not
efficiently update repos on such nodes using Git.
This change allows pushing Git repos to Kubernetes Pods by bridging
the Git communication over `kubectl` and thereby allowing for the
same behaviour as for standard, non-container, ssh-reachable build
nodes.
(cf. https://git-scm.com/docs/git-remote-ext)

Change-Id: I71919d3bc93e48d5bb24234265fca9c84ce23b87
2020-03-09 14:44:24 +01:00
Albin Vass 110dcaacf9 Clean non-bare remote repos
In case of reused workspaces on static nodes remote
non-bare repos needs to be cleaned up to make sure
that any untracked files from any earlier jobs are removed.

Change-Id: I00dda298f499b241a224c19657ebbb8a9015eb4d
2019-09-06 07:16:05 -07:00
Jeremy Stanley 2711d10186 Be consistent about spaces before and after vars
With the arrival of ansible-lint 4, Jinja2 variable expansions must
include spaces before and after the variable name inside the
brackets.

Adjust the new violations accordingly and remove the rule
206 exclusion.

Change-Id: Ib3ff7b0233a5d5cf99772f9c2adc81861cf34ffa
2019-08-07 20:17:41 +01:00
Tobias Henkel 4ea777ae66
Optionally silence git in mirror-workspace-git-repos
Especially when using Github branch and push workflows repos can
easily have hundreds of branches.  The role mirror-workspace-git-repos
which pushes them onto the node prints all of them in every
build. This can get quite messy. Thus we need to optionally be able to
silence the git push operation. This is done on purpose by the --quiet
parameter instead of using no_log because this way errors are still
logged normally and normal operation produces no log output for this
task.

Change-Id: Id77cc00972df9139e4544dd79954d91f4ab6b60b
2019-02-14 08:52:38 +01:00
Ian Wienand 91bef675d4 mirror-workspace-git-repos: Explicitly show HEAD of checked out branches
This expilicitly notes the HEAD of the checked out tree in the logs.
Currently you'll see something like

 ...  HEAD is now at 9dfb46a18 [wip] install ansible as editable during devel jobs
 ... Already on 'master'
 ... ok: Item: Runtime: 0:00:00.079626

for each project as this loop happens.  However there's no explicit
mention of the project name and you have to reverse engineer what
menioned change relates to what project.

Where this would be useful is when you have an external project
dependency and suddenly your testing stops working due to a change in
it.  You can quickly compare the last good run with the failing HEAD
mentioned here to help bisect the problem.

Change-Id: I84d9a8a460e99d3bc558b3a7584d787b22f2ed33
2018-12-12 16:02:59 +11:00
Tudor Tabacel 719f214db7 mirror-workspace-git: use port when pushing git repo through ssh
In the case of using a custom SSH port to connect to the ansible host,
the task of pushing the repository failed, as it assumed the SSH port to
be the default 22.

Now the command is aware of the custom SSH port, as it is specified in
the host facts.

Note that we have to escape the hostname if it is an ipv6 address
(because : is a special character in ipv6 addresses). Thankfully ansible
provides a filter to do that for us:
https://docs.ansible.com/ansible/2.5/user_guide/playbooks_filters_ipaddr.html#wrapping-ipv6-addresses-in-brackets

Change-Id: I76969850fc3a57078370fe38efdebac146720797
2018-11-19 14:17:31 -08:00
Clark Boylan f6de96597f Revert "mirror-workspace-git: use port when pushing git repo through ssh"
This reverts commit 34cfe44ca5.

The :port suffix doesn't work if the hostname is an ipv6 ip address as
the hostname needs to be wrapped in []s in that case. Revert this so
that we can fix this in a followup.

Change-Id: I2dfee56d40a4cdd096946a2f67c37117fff74cce
2018-11-19 14:06:30 -08:00
Tudor Tabacel 34cfe44ca5
mirror-workspace-git: use port when pushing git repo through ssh
In the case of using a custom SSH port to connect to the ansible host,
the task of pushing the repository failed, as it assumed the SSH port to
be the default 22.

Now the command is aware of the custom SSH port, as it is specified in
the host facts.

Change-Id: I3418016ad5a57e3024a8a553340a7e69b7d1c2fe
2018-11-09 15:00:28 +01:00
Clark Boylan b5ceee2004 Retry failed git pushses on workspace setup
We've seen network/ssh failures to push one of the many git repos into
the workspace. Followup pushes to other repos succeed. Considering that
subsequent pushes do succeed allow for 3 retries to get these workspaces
set up.

Logs below show this happening. The first push of the repo under test
fails (openstack/tripleo-heat-templates) then the push for openstack
requirements succeeds.

  LOOP [mirror-workspace-git-repos : Synchronize src repos to workspace directory]
  Timeout exception waiting for the logger. Please check connectivity to [158.69.64.232:19885]
  ubuntu-xenial -> localhost | ssh: connect to host 158.69.64.232 port 22: No route to host
  ubuntu-xenial -> localhost | fatal: Could not read from remote repository.
  ubuntu-xenial -> localhost |
  ubuntu-xenial -> localhost | Please make sure you have the correct access rights
  ubuntu-xenial -> localhost | and the repository exists.
  ubuntu-xenial -> localhost | ssh: connect to host 158.69.64.232 port 22: No route to host
  ubuntu-xenial -> localhost | fatal: Could not read from remote repository.
  ubuntu-xenial -> localhost |
  ubuntu-xenial -> localhost | Please make sure you have the correct access rights
  ubuntu-xenial -> localhost | and the repository exists.
  ubuntu-xenial -> localhost | To git+ssh://zuul@158.69.64.232//home/zuul/src/git.openstack.org/openstack/requirements
  ubuntu-xenial -> localhost |    66b2988..740ae1a  master -> master
  ubuntu-xenial -> localhost |  * [new branch]      stable/newton -> stable/newton
  ubuntu-xenial -> localhost |  * [new branch]      stable/ocata -> stable/ocata
  ubuntu-xenial -> localhost |  * [new branch]      stable/pike -> stable/pike
  ubuntu-xenial -> localhost |  * [new branch]      stable/queens -> stable/queens
  ubuntu-xenial -> localhost |  * [new branch]      stable/rocky -> stable/rocky
  ubuntu-xenial -> localhost |  * [new branch]      origin/HEAD -> origin/HEAD
  ubuntu-xenial -> localhost |  * [new branch]      origin/master -> origin/master
  ubuntu-xenial -> localhost |  * [new branch]      origin/stable/newton -> origin/stable/newton
  ubuntu-xenial -> localhost |  * [new branch]      origin/stable/ocata -> origin/stable/ocata
  ubuntu-xenial -> localhost |  * [new branch]      origin/stable/pike -> origin/stable/pike
  ubuntu-xenial -> localhost |  * [new branch]      origin/stable/queens -> origin/stable/queens
  ubuntu-xenial -> localhost |  * [new branch]      origin/stable/rocky -> origin/stable/rocky
  ubuntu-xenial -> localhost | ok: Item: Runtime: 0:00:01.828724
  ubuntu-xenial -> localhost | changed: All items complete

  ubuntu-xenial -> localhost | ssh: connect to host 158.69.64.232 port 22: No route to host
  ubuntu-xenial -> localhost | fatal: Could not read from remote repository.
  ubuntu-xenial -> localhost |
  ubuntu-xenial -> localhost | Please make sure you have the correct access rights
  ubuntu-xenial -> localhost | and the repository exists.

  http://logs.openstack.org/56/605356/17/check/openstack-tox-linters/4323abf/ara-report/result/bb14d3fe-338b-4d7a-852f-e66c60d13493/

Related-Bug: 1384373
Change-Id: I6c34d1a6e34762f78b9dd2a2d2a07ceb131a64cc
2018-10-05 12:31:42 -07:00
Monty Taylor 4d2df638d1 Use item.checkout from zuul.projects when mirroring
We need to set the remote HEAD of the repos after we mirror them. We
have been doing that by looking at git status on the local repos to find
what their head has been set to. However, we have 'checkout' in
zuul.projects now, so we can really just use that.

Change-Id: I251da11b7767793278c3f08dcf64aa008e759669
Depends-On: https://review.openstack.org/540948
2018-02-05 11:21:44 -08:00
Doug Hellmann 2943ce05c9 add debug info to mirror-workspace-git-repos
Sometimes the task to determine the local HEAD of projects we've
checked out is failing in a way that we can't parse. Add a step before
the one that fails to show the full git status output to help with
debugging.

Change-Id: I095489249593442e1e9a3b346aed1ecf4135825f
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
2018-02-05 10:06:39 -05:00
Ian Wienand 80f5a7eeb4 Convert back to zuul.projects
Zuul has transitioned zuul.projects to a dict that mirrors
zuul._projects.  Convert users back to zuul.projects so we can remove
the underscore version in zuul.

Change-Id: I1408a15d4da274f3fc911f03d5572f4818bc4ebb
Depends-On: I3c011f72933e98ccbf8badf0e9197c8659766c51
2017-12-01 15:02:20 +11:00
David Moreau Simard 5d751bab12
mirror-workspace-git-repos: Pass a dict, not a list containing a dict
This was a regression introduced in the commit
b1b2537de7

Change-Id: Ib5ed93491631f22472a3eb4913d29d20a78592cd
2017-11-30 10:29:34 -05:00
Ian Wienand b1b2537de7
Move to dictionary list of projects zuul._projects (take 2)
This is a revert of commit f28cc33bc3
which was a revert of the original attempt at moving to zuul._projects
(df98773573).

The issue was that the order of projects in "Determine local HEAD" was
not the same as "Update remote repository state" and we ended up
checking out the wrong thing.

To avoid this, build the projects and their current heads on the
exectutor into a separate dict, and as we iterate the projects look up
the correct values in that.

Change-Id: I0d9a66435714efe42fb653aafc6cb71b08ca6b8a
2017-11-29 17:56:08 -06:00
James E. Blair f28cc33bc3 Revert "Move to dictionary list of projects zuul._projects"
This reverts commit df98773573.

The order in which we iterate over items in the "determine local HEAD"
task is not always the order in which we iterate over mirror-workspace-
git-repos.

Change-Id: I181d6a2cfa2c3104730f20362bbdc10fa582339f
2017-10-29 10:37:31 -07:00
Ian Wienand df98773573 Move to dictionary list of projects zuul._projects
Zuul exports the projects list as a dictionary in _projects in the
depends-on.  The idea is that we switch these jobs to that, and do
some testing.  When ready, we switch "projects" to be the dictionary
view, and revert "_project" calls here to "project".

Change-Id: Id9a7c137ca5bed25d81087201091157c8401576a
Depends-On: I4476b9d4915d107e29b91229287865bff0ada305
2017-10-28 17:46:41 +02:00
Andreas Jaeger 0506323c2b Ansible linting fixes
Fix a few problems noticed when using this in project-config:
* Ignore apt-get warning in configure-mirrors
* All tasks should be named in upload-logs, emit-job-header
* use git_config in mirror-workspace-git-repos
* Ignore git warnings in mirror-workspace-git-repos

Change-Id: Ibcdc8d5a42fb081b5faa0cc89460e4cf88d369ba
2017-10-27 19:18:15 +02:00
James E. Blair dcd89b2686 Revert "Fix linting issues found via project-config"
This has syntax errors.

This reverts commit d3128dab95.

Change-Id: Ida6569d384f50095cc228625c7d6e73e154270ae
2017-09-14 13:10:22 -06:00
Jesse Keating d3128dab95 Fix linting issues found via project-config
There are no playbooks that use the roles in this repo in a way that
would lint them, however running linters in project-config found
numerous issues in these roles. Correct the roles.

Change-Id: I017532c8aed8fd90474052423c7ba2510cf84631
Signed-off-by: Jesse Keating <omgjlk@us.ibm.com>
2017-09-13 14:56:59 -06:00
James E. Blair 44e8254679 Fix error in mirror-workspace-git-repos
Change-Id: I24d8fd400362ea6a20bc068617e863f98c3e3170
2017-08-31 11:51:10 -07:00
Monty Taylor dd6bf58d66
Handle pushing to non-bare remote repos
When we're pushing to a non-bare repo, git has a sad if we push to the
branch that's checked out. But that's ok - we're going to update the
checked out state anyway as a follow up. Tell git it's ok.

Then, after we've pushed, we need to reset after having pushed branch HEAD
to a non bare repo. Clean up after ourselves by removing the config
setting we added to allow the push in the first place.

Change-Id: Id84e9af9d33519e515b8e6d330b375a8e17c14f5
2017-08-31 09:38:49 -05:00
James E. Blair 1451be950a Fix checkout in mirror-workspace-git-repos
This task happens on the remote node.

Change-Id: I68ac25fb69a0f7468f73ae856ace2545154eacae
2017-08-30 16:00:31 -07:00
James E. Blair e8b82ac4de Fix error in mirror-workspace-git-repos
The project src_dir contains 'src/', so use work_root instead of
src_root.

Change-Id: I3017dded1a8baf7fcad0b47a759dfc9f7355d0b1
2017-08-30 15:53:08 -07:00
James E. Blair 232a35d3ac Fix errors in mirro-workspace-git-repos
The command and shell tasks take these arguments under the 'args'
dict.

Change-Id: I643c371141125528334555dc72abdbdb7c3ef741
2017-08-29 17:57:33 -07:00
James E. Blair 348598e96a Add mirror-workspace-git-repos role
Change-Id: I6958e95a9ea31ab8ae027a9b33069d74be615d91
2017-08-29 16:15:54 -07:00