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