mirror of
https://github.com/kairos-io/kcrypt-challenger.git
synced 2025-04-27 11:30:52 +00:00
Handle unexpected VM exit better and use a core image with working DNS
Also print serial output when something goes wrong Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
This commit is contained in:
parent
4c0b40d3a0
commit
266c4f20e9
@ -1,5 +1,5 @@
|
||||
VERSION 0.6
|
||||
ARG BASE_IMAGE=quay.io/kairos/core-opensuse:latest
|
||||
ARG BASE_IMAGE=quay.io/kairos/core-opensuse-leap:latest
|
||||
ARG OSBUILDER_IMAGE=quay.io/kairos/osbuilder-tools
|
||||
ARG GO_VERSION=1.18
|
||||
ARG LUET_VERSION=0.33.0
|
||||
|
10
go.mod
10
go.mod
@ -16,7 +16,7 @@ require (
|
||||
github.com/onsi/ginkgo/v2 v2.8.0
|
||||
github.com/onsi/gomega v1.26.0
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/spectrocloud/peg v0.0.0-20230207104055-5f48d834ddf6
|
||||
github.com/spectrocloud/peg v0.0.0-20230213144904-73a265b43e5b
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
k8s.io/api v0.24.2
|
||||
k8s.io/apimachinery v0.24.2
|
||||
@ -118,12 +118,12 @@ require (
|
||||
go.uber.org/atomic v1.10.0 // indirect
|
||||
go.uber.org/multierr v1.9.0 // indirect
|
||||
go.uber.org/zap v1.24.0 // indirect
|
||||
golang.org/x/crypto v0.5.0 // indirect
|
||||
golang.org/x/net v0.5.0 // indirect
|
||||
golang.org/x/crypto v0.6.0 // indirect
|
||||
golang.org/x/net v0.6.0 // indirect
|
||||
golang.org/x/oauth2 v0.4.0 // indirect
|
||||
golang.org/x/sys v0.5.0 // indirect
|
||||
golang.org/x/term v0.4.0 // indirect
|
||||
golang.org/x/text v0.6.0 // indirect
|
||||
golang.org/x/term v0.5.0 // indirect
|
||||
golang.org/x/text v0.7.0 // indirect
|
||||
golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect
|
||||
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
|
20
go.sum
20
go.sum
@ -700,8 +700,8 @@ github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9
|
||||
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||
github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0=
|
||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||
github.com/spectrocloud/peg v0.0.0-20230207104055-5f48d834ddf6 h1:21+a7wprqouCWb204xWC7kJY1iO60l1KM+/YRSsxRVk=
|
||||
github.com/spectrocloud/peg v0.0.0-20230207104055-5f48d834ddf6/go.mod h1:YMaL3lRGnHWV5lfAorzH1dTwc5BL7gU0ILLYbS6elPw=
|
||||
github.com/spectrocloud/peg v0.0.0-20230213144904-73a265b43e5b h1:Ty4xpZIJXRFPFm8GNEFwtMXd0T+O1trmKyFRxfcyvxs=
|
||||
github.com/spectrocloud/peg v0.0.0-20230213144904-73a265b43e5b/go.mod h1:YMaL3lRGnHWV5lfAorzH1dTwc5BL7gU0ILLYbS6elPw=
|
||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
|
||||
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
|
||||
@ -841,8 +841,8 @@ golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b/go.mod h1:T9bdIzuCu7OtxOm
|
||||
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE=
|
||||
golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
|
||||
golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc=
|
||||
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||
@ -938,8 +938,8 @@ golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qx
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw=
|
||||
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
|
||||
golang.org/x/net v0.6.0 h1:L4ZwwTvKW9gr0ZMS1yrHD9GZhIuVjOBBnaKH+SPQK0Q=
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
@ -1060,8 +1060,8 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn
|
||||
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.4.0 h1:O7UWfv5+A2qiuulQk30kVinPoMtoIPeVaKLEgLpVkvg=
|
||||
golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ=
|
||||
golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
@ -1071,8 +1071,8 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k=
|
||||
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
|
@ -55,4 +55,4 @@ kubectl apply -k "$SCRIPT_DIR/../tests/assets/"
|
||||
# https://stackoverflow.com/a/6752280
|
||||
export KMS_ADDRESS="10.0.2.2.challenger.sslip.io"
|
||||
|
||||
PATH=$PATH:$GOPATH/bin ginkgo --nodes $GINKGO_NODES --fail-fast -r ./tests/
|
||||
PATH=$PATH:$GOPATH/bin ginkgo -v --nodes $GINKGO_NODES --fail-fast -r ./tests/
|
||||
|
@ -1,6 +1,7 @@
|
||||
package e2e_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
@ -22,10 +23,35 @@ var vm VM
|
||||
|
||||
var _ = Describe("local encrypted passphrase", func() {
|
||||
var config string
|
||||
var vmStillNeeded bool // When false, a stopped VM should stop execution
|
||||
var ctx context.Context
|
||||
|
||||
BeforeEach(func() {
|
||||
vmStillNeeded = true
|
||||
RegisterFailHandler(printInstallationOutput)
|
||||
vm = startVM()
|
||||
ctx, vm = startVM()
|
||||
fmt.Printf("\nvm.StateDir = %+v\n", vm.StateDir)
|
||||
|
||||
go func() {
|
||||
defer GinkgoRecover()
|
||||
<-ctx.Done()
|
||||
if vmStillNeeded {
|
||||
stdout, err := os.ReadFile(path.Join(vm.StateDir, "stdout"))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
stderr, err := os.ReadFile(path.Join(vm.StateDir, "stderr"))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
serialLog, err := os.ReadFile(path.Join(vm.StateDir, "serial.log"))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
fmt.Printf("stdout: %s\n", stdout)
|
||||
fmt.Printf("stderr: %s\n", stderr)
|
||||
fmt.Printf("serial: %s\n", serialLog)
|
||||
|
||||
// Although we call `Fail`, ginkgo still waits for `EventuallyConnects`
|
||||
// below to be done for some reason. Something to do with locks probably.
|
||||
Fail("VM exited before the test was done")
|
||||
}
|
||||
}()
|
||||
|
||||
vm.EventuallyConnects(1200)
|
||||
})
|
||||
@ -46,6 +72,7 @@ var _ = Describe("local encrypted passphrase", func() {
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
vmStillNeeded = false // We are done. Don't fail when we exit the VM.
|
||||
err := vm.Destroy(func(vm VM) {
|
||||
// Stop TPM emulator
|
||||
tpmPID, err := os.ReadFile(path.Join(vm.StateDir, "tpm", "pid"))
|
||||
@ -140,7 +167,7 @@ kcrypt:
|
||||
|
||||
It("creates a passphrase and a key/pair to decrypt it", func() {
|
||||
// Expect a LUKS partition
|
||||
vm.Reboot()
|
||||
vm.Reboot(750)
|
||||
vm.EventuallyConnects(1200)
|
||||
out, err := vm.Sudo("blkid")
|
||||
Expect(err).ToNot(HaveOccurred(), out)
|
||||
|
@ -42,7 +42,7 @@ func pass() string {
|
||||
return pass
|
||||
}
|
||||
|
||||
func startVM() VM {
|
||||
func startVM() (context.Context, VM) {
|
||||
if os.Getenv("ISO") == "" {
|
||||
fmt.Println("ISO missing")
|
||||
os.Exit(1)
|
||||
@ -86,10 +86,14 @@ func startVM() VM {
|
||||
fmt.Printf("\nVM Aborted: %s %s Exit status: %s\n", out, err, status)
|
||||
}),
|
||||
types.WithStateDir(stateDir),
|
||||
// Serial output to file: https://superuser.com/a/1412150
|
||||
func(m *types.MachineConfig) error {
|
||||
m.Args = append(m.Args,
|
||||
"-chardev", fmt.Sprintf("socket,id=chrtpm,path=%s/swtpm-sock", path.Join(stateDir, "tpm")),
|
||||
"-tpmdev", "emulator,id=tpm0,chardev=chrtpm", "-device", "tpm-tis,tpmdev=tpm0",
|
||||
"-chardev", fmt.Sprintf("stdio,mux=on,id=char0,logfile=%s,signal=off", path.Join(stateDir, "serial.log")),
|
||||
"-serial", "chardev:char0",
|
||||
"-mon", "chardev=char0",
|
||||
)
|
||||
return nil
|
||||
},
|
||||
@ -119,7 +123,7 @@ func startVM() VM {
|
||||
|
||||
vm := NewVM(m, stateDir)
|
||||
|
||||
err = vm.Start(context.Background())
|
||||
ctx, err := vm.Start(context.Background())
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
if os.Getenv("MACHINE_SPICY") != "" {
|
||||
@ -130,7 +134,7 @@ func startVM() VM {
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
}
|
||||
|
||||
return vm
|
||||
return ctx, vm
|
||||
}
|
||||
|
||||
// return the PID of the swtpm (to be killed later) and the state directory
|
||||
|
Loading…
Reference in New Issue
Block a user