]> scripts.mit.edu Git - wizard.git/blob - TODO
Add refactoring comments.
[wizard.git] / TODO
1 The Git Autoinstaller
2
3 TODO NOW:
4
5 - Better error message if daemon/scripts-security-upd
6   is not on scripts-security-upd list
7
8 - Refactor log model out of deploy
9 - Refactor @staticmethod's for building from parallel-find to factory
10 - Refactor get*() into properties
11
12 - Add repository flag to migrate so that we can specify an
13   arbitrary repository to migrate to
14
15 - Build automation for generating config files; this automation
16   will be shared with the migrate script and the installer script
17   (migrate script needs to be able to pull out values from config
18   file, so will we; installer script needs to be able to run
19   the installer to generate config files, so will this)
20
21 - The great initial deploy:
22     - Turn on mediawiki new autoinstaller
23     - Migrate all mediawiki installs
24
25 - Consider making usermode wizard operation a support mode
26   (mostly for letting users upgrade things themself)
27
28 - Implement proper deploy log parsing; this basically means we
29   need to be able to introspect Git Log. Consider using git-python
30   for this.  There's also missing functionality, bad error handling
31   and hacks in the prototype implementation of upgrade
32
33 - Wordpress needs to have .scripts dir in all -scripts versions
34   (remember --no-walk!) (also make .scripts/.htaccess)
35 - Wordpress needs to have a .scripts/update script written for
36   its latest version (do this after its migration)
37 - Wordpress needs to check for php.ini files (which it almost
38   certianly has) and commit messages
39 - Wordpress needs user config and php.ini links made
40
41 - Summary script should be more machine friendly, and should not
42   output summary charts when I increase specificity
43 - Check how many autoinstalls are missing w bits for
44   daemon.scripts (this would need pyafs)
45 - Consider fixing Wizard's commit messages
46
47 PULLING OUT CONFIGURATION FILES IN AN AUTOMATED MANNER
48
49 advancedpoll: Template file to fill out
50 django: Noodles of template files
51 gallery2: Multistage install process
52 joomla: Template file
53 mediawiki: One-step install process
54 phpbb: Multistage install process
55 phpical: Template file
56 trac: NFC
57 turbogears: NFC
58 wordpress: Multistage install process
59
60 PHILOSOPHY ABOUT LOGGING
61
62 Logging is most useful when performing a mass run.  This
63 includes things such as mass-migration as well as when running
64 summary reports.  An interesting property about mass-migration
65 or mass-upgrade, however, is that if they fail, they are
66 idempotent, so an individual case can be debugged simply running
67 the single-install equivalent with --debug on.  (This, indeed,
68 may be easier to do than sifting through a logfile).
69
70 It is a different story when you are running a summary report:
71 you are primarily bound by your AFS cache and how quickly you can
72 iterate through all of the autoinstalls.  Checking if a file
73 exists on a cold AFS cache may
74 take several minutes to perform; on a hot cache the same report
75 may take a mere 3 seconds.  When you get to more computationally
76 expensive calculations, however, even having a hot AFS cache
77 is not enough to cut down your runtime.
78
79 There are certain calculations that someone may want to be
80 able to perform on manipulated data.  As such, this data should
81 be cached on disk, if the process for extracting this data takes
82 a long time.  Also, for usability sake, Wizard should generate
83 the common case reports.
84
85 Ensuring that machine parseable reports are made, and then making
86 the machinery to reframe this data, increases complexity.  Therefore,
87 the recommendation is to assume that if you need to run iteratively,
88 you'll have a hot AFS cache at your fingerprints, and if that's not
89 fast enough, then cache the data.
90
91 COMMIT MESSAGE FIELDS:
92
93 Installed-by: username@hostname
94 Pre-commit-by: Real Name <username@mit.edu>
95 Upgraded-by: Real Name <username@mit.edu>
96 Migrated-by: Real Name <username@mit.edu>
97 Wizard-revision: abcdef1234567890
98 Wizard-args: /wizard/bin/wizard foo bar baz
99
100 GIT COMMIT FIELDS:
101
102 Committer: Real Name <username@mit.edu>
103 Author: lockername locker <lockername@scripts.mit.edu>
104
105 NOTES:
106
107 - A perfectly formed autoinstall with upgrade paths for all of
108   the intervening versions is not really feasible to implement.
109   As such, we want to migrate everything to -scripts, and then
110   generate a -scripts2 with the correct .scripts directory.
111   We will then nop update some installs, but this will prevent
112   us from having to migrate and update concurrently.  Treat
113   a scripts2 upgrade from migration the same way you would treat
114   a botched scripts upgrade.
115
116 - Currently all repositories are initialized with --shared, which
117   means they have basically ~no space footprint.  However, it
118   also means that /mit/scripts/wizard/srv MUST NOT lose revs.
119
120 - Full fledged logging options. Namely:
121   x all loggers (delay implementing this until we actually have debug stmts)
122     - default is WARNING
123     - debug     => loglevel = DEBUG
124   x stdout logger
125     - default is WARNING (see below for exception)
126     - verbose   => loglevel = INFO
127   x file logger (only allowed for serial processing)
128     - default is OFF
129     - log-file   => loglevel = INFO
130   x database logger (necessary for parallel processing, not implemented)
131     - default is OFF
132     - log-db    => loglevel = INFO
133
134 - More on the database logger: it will be very simple with one
135   table named `logs` in SQLite, with columns: `job`, `level`,
136   `message`.  Job identifies the subprocess/thread that emitted
137   the log, so things can be correlated together.  We will then
138   have `wizard dump` which takes a database like this and dumps
139   it into a file logger type file.  The database may also store
140   a queue like structure which can be used to coordinate jobs.
141
142 OVERALL PLAN:
143
144 * Some parts of the infrastructure will not be touched, although I plan
145   on documenting them.  Specifically, we will be keeping:
146
147     - parallel-find.pl, and the resulting
148       /mitalso make .scripts/.htaccess/scripts/sec-tools/store/scriptslist
149       This script might need to be adapted if we decide to nuke
150       .scripts-version files.
151
152     - The current install scripts will be kept in place, sans changes
153       necessary to make them use Git install of copying the script over.
154       Porting these scripts to Python and making them modular would be
155       nice, but is priority.  For the long term, seeing this scripts
156       be packaged with rest of our code would be optimal.
157
158 * The new procedure for generating an update is as follows:
159   (check out the mass-migration instructions for something in this spirit,
160   although uglier in some ways)
161
162     0. ssh into not-backward, temporarily give the daemon.scripts-security-upd
163        bits by blanching it on system:scripts-security-upd, and run parallel-find.pl
164
165     1. Have the Git repository and working copy for the project on hand.
166
167     2. Checkout the pristine branch
168
169     3. Remove all files from the working copy.  Use `wipe-working-dir`
170
171     4. Download the new tarball
172
173     5. Extract the tarball over the working copy (`cp -R a/. b` works well,
174        remember that the working copy is empty)
175
176     6. Check for empty directories and add stub files as necessary.
177        Use `preserve-empty-dir`
178
179     7. Git add it all, and then commit as a new pristine version (v1.2.3)
180
181     8. Checkout the master branch
182
183     9. [FOR EXISTING REPOSITORIES]
184        Merge the pristine branch in. Resolve any conflicts that our
185        patches have with new changes. Do NOT let Git auto-commit it
186        with --no-commit (otherwise, you want to git commit --amend
187        to keep our history clean
188
189        [FOR NEW REPOSITORIES]
190        See if any patches are needed to make this run smoothly on
191        scripts.
192
193     [FOR NEW REPOSITORIES]
194         mkdir .scripts
195         echo "Deny from all" > .scripts/.htaccess
196         touch .scripts/update
197         chmod a+x .scripts/update
198
199    10. Check if there are any special update procedures, and update/create the
200        .scripts/update shell script as necessary (this means that any
201        application specific update logic will be kept with the actual
202        source code.  The language of this update script will vary
203        depending on context.)
204
205    11. Commit your changes, and tag as v1.2.3-scripts (or scripts2, if
206        you are amending an install without an upstream changes)
207
208    12. Test the new update procedure using
209        `wizard upgrade --with=/path/to/repo /your/autoinstall` (this will
210        read out master as your "latest" version).
211        Use git commit --amend to fix any bugs (alternatively, squash them
212        together later).
213
214    13. You can also do a "mass" version of this using:
215        `wizard -d testbed.txt massupgrade --with=/path/to/repo app`
216        You'll need perms for any testbed stuff you want.
217
218       GET APPROVAL BEFORE PROCEEDING ANY FURTHER
219
220       NOTE: The following commands are to be run on not-backward.mit.edu.
221       You'll need to add daemon.scripts-security-upd to
222       scripts-security-upd to get bits to do this.  Make sure you remove
223       these bits when you're done.
224
225    14. Run `wizard research appname`
226        which uses Git commands to check how many
227        working copies apply the change cleanly, and writes out a logfile
228        with the working copies that don't apply cleanly.  It also tells
229        us about "corrupt" working copies.
230
231    15. Run `wizard massupgrade appname`, which applies the update to all working
232        copies possible, and sends mail to users to whom the working copy
233        did not apply cleanly. It also frobs .scripts-version for successful
234        upgrades (maybe not, depending on our plans).
235
236    16. Run parallel-find.pl to update our inventory
237
238 * For mass importing into the repository, the steps are:
239   (this probably won't ever be automated, becuase there are fiddly bits)
240
241 [TO SET IT UP]
242 # let app-1.2.3 be the scripts folder originally in deploydev
243 # let this folder be srv/
244 # you can also do a git clone
245     mkdir app
246     cd app
247     git init
248     cd ..
249 unfurl app-1.2.3 app  # [FIDDLY BIT]
250 # NOTE: contents of application are now in app directory
251 cd app
252 git add .
253 git commit -s -m "App 1.2.3"
254 git tag v1.2.3
255 git branch pristine
256 # NOTE: you're still on master branch
257 # WARNING: the following operation might require -p1
258 patch -p0 < ../app-1.2.3/app-1.2.3.patch  # [FIDDLY BIT]
259 # NOTE: please sanity check the patch!
260 git add .
261 # NOTE: -a flag is to handle if the patch deleted something
262 git commit -as -m "App 1.2.3-scripts"
263 git tag v1.2.3-scripts
264
265 [TO ADD AN UPDATE]
266 # let this folder be srv/app.git
267 git checkout pristine
268 # NOTE: this preserves your .git folder, but removes everything
269 wipe-working-dir .
270 cd ..
271 unfurl app-1.2.3 app  # [FIDDLY BIT]
272 cd app
273 # NOTE: please sanity check app directory
274 git add .
275 # NOTE: -a is to take care of deletions
276 git commit -as -m "App 1.2.3"
277 git tag v1.2.3
278 [FIDDLE AROUND. FIDDLE AROUND]
279 [IF THE PATCH HAS CHANGED]
280     # You are on the pristine branch
281     # NOTE: Now, the tricky part (this is different from a real update)
282     git symbolic-ref HEAD refs/heads/master
283     # NOTE: Now, we think we're on the master branch, but we have
284     # pristine copy checked out
285     # NOTE: -p0 might need to be twiddled
286     patch -p0 < ../app-1.2.3/app-1.2.3.patch
287     git add .
288     # COMMENT: used to git checkout .scripts here
289     # then check if the directory needs an updated update script
290     # NOTE: Fake the merge
291     git rev-parse pristine > .git/MERGE_HEAD
292 [IF THE PATCH HASN'T CHANGED]
293     git checkout master
294     git merge --no-commit pristine
295 git commit -as -m "App 1.2.3-scripts"
296 git tag v1.2.3-scripts
297
298 * The repository for a given application will contain the following files:
299
300     - The actual application's files, as from the official tarball
301
302     - A .scripts directory, which contains the following information:
303
304         * .scripts/update shell script (with the +x bit set appropriately),
305           which performs the commands necessary to update a script.  This can
306           be in any language.
307
308         * .scripts/.htaccess to prevent this directory from being accessed
309           from the web.
310
311         * .scripts/database (generated) contains the database the
312           user installed the script to, so scripts-remove can clean it
313
314             XXX: Could cause problems if a user copies the autoinstall,
315             fiddles with the DB credentials, and then scripts-remove's
316             the autoinstall.  Possible fix is to add the original
317             directory as a sanity check.  Additionally, we could have
318             the application read out of this file.
319
320         * .scripts/old-version (optional) the old value of .scripts-versoin
321
322         * .scripts/install (eventually) interactively installs the
323           applicatoin from command line.
324
325 * The autoupgrade shall be the process of:
326
327     # Make the directory not accessible by the outside world (htaccess, but be careful!)
328     git add -u .
329     git commit -m 'automatically generated backup'
330     git pull origin master
331     if [ $? ne 0 ]; then git reset --hard; echo 'conflicts during upgrade'; fi
332     ./.scripts/update
333     # Make it accessible
334
335   (with some more robust error checking, a proper dry run mechanism to, and
336   lots of su'ing)
337
338 * Make 'wizard summary' generate nice pretty graphs of installs by date
339   (more histograms, will need to check actual .scripts-version files.)
340
341 * Update AFS patch to advertise its existence, so we can check for it
342   here.