-
Notifications
You must be signed in to change notification settings - Fork 174
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
Migrate container configuration in portlayer in memory #4146
Conversation
@matthewavery added you as reviewer cause you ever worked on this issue. |
@@ -88,6 +88,7 @@ type VicContainerProxy interface { | |||
|
|||
Stop(vc *viccontainer.VicContainer, name string, seconds *int, unbound bool) error | |||
IsRunning(vc *viccontainer.VicContainer) (bool, error) | |||
IsBroken(vc *viccontainer.VicContainer) (bool, error) |
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.
Are we sure this will only be needed in the container endpoints? I am wondering if we will need this information for networks or volumes at some point.
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.
Right now, guess this is fine.
This information is needed by container stop/start/rm, cause we still allow user to delete the broken container. But for all the other functions, if the configuration is available after half migration, those piece of function will looks good, it otherwise, that will not. The function is consistent.
We don't that care about the function of broken containers atm, as long as that's deletable.
lib/config/executor/container_vm.go
Outdated
@@ -34,7 +34,7 @@ type Common struct { | |||
// A reference to the components hosting execution environment, if any | |||
ExecutionEnvironment string | |||
|
|||
// Unambiguous ID with meaning in the context of its hosting execution environment | |||
// Unambiguous ID with meaning in the context of its hosting execution environment. Change this definition will cause container backward compatibility issue |
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.
please add "Please don't change this." I am not sure, you might add a "without talking to emma lin" to that. That way if someone does want to change it for whatever reason they can talk to you about why they likely shouldn't.
lgtm 😄 , other than the comment on the container ID field. Though that is simply a suggestion. |
For easy to understand, here I posted the output of docker commands if there is one container broken for data migration error(the error if faked, I cannot have a real failure for that now):
|
return false, err | ||
} | ||
|
||
return inspectJSON.State.Running, nil | ||
return inspectJSON.State.Status == "broken", nil |
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.
Are there any statuses defined as constants? Using strings is not the best solution especially if it used more than 2 times across all project.
I also don't like IsBroken method. It's just awkward. There should be a method that returns status only it would be way more useful for other possible cases too.
if err != nil && IsNotFoundError(err) { | ||
cache.ContainerCache().DeleteContainer(vc.ContainerID) | ||
return err | ||
} | ||
if !running { | ||
// attempt to stop container if status is running or broken | ||
if !inspectJSON.State.Running && inspectJSON.State.Status != "broken" { |
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 we make this string a const?
info.ContainerConfig.State = s | ||
var state string | ||
if container.MigrationError != nil { | ||
state = "broken" |
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.
Ditto
lib/config/executor/container_vm.go
Outdated
@@ -34,7 +34,7 @@ type Common struct { | |||
// A reference to the components hosting execution environment, if any | |||
ExecutionEnvironment string | |||
|
|||
// Unambiguous ID with meaning in the context of its hosting execution environment | |||
// Unambiguous ID with meaning in the context of its hosting execution environment. Change this definition will cause container backward compatibility issue. Please don't change this. |
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.
Change/Changing
Also the comment might be little bit more than this so that reader can understand why he/she shouldn't be changing this
@@ -146,6 +146,12 @@ func Commit(ctx context.Context, sess *session.Session, h *Handle, waitTime *int | |||
log.Debugf("Nilifying ExtraConfig as we are running") | |||
s.ExtraConfig = nil | |||
} | |||
// nilify ExtraConfig if container configuration is migrated | |||
// in this case, VCH and container are in different version. Migrated configuration cannot be written back to old container, to avoid data loss in old version's container | |||
if h.Migrated { |
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.
We are setting ExtraConfig to nil if we are powered on so why do we need this?
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 because configuration data is migrated. If write back to container vmx file, the old binary cannot read back new data. We ever talked about that part in one meeting, remember?
970a3e6
to
ccaf115
Compare
6798498
to
554b448
Compare
This value is used to skip new features on old containers
return err | ||
} | ||
// force stop if container is broken to make sure container is deletable later | ||
if state.Status == ContainerError { |
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 checking for status "error". Is this what you're using for "broken"?
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.
So, I see where you're setting it on the portlayer side. Since this is our state string, why not use a more explicit string, such as "migrating"?
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.
yes
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 one error state caused by migration, not a working state as migrating. I think we might have other incorrect scenarios other than migration error, so I didn't use migration error as the state.
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.
Ok, I just got broken was an actual status. It's actually a description, meaning the status is error.
Can you change the comment to say "if container is in an error state"? Or is broken the best description?
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'll update the comment.
defer trace.End(trace.Begin("")) | ||
|
||
if c.client == nil { | ||
return false, InternalServerError("ContainerProxy.IsRunning failed to get a portlayer client") | ||
return nil, InternalServerError("ContainerProxy.dockerInfo failed to get a portlayer client") |
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.
.State and not .dockerInfo
Fixes #3610