-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add config field to specify chroot mapping for exec driver #1518
Changes from 2 commits
1876fc2
09f2fc9
593669a
6201588
bd0363b
95c1d76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -227,7 +227,12 @@ func (e *UniversalExecutor) configureChroot() error { | |
return err | ||
} | ||
|
||
if err := allocDir.Embed(e.ctx.Task.Name, chrootEnv); err != nil { | ||
chroot := chrootEnv | ||
if e.command.ChrootEnv != nil && len(e.command.ChrootEnv) > 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
chroot = e.command.ChrootEnv | ||
} | ||
|
||
if err := allocDir.Embed(e.ctx.Task.Name, chroot); err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add a test for this as well? It would be nice if the test asserts that only the specified top level directories specified by the operator are present in the chroot. |
||
return err | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -315,6 +315,7 @@ func parseClient(result **ClientConfig, list *ast.ObjectList) error { | |
"node_class", | ||
"options", | ||
"meta", | ||
"chroot_env", | ||
"network_interface", | ||
"network_speed", | ||
"max_kill_timeout", | ||
|
@@ -334,6 +335,7 @@ func parseClient(result **ClientConfig, list *ast.ObjectList) error { | |
|
||
delete(m, "options") | ||
delete(m, "meta") | ||
delete(m, "chroot_env") | ||
delete(m, "reserved") | ||
delete(m, "stats") | ||
|
||
|
@@ -370,6 +372,20 @@ func parseClient(result **ClientConfig, list *ast.ObjectList) error { | |
} | ||
} | ||
|
||
// Parse out chroot_env fields. These are in HCL as a list so we need to | ||
// iterate over them and merge them. | ||
if chrootEnvO := listVal.Filter("chroot_env"); len(chrootEnvO.Items) > 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a test for this |
||
for _, o := range chrootEnvO.Elem().Items { | ||
var m map[string]interface{} | ||
if err := hcl.DecodeObject(&m, o.Val); err != nil { | ||
return err | ||
} | ||
if err := mapstructure.WeakDecode(m, &config.ChrootEnv); err != nil { | ||
return err | ||
} | ||
} | ||
} | ||
|
||
// Parse reserved config | ||
if o := listVal.Filter("reserved"); len(o.Items) > 0 { | ||
if err := parseReserved(&config.Reserved, o); err != nil { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this field to
ExecutorContext