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

Inspect all property changes before exiting WaitForKeyInExtraConfig #5938

Merged
merged 1 commit into from
Aug 15, 2017

Conversation

sflxn
Copy link
Contributor

@sflxn sflxn commented Aug 7, 2017

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

@sflxn sflxn requested review from dougm and hickeng August 7, 2017 23:02
@sflxn sflxn force-pushed the nonexistent_group branch from 6784243 to 2e7e599 Compare August 7, 2017 23:03
@sflxn sflxn requested review from emlin and hickeng and removed request for hickeng August 7, 2017 23:03
err := vm.WaitForExtraConfig(ctx, waitFunc)
if err == nil && poweredOff != nil {
if err == nil && poweredOff != nil && detail == "" {
Copy link
Contributor

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

@dougm
Copy link
Member

dougm commented Aug 14, 2017

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.

@sflxn
Copy link
Contributor Author

sflxn commented Aug 14, 2017

Thanks Doug. I was wondering if I could do that also, but I wasn't sure if that actually affected the ordering.

@dougm
Copy link
Member

dougm commented Aug 14, 2017

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)

@@ -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
Copy link
Contributor

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.

@@ -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
Copy link
Contributor

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.

@sflxn sflxn force-pushed the nonexistent_group branch 2 times, most recently from 1ad8165 to 808b23d Compare August 15, 2017 16:23
Copy link
Contributor

@mhagen-vmware mhagen-vmware left a comment

Choose a reason for hiding this comment

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

lgtm

@sflxn sflxn force-pushed the nonexistent_group branch 3 times, most recently from f6be904 to 07d9197 Compare August 15, 2017 16:43
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
@sflxn sflxn merged commit f4f8ef7 into vmware:master Aug 15, 2017
AngieCris pushed a commit to AngieCris/vic that referenced this pull request Nov 20, 2017
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants