From 2e12d5df0b898f38ca0510c7b375114278982a1c Mon Sep 17 00:00:00 2001
From: Clark Boylan <clark.boylan@gmail.com>
Date: Thu, 5 Mar 2020 13:10:00 -0800
Subject: [PATCH] Fix afs publishing of translation sources

There are at least two problems here. The first is we can't create an
afs token because we don't have access to the afs secret. The old ssh
based secret was removed by:

  https://review.opendev.org/#/c/706734/2/zuul.d/jobs.yaml

Fix that by adding the new opendev tarballs secret to the job.

Next we need to prefix translation sources with translation-source/ in
the filesystem path. This requires us to write out to a different afs
path than normal. To address that we add a new playbook that is aware of
this different path.

Change-Id: I8b49e4d91600377c98e003b806a13fc89d2614ec
---
 .../openstack-translation-artifacts.yaml         | 16 ++++++++++++++++
 zuul.d/jobs.yaml                                 |  5 +++--
 2 files changed, 19 insertions(+), 2 deletions(-)
 create mode 100644 playbooks/translation/openstack-translation-artifacts.yaml

diff --git a/playbooks/translation/openstack-translation-artifacts.yaml b/playbooks/translation/openstack-translation-artifacts.yaml
new file mode 100644
index 0000000000..a35fce38da
--- /dev/null
+++ b/playbooks/translation/openstack-translation-artifacts.yaml
@@ -0,0 +1,16 @@
+- hosts: localhost
+  tasks:
+    - block:
+        - name: Create AFS token
+          include_role:
+            name: create-afs-token
+        - name: Upload to afs
+          include_role:
+            name: upload-afs-synchronize
+          vars:
+            afs_source: "{{ zuul.executor.work_root }}/artifacts/"
+            afs_target: "/afs/.openstack.org/project/tarballs.opendev.org/translation-source/{{ zuul.project.short_name}}/"
+        - name: Destroy AFS token
+          include_role:
+            name: destroy-afs-token
+      when: zuul_success | bool
diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml
index ad3432c978..4c995ee8e9 100644
--- a/zuul.d/jobs.yaml
+++ b/zuul.d/jobs.yaml
@@ -1049,11 +1049,10 @@
     run: playbooks/translation/upstream-translation-update.yaml
     post-run:
       - playbooks/translation/post.yaml
-      - playbooks/publish/openstack-artifacts.yaml
+      - playbooks/translation/openstack-translation-artifacts.yaml
     semaphore: translations
     protected: true
     vars:
-      fileserver_leading_path: translation-source
       constraints_file: '{{ ansible_user_dir }}/src/opendev.org/openstack/requirements/upper-constraints.txt'
     required-projects:
       - openstack/horizon
@@ -1063,6 +1062,8 @@
     nodeset: ubuntu-bionic
     secrets:
       - zanata_api_credentials
+      - secret: afs_tarballs_opendev_org
+        name: afs
 
 - job:
     name: propose-translation-update