diff --git a/backend/lxd.go b/backend/lxd.go index c4725ab3c..572fda38b 100644 --- a/backend/lxd.go +++ b/backend/lxd.go @@ -25,6 +25,7 @@ import ( ) var ( + lxdArchOverride = "" lxdLimitCPU = "2" lxdLimitCPUBurst = false lxdLimitDisk = "10GB" @@ -41,9 +42,10 @@ var ( lxdDockerPool = "" lxdDockerDisk = "10GB" lxdNetworkIPv6Filtering = "true" - lxdSecurityPrivileged = "false" + lxdSecurityPrivileged = "false" lxdHelp = map[string]string{ + "ARCH_OVERRIDE": fmt.Sprintf("override arch value from job config (default %q)", lxdArchOverride), "EXEC_CMD": fmt.Sprintf("command to run via exec/ssh (default %q)", lxdExecCmd), "EXEC_UID": fmt.Sprintf("UID of travis user (default %d)", lxdExecUID), "MEMORY": fmt.Sprintf("memory to allocate to each container (default %q)", lxdLimitMemory), @@ -63,7 +65,7 @@ var ( "NETWORK_STATIC": fmt.Sprintf("whether to statically set network configuration (default %v)", lxdNetworkStatic), "NETWORK_DNS": fmt.Sprintf("comma separated list of DNS servers (requires NETWORK_STATIC) (default %q)", lxdNetworkDns), "NETWORK_IPV6_FILTERING": fmt.Sprintf("prevent the containers from spoofing another's IPv6 address (default %s)", lxdNetworkIPv6Filtering), - "SECURITY_PRIVILEGED": fmt.Sprintf("request a container to run without a UID mapping when set true (default %s)", lxdSecurityPrivileged), + "SECURITY_PRIVILEGED": fmt.Sprintf("request a container to run without a UID mapping when set true (default %s)", lxdSecurityPrivileged), } ) @@ -93,9 +95,10 @@ type lxdProvider struct { limitNetwork string limitProcess string - image string - runCmd []string - runUID int64 + archOverride string + image string + runCmd []string + runUID int64 imageSelectorType string imageSelector image.Selector @@ -110,7 +113,7 @@ type lxdProvider struct { networkLeases map[string]string networkLeasesLock sync.Mutex networkIPv6Filtering string - securityPrivileged string + securityPrivileged string pool string dockerCache string @@ -126,6 +129,11 @@ func newLXDProvider(cfg *config.ProviderConfig) (Provider, error) { return nil, err } + archOverride := lxdArchOverride + if cfg.IsSet("ARCH_OVERRIDE") { + archOverride = cfg.Get("ARCH_OVERRIDE") + } + execCmd := strings.Split(lxdExecCmd, " ") if cfg.IsSet("EXEC_CMD") { execCmd = strings.Split(cfg.Get("EXEC_CMD"), " ") @@ -307,6 +315,8 @@ func newLXDProvider(cfg *config.ProviderConfig) (Provider, error) { return &lxdProvider{ client: client, + archOverride: archOverride, + limitCPU: limitCPU, limitCPUBurst: limitCPUBurst, limitDisk: limitDisk, @@ -330,7 +340,7 @@ func newLXDProvider(cfg *config.ProviderConfig) (Provider, error) { networkDNS: networkDNS, networkLeases: networkLeases, networkIPv6Filtering: networkIPv6Filtering, - securityPrivileged: securityPrivileged, + securityPrivileged: securityPrivileged, pool: pool, dockerCache: dockerCache, @@ -500,8 +510,13 @@ func (p *lxdProvider) Start(ctx gocontext.Context, startAttributes *StartAttribu if startAttributes.ImageName != "" { imageName = startAttributes.ImageName } else { + imageArch := startAttributes.Arch + if p.archOverride != "" { + imageArch = p.archOverride + } + imageName, err = p.imageSelector.Select(ctx, &image.Params{ - Infra: "lxd-" + startAttributes.Arch, + Infra: "lxd-" + imageArch, Language: startAttributes.Language, OsxImage: startAttributes.OsxImage, Dist: startAttributes.Dist,