Ivan Berezovskiy | 3895982 | 2019-09-26 16:29:51 +0400 | [diff] [blame^] | 1 | ======================= |
| 2 | Salt formula backports |
| 3 | ======================= |
| 4 | ------------ |
| 5 | Readme file |
| 6 | ------------ |
| 7 | |
| 8 | Setting up downstream mirror |
| 9 | ============================ |
| 10 | |
| 11 | Setup formula syncronisation after you deployed Drivertain. The backport state can be used to apply any patches/modification which hadn't been included to offical packages. The state uses the backports:patches pillar to keep the neccessary information. |
| 12 | |
| 13 | Step 1: |
| 14 | Check jenkins_admin_public_key and add it to service user in gerrit(git repo). |
| 15 | |
| 16 | Got to https://gerrit.mirantis.com/login/ |
| 17 | Login as "service" user. |
| 18 | Navigate to Setting -> SSH Public Keys. |
| 19 | Add new key. |
| 20 | |
| 21 | Step 2: |
| 22 | |
| 23 | Add following pillar to cicd leader:: |
| 24 | |
| 25 | parameters: |
| 26 | _param: |
| 27 | jenkins_git_mirror_downstream_jobs: |
| 28 | - name: salt-formula-backports |
| 29 | downstream: formulas/salt-formula-backports |
| 30 | upstream: "ssh://robot@gerrit.example.com:29418/formulas/salt-formula-backports" |
| 31 | branches: master |
| 32 | gerrit: |
| 33 | client: |
| 34 | project: |
| 35 | formulas/salt-formula-backports: |
| 36 | enabled: true |
| 37 | description: Backport formula |
| 38 | upstream: "ssh://robot@gerrit.example.com:29418/formulas/salt-formula-backports" |
| 39 | access: ${gerrit:client:default_access} |
| 40 | require_change_id: true |
| 41 | require_agreement: false |
| 42 | merge_content: true |
| 43 | |
| 44 | Step 3: |
| 45 | Run the highstate on cid01 node:: |
| 46 | |
| 47 | salt "cid01*" state.highstate |
| 48 | |
| 49 | Setting up downstream mirror |
| 50 | ============================ |
| 51 | |
| 52 | This this is how you can setup automated formula installation on salt master from local gerrit. |
| 53 | Step 1: |
| 54 | Add following pillar to config:: |
| 55 | |
| 56 | root@cfg01:/srv/salt/reclass# cat ./classes/cluster/mlab/infra/backports/formula.yml |
| 57 | parameters: |
| 58 | _param: |
| 59 | local_salt_formulas: http://${_param:cicd_control_address}:8080/formulas |
| 60 | local_salt_formulas_revision: master |
| 61 | salt: |
| 62 | master: |
| 63 | environment: |
| 64 | prd: |
| 65 | formula: |
| 66 | backports: |
| 67 | source: git |
| 68 | address: '${_param:local_salt_formulas}/salt-formula-backports' |
| 69 | revision: ${_param:local_salt_formulas_revision} |
| 70 | |
| 71 | |
| 72 | Step 2: |
| 73 | |
| 74 | Run the highstate on cfg01 node:: |
| 75 | |
| 76 | salt 'cfg01*' state.highstate |
| 77 | |
| 78 | How to enable specific patch |
| 79 | ============================ |
| 80 | For example to enable patch on salt master's ntp formula |
| 81 | |
| 82 | Add following class or define the pillar on the salt master (make sure pillar is visible only for this particular node):: |
| 83 | |
| 84 | root@cfg01:/srv/salt/reclass# cat ./classes/cluster/lab/infra/config/patches.yml |
| 85 | applications: |
| 86 | - backports |
| 87 | |
| 88 | parameters: |
| 89 | backports: |
| 90 | patches: |
| 91 | compute_patch: # you can refer to jira issue, gerrit CR, salesforce ID or any other id. |
| 92 | /etc/init/nova-compute-kvm-upstart.conf: # file to apply the patch |
| 93 | md5sum: 34dd520613bda0bf572a3bcee5767d29 # md5sum of resulted file |
| 94 | diff: | |
| 95 | --- /etc/init/nova-compute-kvm-upstart.conf 2018-03-31 20:48:30.000000000 +0800 |
| 96 | +++ nova-compute-kvm-upstart.conf.orig 2019-05-07 20:58:26.601836128 +0800 |
| 97 | @@ -1,7 +1,7 @@ |
| 98 | description "OpenStack Compute" |
| 99 | author "Thomas Goirand <zigo@debian.org>" |
| 100 | |
| 101 | -start on started libvirt-bin |
| 102 | +start on started libvirtd |
| 103 | stop on runlevel [!2345] |
| 104 | |
| 105 | chdir /var/run |
| 106 | |
| 107 | |
| 108 | How to create a new patch |
| 109 | ========================= |
| 110 | |
| 111 | Back original file:: |
| 112 | |
| 113 | cp /etc/init/nova-compute-kvm-upstart.conf nova-compute-kvm-upstart.conf.orig |
| 114 | |
| 115 | Make the necessary change:: |
| 116 | |
| 117 | vim /etc/init/nova-compute-kvm-upstart.conf |
| 118 | |
| 119 | Run the diff command to see the difference between files:: |
| 120 | |
| 121 | diff -u nova-compute-kvm-upstart.conf.orig /etc/init/nova-compute-kvm-upstart.conf |
| 122 | |
| 123 | --- /etc/init/nova-compute-kvm-upstart.conf 2018-03-31 20:48:30.000000000 +0800 |
| 124 | +++ nova-compute-kvm-upstart.conf.orig 2019-05-07 20:58:26.601836128 +0800 |
| 125 | @@ -1,7 +1,7 @@ |
| 126 | description "OpenStack Compute" |
| 127 | author "Thomas Goirand <zigo@debian.org>" |
| 128 | |
| 129 | -start on started libvirt-bin |
| 130 | +start on started libvirtd |
| 131 | stop on runlevel [!2345] |
| 132 | |
| 133 | chdir /var/run |
| 134 | |
| 135 | Save the output into files direcotry in formula:: |
| 136 | |
| 137 | files/patch-init-nova-compute.conf |
| 138 | |
| 139 | check the md5 sum for the file and add into resource:: |
| 140 | |
| 141 | md5sum /etc/init/nova-compute-kvm-upstart.conf |
| 142 | 34dd520613bda0bf572a3bcee5767d29 /etc/init/nova-compute-kvm-upstart.conf |
| 143 | |
| 144 | This info should be enough to create the pillar data:: |
| 145 | |
| 146 | backports: |
| 147 | patches: |
| 148 | compute_patch: |
| 149 | /etc/init/nova-compute-kvm-upstart.conf: |
| 150 | md5sum: 34dd520613bda0bf572a3bcee5767d29 |
| 151 | diff: | |
| 152 | --- /etc/init/nova-compute-kvm-upstart.conf 2018-03-31 20:48:30.000000000 +0800 |
| 153 | +++ nova-compute-kvm-upstart.conf.orig 2019-05-07 20:58:26.601836128 +0800 |
| 154 | @@ -1,7 +1,7 @@ |
| 155 | description "OpenStack Compute" |
| 156 | author "Thomas Goirand <zigo@debian.org>" |
| 157 | |
| 158 | -start on started libvirt-bin |
| 159 | +start on started libvirtd |
| 160 | stop on runlevel [!2345] |
| 161 | |
| 162 | chdir /var/run |
| 163 | |
| 164 | If the patch data contains any special characters and pillar is failed to build you can use base64 enconding for patch code:: |
| 165 | |
| 166 | |
| 167 | backports: |
| 168 | patches: |
| 169 | compute_patch: |
| 170 | /usr/share/salt-formulas/env/oslo_templates/files/queens/oslo/messaging/_rabbit.conf: |
| 171 | md5sum: 73a3eebf769b3038a7c65a5019141938 |
| 172 | encoding: base64 |
| 173 | diff: | |
| 174 | RnJvbSBiOTIzMGIzMGYwNGRkOTE4YzliOWI0NzkzYjIwNWYwYTZmM2M2ZDZmIE1vbiBTZXAgMTcg |
| 175 | ... |
| 176 | ID0ge3sgX2RhdGEucnBjX3JldHJ5X2RlbGF5IH19Cit7JS0gZW5kaWYgJX0K |
| 177 | |
| 178 | |
| 179 | Best practice: |
| 180 | ============== |
| 181 | |
| 182 | 1. Make sure product bug/ticket/review is created to resolve the problem in upstream. |
| 183 | 2. Add a link to the product ticket/review next to the resource in the formula. |
| 184 | 3. Make sure to add service restart if needed. |
| 185 | 4. Pay attention to failed patch resources. Most likely this means that file was changed. review the file and update or disable the patch if necessary. |
| 186 | |
| 187 | |
| 188 | Full pillar list: |
| 189 | ================= |
| 190 | |
| 191 | Pillar:: |
| 192 | |
| 193 | applications: |
| 194 | - backports |
| 195 | |
| 196 | parameters: |
| 197 | backports: |
| 198 | patch_directory: "/tmp/patches" |
| 199 | patches: |
| 200 | PROD-26834: |
| 201 | /usr/share/salt-formulas/env/jenkins/client/init.sls: |
| 202 | md5sum: bdce63b782f9056338cd43114b9b7dfc |
| 203 | diff: | |
| 204 | diff --git a/jenkins/client/init.sls b/jenkins/client/init.sls |
| 205 | index 9c8509c..85cacb3 100644 |
| 206 | ...... |
| 207 | - jenkins.client.throttle_category |
| 208 | {%- endif %} |
| 209 | /usr/share/salt-formulas/env/jenkins/_states/jenkins_location.py: |
| 210 | md5sum: e9212236971306230710b41493d7d2fa |
| 211 | diff: | |
| 212 | diff --git a/_states/jenkins_location.py b/_states/jenkins_location.py |
| 213 | new file mode 100644 |
| 214 | index 0000000..7aac8bf |
| 215 | ...... |
| 216 | + ['CHANGED', 'EXISTS'], |
| 217 | + {'url': url, 'email': email}, |
| 218 | + 'location config') |
| 219 | |