Merge lp:~nuclearbob/utah/desktop-resolvconf into lp:utah

Proposed by Max Brustkern
Status: Merged
Approved by: Javier Collado
Approved revision: 771
Merged at revision: 770
Proposed branch: lp:~nuclearbob/utah/desktop-resolvconf
Merge into: lp:utah
Diff against target: 121 lines (+13/-13)
3 files modified
utah/provisioning/baremetal/bamboofeeder.py (+5/-6)
utah/provisioning/baremetal/cobbler.py (+4/-4)
utah/provisioning/provisioning.py (+4/-3)
To merge this branch: bzr merge lp:~nuclearbob/utah/desktop-resolvconf
Reviewer Review Type Date Requested Status
Dimitri John Ledkov (community) Disapprove
Javier Collado (community) Approve
Review via email: mp+138236@code.launchpad.net

Description of the change

This change makes all desktop installs copy resolv.conf from the installer environment into the target environment before running chroot commands. We've been doing this for a while on physical machine installs, and it works well to allow package installation to take place as part of the latecommand.

Unfortunately, that is not the only problem with the current code. Now that we have a utah-common package, the client installation fails since we don't install that as well. I'll be submitting a separate proposal for that shortly. We could test them together, but even in the absence of that fix, this one should get ssh installed and fail on client installation, unlike the current code on virtual machine desktop installs, which fails to connect to the machine after it reboots following the install.

To post a comment you must log in.
Revision history for this message
Javier Collado (javier.collado) wrote :

I've tested the code and it works fine. Anyway, I've got a couple of questions:

Could the `/etc/resolv.conf` file in the host machine be broken in some way
that it's unusable in the guest machine?

Should we remove the lines that append `apt-get install` commands to
`/etc/rc.local`?

review: Needs Information
Revision history for this message
Max Brustkern (nuclearbob) wrote :

If the resolv.conf file in the installation environment is broken, then the package install will fail, so I think having the install in rc.local is a good safeguard against that. I'm not sure what would cause it to be broken, as I haven't seen that happen before.

Revision history for this message
Javier Collado (javier.collado) wrote :

Thanks for the response. Merging now.

review: Approve
Revision history for this message
Javier Collado (javier.collado) wrote :

By the way, thanks for fixing pep8 warnings as well.

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

resolv.conf should always be a symlink to a file in /run generated by resolvconf daemon.
Instead of overriding a symlink with static config, /run should be bindmounted instead.
I will propose an update.

$ ls -la /etc/resolv.conf
lrwxrwxrwx 1 root root 29 Feb 3 2012 /etc/resolv.conf -> ../run/resolvconf/resolv.conf

review: Disapprove
Revision history for this message
Javier Collado (javier.collado) wrote :

It's a shame I already merged, but I'll be happy to review your fix and test
it.

Revision history for this message
Max Brustkern (nuclearbob) wrote :

