Skip to content
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

Fixes a default config bug of gc scheduler #2214

Merged
merged 1 commit into from
Mar 22, 2018

Conversation

miaoyq
Copy link
Member

@miaoyq miaoyq commented Mar 17, 2018

I ran the containerd service with the default config, the service failed when loading config file with error log:

containerd[10993]: containerd: time: missing unit in duration 100000000

That's because toml.Decode can not decode 100000000 to time.Duration variable.

We should encode time.Duration variable to string with unit (e.g.: 100000000 -> "100ms") when print the the default config with containerd config default.

This pr fixes the bug.

Signed-off-by: Yanqiang Miao miao.yanqiang@zte.com.cn

@miaoyq miaoyq force-pushed the fixes-config-bug branch 3 times, most recently from f94b6bd to 40f80d3 Compare March 17, 2018 14:18
type duration time.Duration
type duration struct {
time.Duration
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this change necessary? Can't you just add MarshalText ?

Copy link
Member Author

@miaoyq miaoyq Mar 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

@miaoyq miaoyq Mar 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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! 😅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member Author

@miaoyq miaoyq Mar 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dnephin Thanks for review, have address your comment.

@miaoyq miaoyq force-pushed the fixes-config-bug branch 3 times, most recently from 79034af to 4206a00 Compare March 19, 2018 04:38
Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>
Copy link
Contributor

@dnephin dnephin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@stevvooe
Copy link
Member

LGTM

@dmcgowan PTAL

@stevvooe stevvooe added this to the 1.1 milestone Mar 22, 2018
@dmcgowan
Copy link
Member

LGTM

@dmcgowan dmcgowan merged commit 804249c into containerd:master Mar 22, 2018
@miaoyq miaoyq deleted the fixes-config-bug branch March 24, 2018 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants