Migrate container configuration in portlayer in memory#4146
Migrate container configuration in portlayer in memory#4146emlin merged 9 commits intovmware:masterfrom
Conversation
|
@matthewavery added you as reviewer cause you ever worked on this issue. |
|
|
||
| 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.
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.
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
| 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.
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 inspectJSON.State.Running, nil | ||
| return inspectJSON.State.Status == "broken", nil |
There was a problem hiding this comment.
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 !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.
can we make this string a const?
| info.ContainerConfig.State = s | ||
| var state string | ||
| if container.MigrationError != nil { | ||
| state = "broken" |
lib/config/executor/container_vm.go
Outdated
| 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.
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
| } | ||
| // 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.
We are setting ExtraConfig to nil if we are powered on so why do we need this?
There was a problem hiding this comment.
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.
This is checking for status "error". Is this what you're using for "broken"?
There was a problem hiding this comment.
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.
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.
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.
I'll update the comment.
|
|
||
| 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") |
Fixes #3610