His branch removes this, but this does work on the current raring ISOs. Since this is already merged, we can use it to get smoke testing working while we test the better replacement. I'm testing it on physical hardware in magners now.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'utah/provisioning/baremetal/bamboofeeder.py'
--- utah/provisioning/baremetal/bamboofeeder.py 2012-11-07 19:49:03 +0000
+++ utah/provisioning/baremetal/bamboofeeder.py 2012-12-05 16:09:25 +0000
@@ -93,7 +93,7 @@
93 self.imagedir = os.path.join(self.tmpdir, 'image.d')93 self.imagedir = os.path.join(self.tmpdir, 'image.d')
94 if not os.path.isdir(self.imagedir):94 if not os.path.isdir(self.imagedir):
95 os.makedirs(self.imagedir)95 os.makedirs(self.imagedir)
96 self.sector = int(subprocess.check_output(['file', 96 self.sector = int(subprocess.check_output(['file',
97 self.wwwimage]97 self.wwwimage]
98 ).strip().split(';')[1].split(',')[3].split()[1])98 ).strip().split(';')[1].split(',')[3].split()[1])
99 self.logger.debug('Image start sector is ' + str(self.sector))99 self.logger.debug('Image start sector is ' + str(self.sector))
@@ -101,7 +101,7 @@
101 self.logger.debug('Mounting ' + self.wwwimage + ' at ' +101 self.logger.debug('Mounting ' + self.wwwimage + ' at ' +
102 self.imagedir)102 self.imagedir)
103 self._runargs(['sudo', 'mount', self.wwwimage, self.imagedir,103 self._runargs(['sudo', 'mount', self.wwwimage, self.imagedir,
104 '-o', 'loop', '-o', 'offset=' + str(self.sector*512),104 '-o', 'loop', '-o', 'offset=' + str(self.sector * 512),
105 '-o', 'uid=' + config.user])105 '-o', 'uid=' + config.user])
106106
107 def _setupconsole(self):107 def _setupconsole(self):
@@ -136,7 +136,7 @@
136 pipe.append('cpio -ivd 2>/dev/null', '-.')136 pipe.append('cpio -ivd 2>/dev/null', '-.')
137 # TODO: suppress dd output137 # TODO: suppress dd output
138 pipe.copy(self.initrd, '/dev/null')138 pipe.copy(self.initrd, '/dev/null')
139 139
140 def _repackinitrd(self):140 def _repackinitrd(self):
141 """141 """
142 Repack the uInitrd file from the initrd.d directory.142 Repack the uInitrd file from the initrd.d directory.
@@ -232,7 +232,7 @@
232 self.cleanfile(preenvfile)232 self.cleanfile(preenvfile)
233 self.logger.debug('Writing preenv setup to ' + preenvfile)233 self.logger.debug('Writing preenv setup to ' + preenvfile)
234 open(preenvfile, 'w').write(self.preenv)234 open(preenvfile, 'w').write(self.preenv)
235 235
236 def _create(self):236 def _create(self):
237 """237 """
238 Install the OS on the system.238 Install the OS on the system.
@@ -258,7 +258,6 @@
258 myfile.write(258 myfile.write(
259"""259"""
260chroot /target sh -c 'sed "/eth[0-9]/d" -i /etc/network/interfaces'260chroot /target sh -c 'sed "/eth[0-9]/d" -i /etc/network/interfaces'
261cp /etc/resolv.conf /target/etc/resolv.conf
262""")261""")
263 myfile.close()262 myfile.close()
264 self._setuppreseed()263 self._setuppreseed()
@@ -293,7 +292,7 @@
293 self.cleanfunction(self.run, ('dd', 'bs=512k', 'count=10',292 self.cleanfunction(self.run, ('dd', 'bs=512k', 'count=10',
294 'if=/dev/zero', 'of=/dev/mmcblk0'), root=True)293 'if=/dev/zero', 'of=/dev/mmcblk0'), root=True)
295 return True294 return True
296 295
297 def _depcheck(self):296 def _depcheck(self):
298 """297 """
299 Check for dependencies that are in Recommends or Suggests.298 Check for dependencies that are in Recommends or Suggests.
300299
=== modified file 'utah/provisioning/baremetal/cobbler.py'
--- utah/provisioning/baremetal/cobbler.py 2012-11-15 20:02:41 +0000
+++ utah/provisioning/baremetal/cobbler.py 2012-12-05 16:09:25 +0000
@@ -94,7 +94,6 @@
94 myfile.write(94 myfile.write(
95"""95"""
96chroot /target sh -c 'sed "/eth[0-9]/d" -i /etc/network/interfaces'96chroot /target sh -c 'sed "/eth[0-9]/d" -i /etc/network/interfaces'
97cp /etc/resolv.conf /target/etc/resolv.conf
98""")97""")
99 myfile.close()98 myfile.close()
100 self._setuppreseed()99 self._setuppreseed()
@@ -165,7 +164,8 @@
165 + ['--' + arg + '=' + self.cargs[arg]164 + ['--' + arg + '=' + self.cargs[arg]
166 for arg in self.cargs])165 for arg in self.cargs])
167166
168 # Things seem to be working fine without this, but sometimes things still get broken167 # Things seem to be working fine without this,
168 # but sometimes things still get broken
169 #self.logger.info('Syncing cobbler')169 #self.logger.info('Syncing cobbler')
170 #self._cobble(['sync'])170 #self._cobble(['sync'])
171 try:171 try:
@@ -253,7 +253,7 @@
253 except UTAHBMProvisioningException:253 except UTAHBMProvisioningException:
254 self._runargs(self.powercommand() + ['off'])254 self._runargs(self.powercommand() + ['off'])
255 self.active = False255 self.active = False
256 256
257 def __del__(self):257 def __del__(self):
258 """258 """
259 If the machine has an inventory, tell the inventory to release the259 If the machine has an inventory, tell the inventory to release the
@@ -273,7 +273,7 @@
273 '/d', '-i', config.nfsconfigfile])273 '/d', '-i', config.nfsconfigfile])
274 self.logger.debug('Reloading NFS config')274 self.logger.debug('Reloading NFS config')
275 self._runargs(config.nfscommand)275 self._runargs(config.nfscommand)
276 276
277 def _cleanuptmpdir(self):277 def _cleanuptmpdir(self):
278 if os.path.isdir(self.tmpdir):278 if os.path.isdir(self.tmpdir):
279 # Cribbed from http://svn.python.org279 # Cribbed from http://svn.python.org
280280
=== modified file 'utah/provisioning/provisioning.py'
--- utah/provisioning/provisioning.py 2012-11-23 13:08:36 +0000
+++ utah/provisioning/provisioning.py 2012-12-05 16:09:25 +0000
@@ -1069,8 +1069,9 @@
1069 .format(install_commands)1069 .format(install_commands)
1070 )1070 )
1071 chroot_command = ' '.join([install_commands, postinstall_commands])1071 chroot_command = ' '.join([install_commands, postinstall_commands])
1072 question.value.prepend('chroot /target sh -c \'{}\'; '1072 question.value.prepend('cp /etc/resolv.conf '
1073 .format(chroot_command))1073 '/target/etc/resolv.conf ; chroot /target sh -c \'{}\'; '
1074 .format(chroot_command))
1074 question.prepend("ubiquity ubiquity/summary note")1075 question.prepend("ubiquity ubiquity/summary note")
1075 question.prepend("ubiquity ubiquity/reboot boolean true")1076 question.prepend("ubiquity ubiquity/reboot boolean true")
1076 else:1077 else:
@@ -1093,7 +1094,7 @@
1093 """1094 """
1094 question = preseed['pkgsel/include']1095 question = preseed['pkgsel/include']
1095 packages = question.value.text.split()1096 packages = question.value.text.split()
1096 for pkgname in ('openssh-server', 'gdebi-core'):1097 for pkgname in config.installpackages:
1097 if pkgname not in packages:1098 if pkgname not in packages:
1098 self.logger.info('Adding {} to preseeded packages'1099 self.logger.info('Adding {} to preseeded packages'
1099 .format(pkgname))1100 .format(pkgname))

Subscribers

People subscribed via source and target branches