|
29 | 29 | reAppcVersion = regexp.MustCompile(`appc version (\d[.\d]+)`)
|
30 | 30 | )
|
31 | 31 |
|
| 32 | +const ( |
| 33 | + // rkt added support for CPU and memory isolators in 0.14.0. We cannot support |
| 34 | + // an earlier version to maintain an uniform interface across all drivers |
| 35 | + minRktVersion = "0.14.0" |
| 36 | + conversionFactor = 1024 * 1024 |
| 37 | +) |
| 38 | + |
32 | 39 | // RktDriver is a driver for running images via Rkt
|
33 | 40 | // We attempt to chose sane defaults for now, with more configuration available
|
34 | 41 | // planned in the future
|
@@ -86,7 +93,7 @@ func (d *RktDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool, e
|
86 | 93 | node.Attributes["driver.rkt.version"] = rktMatches[1]
|
87 | 94 | node.Attributes["driver.rkt.appc.version"] = appcMatches[1]
|
88 | 95 |
|
89 |
| - minVersion, _ := version.NewVersion("0.14.0") |
| 96 | + minVersion, _ := version.NewVersion(minRktVersion) |
90 | 97 | currentVersion, _ := version.NewVersion(node.Attributes["driver.rkt.version"])
|
91 | 98 | if currentVersion.LessThan(minVersion) {
|
92 | 99 | // Do not allow rkt < 0.14.0
|
@@ -165,7 +172,7 @@ func (d *RktDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, e
|
165 | 172 | }
|
166 | 173 |
|
167 | 174 | // Add memory isolator
|
168 |
| - cmdArgs = append(cmdArgs, fmt.Sprintf("--memory=%vM", int64(task.Resources.MemoryMB)*1024*1024)) |
| 175 | + cmdArgs = append(cmdArgs, fmt.Sprintf("--memory=%vM", int64(task.Resources.MemoryMB)*conversionFactor)) |
169 | 176 |
|
170 | 177 | // Add CPU isolator
|
171 | 178 | cmdArgs = append(cmdArgs, fmt.Sprintf("--cpu=%vm", int64(task.Resources.CPU)))
|
|
0 commit comments