Skip to content

Commit ce03266

Browse files
saqibali-2kdustymabe
authored andcommitted
mantle/kola, mantle/platform: split test buckets if merged config is too large
We have seen in the past that the non-exclusive tests' merged config can become too large to pass to cloud providers. To fix this issue we compressed configs (for AWS), but this is only a temporary fix. If a non-exclusive test bucket's config becomes too large, let's split the bucket into two buckets to lower the config size.
1 parent 88c44bc commit ce03266

File tree

12 files changed

+117
-7
lines changed

12 files changed

+117
-7
lines changed

mantle/kola/harness.go

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -593,11 +593,34 @@ func runProvidedTests(testsBank map[string]*register.Test, patterns []string, mu
593593

594594
if len(nonExclusiveTests) > 0 {
595595
buckets := createTestBuckets(nonExclusiveTests)
596-
for i, bucket := range buckets {
596+
numBuckets := len(buckets)
597+
for i := 0; i < numBuckets; {
597598
// This test does not need to be registered since it is temporarily
598599
// created to be used as a wrapper
599-
nonExclusiveWrapper := makeNonExclusiveTest(i, bucket, flight)
600-
tests[nonExclusiveWrapper.Name] = &nonExclusiveWrapper
600+
nonExclusiveWrapper := makeNonExclusiveTest(i, buckets[i], flight)
601+
if flight.ConfigTooLarge(*nonExclusiveWrapper.UserData) {
602+
// Since the merged config size is too large, we will split the bucket into
603+
// two buckets
604+
numTests := len(buckets[i])
605+
if numTests == 1 {
606+
// This test bucket cannot be split further so the single test config
607+
// must be too large
608+
err = fmt.Errorf("test %v has a config that is too large", buckets[i][0].Name)
609+
plog.Fatal(err)
610+
}
611+
newBucket1 := buckets[i][:numTests/2]
612+
newBucket2 := buckets[i][numTests/2:]
613+
buckets[i] = newBucket1
614+
buckets = append(buckets, newBucket2)
615+
// Since we're adding a bucket we'll bump the numBuckets and not
616+
// bump `i` during this loop iteration because we want to run through
617+
// the check again for the current bucket which should now have half
618+
// the tests, but may still have a config that's too large.
619+
numBuckets++
620+
} else {
621+
tests[nonExclusiveWrapper.Name] = &nonExclusiveWrapper
622+
i++ // Move to the next bucket to evaluate
623+
}
601624
}
602625
}
603626

mantle/platform/machine/aws/cluster.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type cluster struct {
3030
flight *flight
3131
}
3232

33-
const maxUserDataSize = 16384
33+
const MaxUserDataSize = 16384
3434

3535
func (ac *cluster) NewMachine(userdata *conf.UserData) (platform.Machine, error) {
3636
return ac.NewMachineWithOptions(userdata, platform.MachineOptions{})
@@ -68,15 +68,15 @@ func (ac *cluster) NewMachineWithOptions(userdata *conf.UserData, options platfo
6868
// Compress via gzip if needed
6969
ud := conf.String()
7070
encoding := base64.StdEncoding.EncodeToString([]byte(ud))
71-
if len([]byte(encoding)) > maxUserDataSize {
71+
if len([]byte(encoding)) > MaxUserDataSize {
7272
ud, err = conf.MaybeCompress()
7373
if err != nil {
7474
return nil, err
7575
}
7676
// Check if config is still too large
7777
encoding = base64.StdEncoding.EncodeToString([]byte(ud))
78-
if len([]byte(encoding)) > maxUserDataSize {
79-
fmt.Printf("WARNING: compressed userdata exceeds expected limit of %d\n", maxUserDataSize)
78+
if len([]byte(encoding)) > MaxUserDataSize {
79+
fmt.Printf("WARNING: compressed userdata exceeds expected limit of %d\n", MaxUserDataSize)
8080
}
8181
}
8282
instances, err := ac.flight.api.CreateInstances(ac.Name(), keyname, ud, 1, int64(options.MinDiskSize))

mantle/platform/machine/aws/flight.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@
1616
package aws
1717

1818
import (
19+
"encoding/base64"
20+
1921
"github.com/coreos/pkg/capnslog"
2022

2123
"github.com/coreos/mantle/platform"
2224
"github.com/coreos/mantle/platform/api/aws"
25+
"github.com/coreos/mantle/platform/conf"
2326
)
2427

2528
const (
@@ -97,6 +100,30 @@ func (af *flight) NewCluster(rconf *platform.RuntimeConfig) (platform.Cluster, e
97100
return ac, nil
98101
}
99102

103+
func (af *flight) ConfigTooLarge(ud conf.UserData) bool {
104+
config, err := ud.Render()
105+
if err != nil {
106+
return true
107+
}
108+
configData := config.String()
109+
encoding := base64.StdEncoding.EncodeToString([]byte(configData))
110+
if len([]byte(encoding)) > MaxUserDataSize {
111+
configData, err = config.MaybeCompress()
112+
if err != nil {
113+
return true
114+
}
115+
// Check if config is still too large
116+
encoding = base64.StdEncoding.EncodeToString([]byte(configData))
117+
if len([]byte(encoding)) > MaxUserDataSize {
118+
// Config is too large
119+
return true
120+
}
121+
}
122+
123+
// Config is not too large
124+
return false
125+
}
126+
100127
func (af *flight) Destroy() {
101128
if af.keyAdded {
102129
if err := af.api.DeleteKey(af.Name()); err != nil {

mantle/platform/machine/azure/flight.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020

2121
"github.com/coreos/mantle/platform"
2222
"github.com/coreos/mantle/platform/api/azure"
23+
"github.com/coreos/mantle/platform/conf"
2324
)
2425

2526
const (
@@ -118,6 +119,12 @@ func (af *flight) NewCluster(rconf *platform.RuntimeConfig) (platform.Cluster, e
118119
return ac, nil
119120
}
120121

122+
func (af *flight) ConfigTooLarge(ud conf.UserData) bool {
123+
124+
// not implemented
125+
return false
126+
}
127+
121128
func (af *flight) Destroy() {
122129
af.BaseFlight.Destroy()
123130
}

mantle/platform/machine/do/flight.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222

2323
"github.com/coreos/mantle/platform"
2424
"github.com/coreos/mantle/platform/api/do"
25+
"github.com/coreos/mantle/platform/conf"
2526
)
2627

2728
const (
@@ -106,6 +107,12 @@ func (df *flight) NewCluster(rconf *platform.RuntimeConfig) (platform.Cluster, e
106107
return dc, nil
107108
}
108109

110+
func (af *flight) ConfigTooLarge(ud conf.UserData) bool {
111+
112+
// not implemented
113+
return false
114+
}
115+
109116
func (df *flight) Destroy() {
110117
for _, keyID := range []int{df.sshKeyID, df.fakeSSHKeyID} {
111118
if keyID == 0 {

mantle/platform/machine/esx/flight.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020

2121
"github.com/coreos/mantle/platform"
2222
"github.com/coreos/mantle/platform/api/esx"
23+
"github.com/coreos/mantle/platform/conf"
2324
)
2425

2526
const (
@@ -56,6 +57,12 @@ func NewFlight(opts *esx.Options) (platform.Flight, error) {
5657
return ef, nil
5758
}
5859

60+
func (af *flight) ConfigTooLarge(ud conf.UserData) bool {
61+
62+
// not implemented
63+
return false
64+
}
65+
5966
// NewCluster creates an instance of a Cluster suitable for spawning
6067
// instances on VMware ESXi vSphere platform.
6168
func (ef *flight) NewCluster(rconf *platform.RuntimeConfig) (platform.Cluster, error) {

mantle/platform/machine/gcloud/flight.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121

2222
"github.com/coreos/mantle/platform"
2323
"github.com/coreos/mantle/platform/api/gcloud"
24+
"github.com/coreos/mantle/platform/conf"
2425
)
2526

2627
type flight struct {
@@ -55,6 +56,12 @@ func NewFlight(opts *gcloud.Options) (platform.Flight, error) {
5556
return gf, nil
5657
}
5758

59+
func (af *flight) ConfigTooLarge(ud conf.UserData) bool {
60+
61+
// not implemented
62+
return false
63+
}
64+
5865
func (gf *flight) NewCluster(rconf *platform.RuntimeConfig) (platform.Cluster, error) {
5966
bc, err := platform.NewBaseCluster(gf.BaseFlight, rconf)
6067
if err != nil {

mantle/platform/machine/openstack/flight.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919

2020
"github.com/coreos/mantle/platform"
2121
"github.com/coreos/mantle/platform/api/openstack"
22+
"github.com/coreos/mantle/platform/conf"
2223
)
2324

2425
const (
@@ -86,6 +87,12 @@ func (of *flight) NewCluster(rconf *platform.RuntimeConfig) (platform.Cluster, e
8687
return oc, nil
8788
}
8889

90+
func (af *flight) ConfigTooLarge(ud conf.UserData) bool {
91+
92+
// not implemented
93+
return false
94+
}
95+
8996
func (of *flight) Destroy() {
9097
if of.keyAdded {
9198
if err := of.api.DeleteKey(of.Name()); err != nil {

mantle/platform/machine/packet/flight.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020

2121
"github.com/coreos/mantle/platform"
2222
"github.com/coreos/mantle/platform/api/packet"
23+
"github.com/coreos/mantle/platform/conf"
2324
)
2425

2526
const (
@@ -85,6 +86,12 @@ func (pf *flight) NewCluster(rconf *platform.RuntimeConfig) (platform.Cluster, e
8586
return pc, nil
8687
}
8788

89+
func (af *flight) ConfigTooLarge(ud conf.UserData) bool {
90+
91+
// not implemented
92+
return false
93+
}
94+
8895
func (pf *flight) Destroy() {
8996
if pf.sshKeyID != "" {
9097
if err := pf.api.DeleteKey(pf.sshKeyID); err != nil {

mantle/platform/machine/qemuiso/flight.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/coreos/pkg/capnslog"
1919

2020
"github.com/coreos/mantle/platform"
21+
"github.com/coreos/mantle/platform/conf"
2122
)
2223

2324
const (
@@ -58,6 +59,12 @@ func NewFlight(opts *Options) (platform.Flight, error) {
5859
return qf, nil
5960
}
6061

62+
func (af *flight) ConfigTooLarge(ud conf.UserData) bool {
63+
64+
// not implemented
65+
return false
66+
}
67+
6168
// NewCluster creates a Cluster instance, suitable for running virtual
6269
// machines in QEMU.
6370
func (qf *flight) NewCluster(rconf *platform.RuntimeConfig) (platform.Cluster, error) {

0 commit comments

Comments
 (0)