-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Set user for rkt tasks #3612
Set user for rkt tasks #3612
Conversation
client/driver/docker.go
Outdated
@@ -201,6 +201,7 @@ type DockerDriverConfig struct { | |||
MacAddress string `mapstructure:"mac_address"` // Pin mac address to container | |||
SecurityOpt []string `mapstructure:"security_opt"` // Flags to pass directly to security-opt | |||
Devices []DockerDevice `mapstructure:"devices"` // To allow mounting USB or other serial control devices | |||
User string `json:"User,omitempty" yaml:"User,omitempty" toml:"User,omitempty"` |
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.
whats up with the yaml and toml here?
Testing suggestions are more than welcome. |
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.
You can test by specifying a non-existent user:
docker run --user alice redis:3.2
docker: Error response from daemon: linux spec user: unable to find user alice: no matching entries in passwd file.
client/driver/docker.go
Outdated
@@ -201,6 +201,7 @@ type DockerDriverConfig struct { | |||
MacAddress string `mapstructure:"mac_address"` // Pin mac address to container | |||
SecurityOpt []string `mapstructure:"security_opt"` // Flags to pass directly to security-opt | |||
Devices []DockerDevice `mapstructure:"devices"` // To allow mounting USB or other serial control devices | |||
User string `mapstructure:user` |
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.
Why add a new config field instead of using the task.User?
e59d8f8
to
23b7042
Compare
Changed this as we already expose this functionality for Docker, see https://www.nomadproject.io/docs/job-specification/task.html#user. Added the change to pass this through for rkt. |
@@ -569,6 +569,11 @@ func (d *RktDriver) Start(ctx *ExecContext, task *structs.Task) (*StartResponse, | |||
|
|||
} | |||
|
|||
// If a user has been specified for the task, pass it through to the user |
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.
See if you can add tests to this and for docker
|
||
select { | ||
case res := <-resp.Handle.WaitCh(): | ||
assert.False(res.Successful()) |
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.
Can you assert it fails b/c the user
I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions. |
Further testing is necessary for each case