Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write /etc/resolv.conf during export #225

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@ func (i *installer) do() error {
}
}

err = i.writeResolvConf()
if err != nil {
i.log.Warn("writing resolv.conf failed", "error", err)
return err
}

err = i.createMetalUser()
if err != nil {
return err
Expand Down Expand Up @@ -140,26 +134,6 @@ func (i *installer) fileExists(filename string) bool {
return !info.IsDir()
}

func (i *installer) writeResolvConf() error {
i.log.Info("write /etc/resolv.conf")
// Must be written here because during docker build this file is synthetic
// FIXME enable systemd-resolved based approach again once we figured out why it does not work on the firewall
// most probably because the resolved must be running in the internet facing vrf.
// ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
// in ignite this file is a symlink to /proc/net/pnp, to pass integration test, remove this first
err := i.fs.Remove("/etc/resolv.conf")
if err != nil {
i.log.Info("no /etc/resolv.conf present")
}

// FIXME migrate to dns0.eu resolvers
content := []byte(
`nameserver 8.8.8.8
nameserver 8.8.4.4
`)
return afero.WriteFile(i.fs, "/etc/resolv.conf", content, 0644)
}

func (i *installer) buildCMDLine() string {
i.log.Info("build kernel cmdline")

Expand Down
52 changes: 0 additions & 52 deletions cmd/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,58 +206,6 @@ func Test_installer_detectFirmware(t *testing.T) {
}
}

func Test_installer_writeResolvConf(t *testing.T) {
tests := []struct {
name string
fsMocks func(fs afero.Fs)
want string
wantErr error
}{
{
name: "resolv.conf gets written",
fsMocks: func(fs afero.Fs) {
require.NoError(t, afero.WriteFile(fs, "/etc/resolv.conf", []byte(""), 0755))
},
want: `nameserver 8.8.8.8
nameserver 8.8.4.4
`,
wantErr: nil,
},
{
name: "resolv.conf gets written, file is not present",
want: `nameserver 8.8.8.8
nameserver 8.8.4.4
`,
wantErr: nil,
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
i := &installer{
log: slog.Default(),
fs: afero.NewMemMapFs(),
}

if tt.fsMocks != nil {
tt.fsMocks(i.fs)
}

err := i.writeResolvConf()
if diff := cmp.Diff(tt.wantErr, err, testcommon.ErrorStringComparer()); diff != "" {
t.Errorf("error diff (+got -want):\n %s", diff)
}

content, err := afero.ReadFile(i.fs, "/etc/resolv.conf")
require.NoError(t, err)

if diff := cmp.Diff(tt.want, string(content)); diff != "" {
t.Errorf("error diff (+got -want):\n %s", diff)
}
})
}
}

func Test_installer_fixPermissions(t *testing.T) {
tests := []struct {
name string
Expand Down
3 changes: 0 additions & 3 deletions debian/context/etc/systemd/resolved.conf.d/dns.conf

This file was deleted.

2 changes: 0 additions & 2 deletions debian/context/kernel-installation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ if [ "${ID}" = "ubuntu" ] ; then
/tmp/linux-image* \
/tmp/linux-modules* \
intel-microcode
# Ubuntu still requires it
systemctl enable systemd-resolved
else
echo "Debian - Install kernel"

Expand Down
2 changes: 2 additions & 0 deletions export.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ readonly PKG="packages.txt"
mkdir -p "${EXPORT_DIRECTORY}"
cd "${EXPORT_DIRECTORY}"
docker export "$(docker create "${DOCKER_IMAGE}")" > ${TAR}
# set /etc/resolv.conf
tar --file ${TAR} --directory=export --append etc
docker run --rm "${DOCKER_IMAGE}" bash -c "dpkg -l" > ${PKG}
lz4 -f -9 ${TAR} ${LZ4}
rm -f ${TAR}
Expand Down
2 changes: 2 additions & 0 deletions export/etc/resolv.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nameserver 8.8.8.8
nameserver 8.8.4.4
Loading