Skip to content

Split container runtime state from config#28483

Closed
cpuguy83 wants to merge 1 commit intomoby:masterfrom
cpuguy83:split_cntr_runtime_data
Closed

Split container runtime state from config#28483
cpuguy83 wants to merge 1 commit intomoby:masterfrom
cpuguy83:split_cntr_runtime_data

Conversation

@cpuguy83
Copy link
Copy Markdown
Member

@cpuguy83 cpuguy83 commented Nov 16, 2016

This is step-1 of implementing a lock-less container object.
This moves the live/runtime state off the container object onto a
separately managed object.

Effectively, these are items on the container struct that cannot (or
should not) be copied, e.g. i/o streams, signal channels, secrets, etc.

The new object is stored in a package level singleton that the container
object is able to get at. The objects are keyed by the container ID,
this means using the singleton should not cause any issues with other
uses (e.g. tests, dep injection, etc) as container ID's are unique.

Replaces some of the work from #26759

Signed-off-by: Brian Goff [email protected]

@LK4D4
Copy link
Copy Markdown
Contributor

LK4D4 commented Nov 16, 2016

@cpuguy83 I'm not really a fan of singletons. What's problem with creating object on-demand?

@cpuguy83
Copy link
Copy Markdown
Member Author

cpuguy83 commented Nov 16, 2016

@LK4D4 I'm generally not a fan either, but I think it works out pretty well here, particularly because container ids must be unique.

I'm not sure where else to put this at the moment other than on the daemon, which seems worse to me.

Comment thread container/monitor.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

let's follow "convention" and put mu on top of protected fields.

Comment thread container/monitor.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

where cleanup of this state happens?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

On daemon.cleanupContainer we call container.RemoveRunState(), which calls this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, I mean what stops logger and copier and other stuff. Where we make sure that we have no references to fields of state in goroutines.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You want to verify that everything is stopped first, works for me.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ok, now we container.Reset() before calling removeRunState

Comment thread container/monitor.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks like add is not really used as add, more like create. Maybe remove s argument and allocate state here?

@cpuguy83
Copy link
Copy Markdown
Member Author

Test failure looks legit, taking a look.

@cpuguy83 cpuguy83 force-pushed the split_cntr_runtime_data branch from cf349fe to 5db3fee Compare November 16, 2016 20:41
@cpuguy83
Copy link
Copy Markdown
Member Author

And all green.

@cpuguy83
Copy link
Copy Markdown
Member Author

cpuguy83 commented Nov 17, 2016

@LK4D4 Maybe I can put his into container.Store somewhere.

@cpuguy83
Copy link
Copy Markdown
Member Author

I think for now I'll just store it on container. This PR will introduce a nice split bewteen config and runtime, can take it further in another PR.

@cpuguy83
Copy link
Copy Markdown
Member Author

cpuguy83 commented Dec 6, 2016

Would be great to get more eyes on this.

@cpuguy83 cpuguy83 force-pushed the split_cntr_runtime_data branch from bd66004 to 46875e4 Compare December 6, 2016 16:11
This is step-1 of implementing a lock-less container object.
This moves the live/runtime state off the container object onto a
separately managed object.

Effectively, these are items on the container struct that cannot (or
should not) be copied, e.g. i/o streams, signal channels, etc.

Signed-off-by: Brian Goff <[email protected]>
@cpuguy83 cpuguy83 force-pushed the split_cntr_runtime_data branch from 46875e4 to b1dacbe Compare December 6, 2016 16:16
@thaJeztah thaJeztah added the status/needs-attention Calls for a collective discussion during a review session label Dec 10, 2016
@thaJeztah
Copy link
Copy Markdown
Member

ping @tonistiigi @crosbymichael could you have a look at this one?

@vdemeester
Copy link
Copy Markdown
Member

@cpuguy83 needs a rebase
@tonistiigi @crosbymichael @LK4D4 ptal 🙇

@tonistiigi
Copy link
Copy Markdown
Member

@cpuguy83 Could we have a design outline for "lockless container object" with the description of the steps/problems involved. There maybe general comments first and it would make reviewing the individual steps easier.

@cpuguy83
Copy link
Copy Markdown
Member Author

@tonistiigi #30225

@estesp
Copy link
Copy Markdown
Contributor

estesp commented Jan 18, 2017

@cpuguy83 and other maintainers: given the proposal is being discussed now in the GH issue, should we still be reviewing this code? I had offered to start reviewing, but if you think there might be a shift in direction based on the proposal discussion, I'll hold off.

@LK4D4
Copy link
Copy Markdown
Contributor

LK4D4 commented Jan 27, 2017

This still depends on #30225

@thaJeztah
Copy link
Copy Markdown
Member

closing for now while we discuss on #30225

@thaJeztah thaJeztah closed this Feb 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/needs-attention Calls for a collective discussion during a review session status/1-design-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants