]> scripts.mit.edu Git - wizard.git/blob - TODO
Implement --log-file-chmod
[wizard.git] / TODO
1 The Git Autoinstaller
2
3 TODO NOW:
4
5 - Check how many autoinstalls are missing w bits for
6   daemon.scripts (this would need pyafs)
7 - Run parallel-find.pl
8 - Migrate all mediawikis
9 - Wordpress needs to have a .scripts/update script written for
10   its latest version
11
12 NOTES:
13
14 - A perfectly formed autoinstall with upgrade paths for all of
15   the intervening versions is not really feasible to implement.
16   As such, we want to migrate everything to -scripts, and then
17   generate a -scripts2 with the correct .scripts directory.
18   We will then nop update some installs, but this will prevent
19   us from having to migrate and update concurrently.  Treat
20   a scripts2 upgrade from migration the same way you would treat
21   a botched scripts upgrade.
22
23 - summary and info are still not using loggers. Maybe they should,
24   maybe they shouldn't.  Using loggers means we lose interactivity
25   with the Git output
26
27 - Currently all repositories are initialized with --shared, which
28   means they have basically ~no space footprint.  However, it
29   also means that /mit/scripts/wizard/srv MUST NOT lose revs.
30
31 - Full fledged logging options. Namely:
32   x all loggers (delay implementing this until we actually have debug stmts)
33     - default is WARNING
34     - debug     => loglevel = DEBUG
35   x stdout logger
36     - default is WARNING (see below for exception)
37     - verbose   => loglevel = INFO
38   x file logger (only allowed for serial processing)
39     - default is OFF
40     - log-file   => loglevel = INFO
41   x database logger (necessary for parallel processing, not implemented)
42     - default is OFF
43     - log-db    => loglevel = INFO
44
45 - More on the database logger: it will be very simple with one
46   table named `logs` in SQLite, with columns: `job`, `level`,
47   `message`.  Job identifies the subprocess/thread that emitted
48   the log, so things can be correlated together.  We will then
49   have `wizard dump` which takes a database like this and dumps
50   it into a file logger type file.  The database may also store
51   a queue like structure which can be used to coordinate jobs.
52
53 OVERALL PLAN:
54
55 * Some parts of the infrastructure will not be touched, although I plan
56   on documenting them.  Specifically, we will be keeping:
57
58     - parallel-find.pl, and the resulting
59       /mit/scripts/sec-tools/store/scriptslist
60       This script might need to be adapted if we decide to nuke
61       .scripts-version files.
62
63     - The current install scripts will be kept in place, sans changes
64       necessary to make them use Git install of copying the script over.
65       Porting these scripts to Python and making them modular would be
66       nice, but is priority.  For the long term, seeing this scripts
67       be packaged with rest of our code would be optimal.
68
69 * The new procedure for generating an update is as follows:
70   (check out the mass-migration instructions for something in this spirit,
71   although uglier in some ways)
72
73     0. ssh into not-backward, temporarily give the daemon.scripts-security-upd
74        bits by blanching it on system:scripts-security-upd, and run parallel-find.pl
75
76     1. Have the Git repository and working copy for the project on hand.
77
78     2. Checkout the pristine branch
79
80     3. Remove all files from the working copy.  Use `wipe-working-dir`
81
82     4. Download the new tarball
83
84     5. Extract the tarball over the working copy (`cp -R a/. b` works well,
85        remember that the working copy is empty)
86
87     6. Check for empty directories and add stub files as necessary.
88        Use `preserve-empty-dir`
89
90     7. Git add it all, and then commit as a new pristine version (v1.2.3)
91
92     8. Checkout the master branch
93
94     9. [FOR EXISTING REPOSITORIES]
95        Merge the pristine branch in. Resolve any conflicts that our
96        patches have with new changes. Do NOT let Git auto-commit it
97        with --no-commit (otherwise, you want to git commit --amend
98        to keep our history clean
99
100        [FOR NEW REPOSITORIES]
101        See if any patches are needed to make this run smoothly on
102        scripts.
103
104     [FOR NEW REPOSITORIES]
105         mkdir .scripts
106         echo "Deny from all" > .scripts/.htaccess
107         touch .scripts/update
108         chmod a+x .scripts/update
109
110    10. Check if there are any special update procedures, and update/create the
111        .scripts/update shell script as necessary (this means that any
112        application specific update logic will be kept with the actual
113        source code.  The language of this update script will vary
114        depending on context.)
115
116    11. Commit your changes, and tag as v1.2.3-scripts (or scripts2, if
117        you are amending an install without an upstream changes)
118
119    12. Test the new update procedure using
120        `wizard upgrade --with=/path/to/repo /your/autoinstall` (this will
121        read out master as your "latest" version).
122        Use git commit --amend to fix any bugs (alternatively, squash them
123        together later).
124
125    13. You can also do a "mass" version of this using:
126        `wizard -d testbed.txt massupgrade --with=/path/to/repo app`
127        You'll need perms for any testbed stuff you want.
128
129       GET APPROVAL BEFORE PROCEEDING ANY FURTHER
130
131       NOTE: The following commands are to be run on not-backward.mit.edu.
132       You'll need to add daemon.scripts-security-upd to
133       scripts-security-upd to get bits to do this.  Make sure you remove
134       these bits when you're done.
135
136    14. Run `wizard research appname`
137        which uses Git commands to check how many
138        working copies apply the change cleanly, and writes out a logfile
139        with the working copies that don't apply cleanly.  It also tells
140        us about "corrupt" working copies.
141
142    15. Run `wizard massupgrade appname`, which applies the update to all working
143        copies possible, and sends mail to users to whom the working copy
144        did not apply cleanly. It also frobs .scripts-version for successful
145        upgrades (maybe not, depending on our plans).
146
147    16. Run parallel-find.pl to update our inventory
148
149 * For mass importing into the repository, the steps are:
150   (this probably won't ever be automated, becuase there are fiddly bits)
151
152 [TO SET IT UP]
153 # let app-1.2.3 be the scripts folder originally in deploydev
154 # let this folder be srv/
155 # you can also do a git clone
156     mkdir app
157     cd app
158     git init
159     cd ..
160 unfurl app-1.2.3 app  # [FIDDLY BIT]
161 # NOTE: contents of application are now in app directory
162 cd app
163 git add .
164 git commit -s -m "App 1.2.3"
165 git tag v1.2.3
166 git branch pristine
167 # NOTE: you're still on master branch
168 # WARNING: the following operation might require -p1
169 patch -p0 < ../app-1.2.3/app-1.2.3.patch  # [FIDDLY BIT]
170 # NOTE: please sanity check the patch!
171 git add .
172 # NOTE: -a flag is to handle if the patch deleted something
173 git commit -as -m "App 1.2.3-scripts"
174 git tag v1.2.3-scripts
175
176 [TO ADD AN UPDATE]
177 # let this folder be srv/app.git
178 git checkout pristine
179 # NOTE: this preserves your .git folder, but removes everything
180 wipe-working-dir .
181 cd ..
182 unfurl app-1.2.3 app  # [FIDDLY BIT]
183 cd app
184 # NOTE: please sanity check app directory
185 git add .
186 # NOTE: -a is to take care of deletions
187 git commit -as -m "App 1.2.3"
188 git tag v1.2.3
189 [FIDDLE AROUND. FIDDLE AROUND]
190 [IF THE PATCH HAS CHANGED]
191     # You are on the pristine branch
192     # NOTE: Now, the tricky part (this is different from a real update)
193     git symbolic-ref HEAD refs/heads/master
194     # NOTE: Now, we think we're on the master branch, but we have
195     # pristine copy checked out
196     # NOTE: -p0 might need to be twiddled
197     patch -p0 < ../app-1.2.3/app-1.2.3.patch
198     git add .
199     # COMMENT: used to git checkout .scripts here
200     # then check if the directory needs an updated update script
201     # NOTE: Fake the merge
202     git rev-parse pristine > .git/MERGE_HEAD
203 [IF THE PATCH HASN'T CHANGED]
204     git checkout master
205     git merge --no-commit pristine
206 git commit -as -m "App 1.2.3-scripts"
207 git tag v1.2.3-scripts
208
209
210 * The repository for a given application will contain the following files:
211
212     - The actual application's files, as from the official tarball
213
214     - A .scripts directory, which contains the following information:
215
216         * .scripts/update shell script (with the +x bit set appropriately),
217           which performs the commands necessary to update a script.  This can
218           be in any language.
219
220         * .scripts/.htaccess to prevent this directory from being accessed
221           from the web.
222
223         * .scripts/database (generated) contains the database the
224           user installed the script to, so scripts-remove can clean it
225
226             XXX: Could cause problems if a user copies the autoinstall,
227             fiddles with the DB credentials, and then scripts-remove's
228             the autoinstall.  Possible fix is to add the original
229             directory as a sanity check.  Additionally, we could have
230             the application read out of this file.
231
232         * .scripts/version (generated) which contains the version
233           last autoinstalled (as distinct from the actual version
234           the script is) (This is the same as .scripts-version right
235           now; probably want to keep that for now)
236
237             XXX: It's unclear if we want to move to this wholesale, or
238             delay this indefinitely.  quentin thinks that the Git
239             repository itself is a sufficient record.
240
241 * The migration process has been implemented, see 'wizard migrate'.
242
243     XXX: We have not decided what migration should do to .scripts-version;
244     if it does move it to .scripts, repositories should have a .gitignore
245     in those directories
246
247 * The autoupgrade shall be the process of:
248
249     # Make the directory not accessible by the outside world (htaccess, but be careful!)
250     git add -u .
251     git commit -m 'automatically generated backup'
252     git pull origin master
253     if [ $? ne 0 ]; then git reset --hard; echo 'conflicts during upgrade'; fi
254     ./.scripts/update
255     # Make it accessible
256
257   (with some more robust error checking, a proper dry run mechanism to, and
258   lots of su'ing)
259
260 * All code that operates on an untrusted Git repository, or runs
261   executable code, should be done on NOT-BACKWARD.mit.edu.  Pending
262   accounts confirmation, it will also get a principal
263   daemon.scripts-security-upd, which is what we'll actually put
264   in the scripts-security-upd group.  parallel-find.pl should also
265   be run on not-backward, by virtue of its fat pipe to the AFS servers.
266
267 * Make 'wizard summary' generate nice pretty graphs of installs by date
268   (more histograms, will need to check actual .scripts-version files.)