-
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
Inspect all property changes before exiting WaitForKeyInExtraConfig #5938
Conversation
6784243
to
2e7e599
Compare
pkg/vsphere/vm/vm.go
Outdated
err := vm.WaitForExtraConfig(ctx, waitFunc) | ||
if err == nil && poweredOff != nil { | ||
if err == nil && poweredOff != nil && detail == "" { |
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 think the check detail == ""
can help to avoid powerdOff error if the value is already set by tether.
But what's the benefit to set exitEarly above? If you want, maybe you could just return at line 202, https://github.com/vmware/vic/pull/5938/files#diff-818b18702ad1cb5203eeaccc54071e09R202
Simpler fix would be to swap the property order here: https://github.com/vmware/vic/blob/master/pkg/vsphere/vm/vm.go#L176 So if we get both properties in the same update set, we examine the extraConfig before the powerState. |
Thanks Doug. I was wondering if I could do that also, but I wasn't sure if that actually affected the ordering. |
The test will need fixing too: modified pkg/vsphere/vm/vm_test.go
@@ -339,7 +339,6 @@ func TestWaitForKeyInExtraConfig(t *testing.T) {
opt := &types.OptionValue{Key: "foo", Value: "bar"}
obj := simulator.Map.Get(vm.Reference()).(*simulator.VirtualMachine)
- obj.Config.ExtraConfig = append(obj.Config.ExtraConfig, opt)
val, err := vm.WaitForKeyInExtraConfig(ctx, opt.Key)
@@ -347,6 +346,7 @@ func TestWaitForKeyInExtraConfig(t *testing.T) {
t.Error("expected error")
}
+ obj.Config.ExtraConfig = append(obj.Config.ExtraConfig, opt)
obj.Summary.Runtime.PowerState = types.VirtualMachinePowerStatePoweredOn
val, err = vm.WaitForKeyInExtraConfig(ctx, opt.Key) |
pkg/vsphere/vm/vm.go
Outdated
@@ -198,30 +199,30 @@ func (vm *VirtualMachine) WaitForKeyInExtraConfig(ctx context.Context, key strin | |||
if key == value.GetOptionValue().Key { | |||
detail = value.GetOptionValue().Value.(string) | |||
if detail != "" && detail != "<nil>" { | |||
return true | |||
exitEarly = true | |||
} | |||
break // continue the outer loop as we may have a powerState change too |
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.
break is not needed here.
pkg/vsphere/vm/vm.go
Outdated
@@ -198,30 +199,30 @@ func (vm *VirtualMachine) WaitForKeyInExtraConfig(ctx context.Context, key strin | |||
if key == value.GetOptionValue().Key { | |||
detail = value.GetOptionValue().Value.(string) | |||
if detail != "" && detail != "<nil>" { | |||
return true | |||
exitEarly = true |
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.
How does it help to iterate over all values? It literally looks like you just need to exist in place where you assign true.
1ad8165
to
808b23d
Compare
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.
lgtm
f6be904
to
07d9197
Compare
There are cases where a container starts up and shuts down very quickly. We treated this case as early termination because the tether failed to initialize. However, in quick to shut down containers, the tether may have initialized and written out return codes, but we read the power off before we read the codes. We now read the status code before the power state changes in WaitForKeyInExtraConfig. This should allow us to not misinterpret quick ending containers. Resolves vmware#5629
…mware#5938) There are cases where a container starts up and shuts down very quickly. We treated this case as early termination because the tether failed to initialize. However, in quick to shut down containers, the tether may have initialized and written out return codes, but we read the power off before we read the codes. We now read the status code before the power state changes in WaitForKeyInExtraConfig. This should allow us to not misinterpret quick ending containers. Resolves vmware#5629
There are cases where a container starts up and shuts down very quickly. We
treated this case as early termination because the tether failed to initialize.
However, in quick to shut down containers, the tether may have initialized and
written out return codes, but we read the power off before we read the codes.
We now read the status code before the power state changes in WaitForKeyInExtraConfig.
This should allow us to not misinterpret quick ending containers.
Resolves #5629