Skip to content

Commit

Permalink
fix ignition config creation
Browse files Browse the repository at this point in the history
* the sequence of Ignition config creation was broken,
so that the part responsible for propagation of proxy
settings has been out of the final ignConfig

* e2e test for proxy settings propagation

Signed-off-by: esendjer <[email protected]>
  • Loading branch information
esendjer committed Jun 5, 2023
1 parent 4584350 commit 1ce5367
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 7 deletions.
61 changes: 61 additions & 0 deletions pkg/machine/e2e/proxy_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package e2e_test

import (
"os"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)

var _ = Describe("podman machine proxy settings propagation", func() {
var (
mb *machineTestBuilder
testDir string
)

BeforeEach(func() {
testDir, mb = setup()
})
AfterEach(func() {
teardown(originalHomeDir, testDir, mb)
})

It("ssh to running machine and check proxy settings", func() {
name := randomString()
i := new(initMachine)
session, err := mb.setName(name).setCmd(i.withImagePath(mb.imagePath)).run()
Expect(err).ToNot(HaveOccurred())
Expect(session).To(Exit(0))

defer func() {
httpProxyEnv := os.Getenv("HTTP_PROXY")
httpsProxyEnv := os.Getenv("HTTPS_PROXY")
if httpProxyEnv != "" {
os.Unsetenv("HTTP_PROXY")
}
if httpsProxyEnv != "" {
os.Unsetenv("HTTPS_PROXY")
}
}()
proxyURL := "http://abcdefghijklmnopqrstuvwxyz-proxy"
os.Setenv("HTTP_PROXY", proxyURL)
os.Setenv("HTTPS_PROXY", proxyURL)

s := new(startMachine)
startSession, err := mb.setName(name).setCmd(s).run()
Expect(err).ToNot(HaveOccurred())
Expect(startSession).To(Exit(0))

sshProxy := sshMachine{}
sshSession, err := mb.setName(name).setCmd(sshProxy.withSSHCommand([]string{"printenv", "HTTP_PROXY"})).run()
Expect(err).ToNot(HaveOccurred())
Expect(sshSession).To(Exit(0))
Expect(sshSession.outputToString()).To(ContainSubstring(proxyURL))

sshSession, err = mb.setName(name).setCmd(sshProxy.withSSHCommand([]string{"printenv", "HTTPS_PROXY"})).run()
Expect(err).ToNot(HaveOccurred())
Expect(sshSession).To(Exit(0))
Expect(sshSession.outputToString()).To(ContainSubstring(proxyURL))
})
})
15 changes: 8 additions & 7 deletions pkg/machine/ignition.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,6 @@ WantedBy=sysinit.target
Contents: &deMoby,
},
}}
ignConfig := Config{
Ignition: ignVersion,
Passwd: ignPassword,
Storage: ignStorage,
Systemd: ignSystemd,
}

// Only qemu has the qemu firmware environment setting
if ign.VMType == QemuVirt {
Expand All @@ -222,7 +216,14 @@ WantedBy=sysinit.target
}
ignSystemd.Units = append(ignSystemd.Units, qemuUnit)
}
ign.Cfg = ignConfig
// Only after all checks are done
// it's ready create the ingConfig
ign.Cfg = Config{
Ignition: ignVersion,
Passwd: ignPassword,
Storage: ignStorage,
Systemd: ignSystemd,
}
return nil
}

Expand Down

0 comments on commit 1ce5367

Please sign in to comment.