Fixes a default config bug of gc scheduler#2214
Conversation
f94b6bd to
40f80d3
Compare
There was a problem hiding this comment.
Why was this change necessary? Can't you just add MarshalText ?
There was a problem hiding this comment.
Why was this change necessary?
It can avoid type conversion like time.Duration(cfg.ScheduleDelay).
Can't you just add
MarshalText?
UnmarshalText is not added by me.
Isn't it used when loading config file? I will verify it.
There was a problem hiding this comment.
@dnephin We need UnmarshalText when loading config file, otherwise containerd service can not start with the error log:
containerd: toml: type mismatch for scheduler.duration: expected table but found string
But I modify UnmarshalText like:
func (d duration) UnmarshalText(_ []byte) error {
return nil
}Still works well, don't know why! 😅
There was a problem hiding this comment.
return nil is probably ignoring the problem, it suspect it will serialize to nothing.
My comment wasn't about UnarmshalText. I think it was correct and doesn't need to change.
I was suggesting it would be better to leave the type as type duration time.Duration and remove the other changes from this PR. I don't think the type conversion is a problem. The only thing that needs to change is adding MarshalText
There was a problem hiding this comment.
@dnephin Thanks for review, have address your comment.
79034af to
4206a00
Compare
Signed-off-by: Yanqiang Miao <[email protected]>
4206a00 to
d465f85
Compare
dnephin
left a comment
There was a problem hiding this comment.
Thanks. A unit test that show the the roundtrip of values (Marshal, then Unmarshal duration) would be great, especially the value that you found was a problem before.
|
LGTM @dmcgowan PTAL |
|
LGTM |
I ran the
containerdservice with the default config, the service failed when loading config file with error log:That's because
toml.Decodecan not decode100000000totime.Durationvariable.We should encode
time.Durationvariable to string with unit (e.g.:100000000->"100ms") when print the the default config withcontainerd config default.This pr fixes the bug.
Signed-off-by: Yanqiang Miao [email protected]