-
Notifications
You must be signed in to change notification settings - Fork 141
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
validate: add weightDevice validation #570
Conversation
Signed-off-by: Zhou Hao <[email protected]>
6ac882e
to
b351961
Compare
validate/validate_test.go
Outdated
BlockIO: &rspec.LinuxBlockIO{ | ||
WeightDevice: []rspec.LinuxWeightDevice{ | ||
{ | ||
{ |
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.
From Travis:
validate/validate_test.go:568:10: missing type in composite literal
validate/validate_test.go:568:10: implicit assignment of unexported field 'linuxBlockIODevice' in specs.LinuxWeightDevice literal
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.
I don't know what to do with this, but I tried the following calls, and they all went wrong.
WeightDevice: []rspec.LinuxWeightDevice{
linuxBlockIODevice{
Major: 5,
Minor: 0,
},
}
WeightDevice: []rspec.LinuxWeightDevice{
rspec.linuxBlockIODevice{
Major: 5,
Minor: 0,
},
}
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.
I don't know what to do with this, but I tried the following calls, and they all went wrong.
I'm pretty sure you want:
WeightDevice: []rspec.LinuxWeightDevice{
rspec.LinuxWeightDevice{
Major: 5,
Minor: 0,
},
},
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.
This is still wrong.
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.
This is still wrong.
Hmm. Maybe Go has a problem with literal struct initialization for lowercase embedded types. We may need to skip these for the literal initialization and add them later via the promoted properties:
weightDevices := []rspec.LinuxWeightDevice{
rspec.LinuxWeightDevice{},
}
weightDevices[0].Major = 5
weightDevices[0].Minor = 0
Then use WeightDevice: weightDevices
when you initialize your config struct.
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.
Cool. It worked, thanks.
validate/validate.go
Outdated
errs = multierror.Append(errs, | ||
specerror.NewError( | ||
specerror.BlkIOWeightOrLeafWeightExist, | ||
fmt.Errorf("You MUST specify at least one of `weight` or `leafWeight` in a given entry"), |
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.
This string is already covered by BlkIOWeightOrLeafWeightExist
. I think we want something like:
for i, weightDevice := range r.BlockIO.WeightDevice {
…
fmt.Errorf("linux.resources.blockIO.weightDevice[%d] specifies neither weight nor leafWeight", i)
…
}
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.
updated, thanks.
09eb0a3
to
7954c88
Compare
Signed-off-by: Zhou Hao <[email protected]>
7954c88
to
f48ae22
Compare
@liangchenye PTAL |
ping @liangchenye |
I'm working on implement 'kill' this morning. |
According to the following specifications:
You MUST specify at least one of weight or leafWeight in a given entry, and MAY specify both.
implement BlkIOWeightOrLeafWeightExist.
Signed-off-by: Zhou Hao [email protected]