From 96142c2f7507fd933e0c2c5b61eb3a893d1b4adf Mon Sep 17 00:00:00 2001 From: Ashley Cui Date: Fri, 22 Sep 2023 09:50:08 -0400 Subject: [PATCH 1/2] Vendor c/common Signed-off-by: Ashley Cui --- go.mod | 2 +- go.sum | 4 +-- .../containers/common/pkg/config/config.go | 28 ------------------- .../containers/common/pkg/config/default.go | 7 ++++- vendor/modules.txt | 2 +- 5 files changed, 10 insertions(+), 33 deletions(-) diff --git a/go.mod b/go.mod index b99dc13139..8013341925 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/containernetworking/cni v1.1.2 github.com/containernetworking/plugins v1.3.0 github.com/containers/buildah v1.32.0 - github.com/containers/common v0.56.1-0.20230920110729-eb4ad859f309 + github.com/containers/common v0.56.1-0.20230920191016-f4e726d4b162 github.com/containers/conmon v2.0.20+incompatible github.com/containers/gvisor-tap-vsock v0.7.1-0.20230921084021-9298405740ad github.com/containers/image/v5 v5.28.0 diff --git a/go.sum b/go.sum index 18c1c99b1c..9151e29ed6 100644 --- a/go.sum +++ b/go.sum @@ -249,8 +249,8 @@ github.com/containernetworking/plugins v1.3.0 h1:QVNXMT6XloyMUoO2wUOqWTC1hWFV62Q github.com/containernetworking/plugins v1.3.0/go.mod h1:Pc2wcedTQQCVuROOOaLBPPxrEXqqXBFt3cZ+/yVg6l0= github.com/containers/buildah v1.32.0 h1:uz5Rcf7lGeStj7iPTBgO4UdhQYZqMMzyt9suDf16k1k= github.com/containers/buildah v1.32.0/go.mod h1:sN3rA3DbnqekNz3bNdkqWduuirYDuMs54LUCOZOomBE= -github.com/containers/common v0.56.1-0.20230920110729-eb4ad859f309 h1:ZuP6m9Ps9bBR/3TlR4AqzobAvtYstKkoYmKIg3R7O84= -github.com/containers/common v0.56.1-0.20230920110729-eb4ad859f309/go.mod h1:ABFEglmyt48WWWQv80kGhitfbVfR1Br35wk3gBQdrIk= +github.com/containers/common v0.56.1-0.20230920191016-f4e726d4b162 h1:94djwIUmnWY9tzQmbMsZ58Kpjg2vx1e0R1HfpTYDkMM= +github.com/containers/common v0.56.1-0.20230920191016-f4e726d4b162/go.mod h1:ABFEglmyt48WWWQv80kGhitfbVfR1Br35wk3gBQdrIk= github.com/containers/conmon v2.0.20+incompatible h1:YbCVSFSCqFjjVwHTPINGdMX1F6JXHGTUje2ZYobNrkg= github.com/containers/conmon v2.0.20+incompatible/go.mod h1:hgwZ2mtuDrppv78a/cOBNiCm6O0UMWGx1mu7P00nu5I= github.com/containers/gvisor-tap-vsock v0.7.1-0.20230921084021-9298405740ad h1:bJu6ieGZqM6C1SyDkpw2x7D3T5VqajoyvudLmdS50e0= diff --git a/vendor/github.com/containers/common/pkg/config/config.go b/vendor/github.com/containers/common/pkg/config/config.go index 8bdccd4e83..0cfe042fc6 100644 --- a/vendor/github.com/containers/common/pkg/config/config.go +++ b/vendor/github.com/containers/common/pkg/config/config.go @@ -1100,34 +1100,6 @@ func Reload() (*Config, error) { return New(&Options{SetDefault: true}) } -func (c *Config) ActiveDestination() (uri, identity string, machine bool, err error) { - if uri, found := os.LookupEnv("CONTAINER_HOST"); found { - if v, found := os.LookupEnv("CONTAINER_SSHKEY"); found { - identity = v - } - return uri, identity, false, nil - } - connEnv := os.Getenv("CONTAINER_CONNECTION") - switch { - case connEnv != "": - d, found := c.Engine.ServiceDestinations[connEnv] - if !found { - return "", "", false, fmt.Errorf("environment variable CONTAINER_CONNECTION=%q service destination not found", connEnv) - } - return d.URI, d.Identity, d.IsMachine, nil - - case c.Engine.ActiveService != "": - d, found := c.Engine.ServiceDestinations[c.Engine.ActiveService] - if !found { - return "", "", false, fmt.Errorf("%q service destination not found", c.Engine.ActiveService) - } - return d.URI, d.Identity, d.IsMachine, nil - case c.Engine.RemoteURI != "": - return c.Engine.RemoteURI, c.Engine.RemoteIdentity, false, nil - } - return "", "", false, errors.New("no service destination configured") -} - var ( bindirFailed = false bindirCached = "" diff --git a/vendor/github.com/containers/common/pkg/config/default.go b/vendor/github.com/containers/common/pkg/config/default.go index 4b1537c758..7c228863b9 100644 --- a/vendor/github.com/containers/common/pkg/config/default.go +++ b/vendor/github.com/containers/common/pkg/config/default.go @@ -6,6 +6,7 @@ import ( "net" "os" "path/filepath" + "runtime" "strings" nettypes "github.com/containers/common/libnetwork/types" @@ -250,8 +251,12 @@ func defaultSecretConfig() SecretConfig { // defaultMachineConfig returns the default machine configuration. func defaultMachineConfig() MachineConfig { + cpus := runtime.NumCPU() / 2 + if cpus == 0 { + cpus = 1 + } return MachineConfig{ - CPUs: 1, + CPUs: uint64(cpus), DiskSize: 100, Image: getDefaultMachineImage(), Memory: 2048, diff --git a/vendor/modules.txt b/vendor/modules.txt index ab2b68647a..15bd06a0fc 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -164,7 +164,7 @@ github.com/containers/buildah/pkg/sshagent github.com/containers/buildah/pkg/util github.com/containers/buildah/pkg/volumes github.com/containers/buildah/util -# github.com/containers/common v0.56.1-0.20230920110729-eb4ad859f309 +# github.com/containers/common v0.56.1-0.20230920191016-f4e726d4b162 ## explicit; go 1.18 github.com/containers/common/libimage github.com/containers/common/libimage/define From d8e3057165f277495b889db1c2efd92938b0b137 Mon Sep 17 00:00:00 2001 From: Ashley Cui Date: Fri, 22 Sep 2023 09:52:52 -0400 Subject: [PATCH 2/2] Adjust machine CPU tests Machine cpu default has changed to cpus/2, so adjust the tests to reflect that. Signed-off-by: Ashley Cui --- pkg/machine/e2e/init_test.go | 12 +++++++++--- pkg/machine/e2e/set_test.go | 7 ++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/pkg/machine/e2e/init_test.go b/pkg/machine/e2e/init_test.go index 2649f9a4fd..96bd48fd1e 100644 --- a/pkg/machine/e2e/init_test.go +++ b/pkg/machine/e2e/init_test.go @@ -2,6 +2,7 @@ package e2e_test import ( "os" + "runtime" "strconv" "strings" "time" @@ -26,6 +27,11 @@ var _ = Describe("podman machine init", func() { teardown(originalHomeDir, testDir, mb) }) + cpus := runtime.NumCPU() / 2 + if cpus == 0 { + cpus = 1 + } + It("bad init name", func() { i := initMachine{} reallyLongName := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" @@ -42,11 +48,11 @@ var _ = Describe("podman machine init", func() { inspectBefore, ec, err := mb.toQemuInspectInfo() Expect(err).ToNot(HaveOccurred()) Expect(ec).To(BeZero()) - Expect(inspectBefore).ToNot(BeEmpty()) + testMachine := inspectBefore[0] Expect(testMachine.Name).To(Equal(mb.names[0])) - Expect(testMachine.Resources.CPUs).To(Equal(uint64(1))) + Expect(testMachine.Resources.CPUs).To(Equal(uint64(cpus))) Expect(testMachine.Resources.Memory).To(Equal(uint64(2048))) }) @@ -91,7 +97,7 @@ var _ = Describe("podman machine init", func() { Expect(inspectBefore).ToNot(BeEmpty()) testMachine := inspectBefore[0] Expect(testMachine.Name).To(Equal(mb.names[0])) - Expect(testMachine.Resources.CPUs).To(Equal(uint64(1))) + Expect(testMachine.Resources.CPUs).To(Equal(uint64(cpus))) Expect(testMachine.Resources.Memory).To(Equal(uint64(2048))) Expect(testMachine.SSHConfig.RemoteUsername).To((Equal(remoteUsername))) diff --git a/pkg/machine/e2e/set_test.go b/pkg/machine/e2e/set_test.go index a1f12cdad6..eb62de77f3 100644 --- a/pkg/machine/e2e/set_test.go +++ b/pkg/machine/e2e/set_test.go @@ -1,6 +1,7 @@ package e2e_test import ( + "runtime" "strconv" "strings" @@ -89,10 +90,14 @@ var _ = Describe("podman machine set", func() { Expect(startSession).To(Exit(0)) ssh2 := sshMachine{} + cpus := runtime.NumCPU() / 2 + if cpus == 0 { + cpus = 1 + } sshSession2, err := mb.setName(name).setCmd(ssh2.withSSHCommand([]string{"lscpu", "|", "grep", "\"CPU(s):\"", "|", "head", "-1"})).run() Expect(err).ToNot(HaveOccurred()) Expect(sshSession2).To(Exit(0)) - Expect(sshSession2.outputToString()).To(ContainSubstring("1")) + Expect(sshSession2.outputToString()).To(ContainSubstring(strconv.Itoa(cpus))) ssh3 := sshMachine{} sshSession3, err := mb.setName(name).setCmd(ssh3.withSSHCommand([]string{"sudo", "fdisk", "-l", "|", "grep", "Disk"})).run()