Skip to content

Inhibit issues with concurrent execs#8098

Merged
hickeng merged 2 commits intovmware:masterfrom
hickeng:7410-minimal
Jun 28, 2018
Merged

Inhibit issues with concurrent execs#8098
hickeng merged 2 commits intovmware:masterfrom
hickeng:7410-minimal

Conversation

@hickeng
Copy link
Contributor

@hickeng hickeng commented Jun 26, 2018

This PR contains two sets of changes:

  1. long term code using updated extraconfig recursion tags
  2. short term code addressing a serialization issue with the "started" field and palliative locking
[skip unit]
[specific ci=1-38-Docker-Exec,6-15-Syslog]
[parallel jobs=4]

Towards #7410

Investigating CI failures:

  • 1-02-Docker-Pull - Running docker pull victest/registry-busybox:latest
  • 1-09-Docker-Attach
    • Attach with short input
    • Attach with short output with tty
  • 1-17-Docker-Network-Connect - Connect container to multiple networks concurrently
    • same issue as for docker attach - concurrent access error not being correctly identified.
  • 1-38-Docker-Exec
    • Concurrent Simple Exec Detached
      • test error - mismatch between process name and later reference
    • Exec During Poweroff Of A Container Performing A Long Running Task - case mismatch
    • Exec During Poweroff Of A Container Performing A Short Running Task - case mismatch
  • Test 6-15 - Verify remote syslog

@hickeng hickeng requested a review from a team as a code owner June 26, 2018 23:33
@hickeng hickeng force-pushed the 7410-minimal branch 2 times, most recently from 9a6e0ba to c554f91 Compare June 27, 2018 01:26
// we special case this for now as we _presume_ that it's either a conflict
// of reconfigure with guest operation, or a conflict with another guest operation.
// These cases do not return a TaskInProgress or concurrent modification.
return ConcurrentAccessError{errors.New("invalid state from start guest program")}
Copy link
Member

Choose a reason for hiding this comment

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

Would there be any benefit to logging err or including it in the new error being constructed here? (E.g., to allow us to use log data to validate the presumption described in the comment above if something doesn't seem to be working quite as expected.)

IP *net.IPNet `vic:"0.1" scope:"read-only" key:"ip"`

// Actual IP address assigned
// TODO: should this skip decode? - if it's used to seed DHCP requests for semi-stable addressing then
Copy link
Member

Choose a reason for hiding this comment

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

Should we file a ticket to track this TODO?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will remove the TODO - with the benefit of time I can recall that the non-persistent keys will never be written from the API side while the VM is powered on. This would only become necessary if we were to change that AND had a reason to update this field from the API side (I cannot think of one).

}

// IsInvalidStateError is an error certifier function for errors coming back from vsphere. It checks for an InvalidStateFault
func IsInvalidStateError(err error) bool {
Copy link
Member

Choose a reason for hiding this comment

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

Is there code that should be updated to call this now that it exists? (If so, that should probably be handled in a separate PR.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is, for example lib/portlayer/storage/vsphere/toolbox_common.go. Opened #8099 for it.

// IsInvalidStateError is an error certifier function for errors coming back from vsphere. It checks for an InvalidStateFault
func IsInvalidStateError(err error) bool {
if soap.IsVimFault(err) {
_, ok1 := soap.ToVimFault(err).(*types.InvalidState)
Copy link
Member

Choose a reason for hiding this comment

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

In the other similar methods, we also check for the *types.____Fault here. Is there a reason we don't check for types.InvalidStateFault in this case? (If so, that would be good to document in a comment here so that future readers don't assume it's a mistake.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

iirc types.InvalidStateFault does not implement GetMethodFault() method so it won't compile. I confess I've not dug into why this one is not the same as the others. @dougm ?

return ok1 || ok2 || soap.ToSoapFault(err).String == "vim.fault.InvalidPowerState" ||
soap.ToSoapFault(err).String == "vim.fault.InvalidPowerState"
}
return false
Copy link
Member

Choose a reason for hiding this comment

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

This whole method seems to be basically repeated many times. Would there be value in defining a helper that takes the four "variable" pieces (two interfaces, two strings) as arguments? (If so, that should probably be handled in a separate PR.)

Copy link
Contributor Author

@hickeng hickeng Jun 27, 2018

Choose a reason for hiding this comment

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

The entire thing should be in govmomi. I think it would end up being either significantly rewritten to use reflection (viable but much harder to read) or would take four types as the pointers are separate types in this case.

I'd prefer just to move it all to govmomi and make it @dougm's problem ;) Opened #8099 for follow up.

@hickeng hickeng force-pushed the 7410-minimal branch 2 times, most recently from 6d40464 to 6950f83 Compare June 27, 2018 04:08
@hickeng
Copy link
Contributor Author

hickeng commented Jun 27, 2018

1-09-Docker-Attach

Attach with short input
VCH: VCH-19517-3070
Bridge: VCH-19517-705
Container: vigilant_yonath-6c2994112e23
Command:

docker -H dhcp-wdc-pod2-haas01-76.eng.vmware.com:2376 --tls start -ai 6c2994112e231402e60f218368f19b120b5b5f73721e5d44a04ba46322c9807a < /tmp/tmp.0k7B3JBWly/fifo

Stderr: Unrecognized input header: 83

Personna:

op=351.18 - container create
op=351.19 - container inspect

op=351.20 - container attach
op=351.21 - container start
==> Event Monitor received eventID(339.76) for container(6c2994112e23) - Started
op=351.20 - container attach - end
op=351.21 - container start - end

op=351.22 - exit code (from event monitor)
==> die event for container(6c2994112e23) with exitCode[0]

op=351.23 - container inspect

op=351.24 - container attach
op=351.25 - container start
==> Event Monitor received eventID(339.92) for container(6c2994112e23) - Started
op=351.24 - container attach - end
op=351.26 - exit code (from event monitor)
==> die event for container(6c2994112e23) with exitCode[0]
op=351.25 - container start - end

op=351.27 - container inspect

op=351.28 - container attach
==> Cannot complete operation due to concurrent modification by another operation
op=351.28 - container attach - end
op=351.29 - container start
==> Event Monitor received eventID(339.107) for container(6c2994112e23) - Started
---> We got `Started` instead of `Powered On` because the attach failed, meaning we don't enter into RunBlocking state.

Questions:

  • why didn't the attach retry?
    • IsConcurrentAccessError method was not working correctly
  • what was the conflicting operations that caused the concurrent access?
    • The network unbind triggered by the power off event for the prior iteration - this is a perfectly acceptable occurrence so why isn't the retry handling it - will answer in question above.

@hickeng hickeng force-pushed the 7410-minimal branch 4 times, most recently from d5c63bd to f6c176f Compare June 27, 2018 18:03
hickeng added a commit to hickeng/vic that referenced this pull request Jun 27, 2018
Makes use of extraconfig update for suppressing decode of fields into
existing structures to prevent overwriting of in-memory state updates
during a reload. This is necessary because there's no test-and-set
guarantees between API and guest side updates with guestinfo.
namespacedb would address this at an infrastructure level.

Adds mapping of InvalidState that we can receive when multiple guest
operations collide to a concurrent modification so that a retry can be
attempted by the caller. Handling of guest operations does not trigger
TaskInProgress or ConcurrentModification as we'd expected from the
infrastructure.

Updates the unit tests to use the structure without the suppression of
decoding - the differentiation wasn't important previously but now the
structure handling is asymmetric depending on whether it's tether or API
so the correct pacakge reference is now important.

(cherry picked from commit 5271ea7)
hickeng added a commit to hickeng/vic that referenced this pull request Jun 27, 2018
There are outstanding issues to address with concurrent exec. This work is
palliative rather than an actual fix.

Removes checking for "started" in the status string - we reliably see this
field not propagating to the property collector despite being logged as
set in the tether. This _only_ applies to execs at this time as that is
the only path calling task.State (via InspectTask).

Adds locking around dispatch of execs, with a timeout, to serialize that
initial dispatch path against a single container. If the timeout expires
it reverts to current behaviour and relies on concurrent modification and
retry.

(cherry picked from commit f6c176f)
hickeng added a commit to hickeng/vic that referenced this pull request Jun 27, 2018
Makes use of extraconfig update for suppressing decode of fields into
existing structures to prevent overwriting of in-memory state updates
during a reload. This is necessary because there's no test-and-set
guarantees between API and guest side updates with guestinfo.
namespacedb would address this at an infrastructure level.

Adds mapping of InvalidState that we can receive when multiple guest
operations collide to a concurrent modification so that a retry can be
attempted by the caller. Handling of guest operations does not trigger
TaskInProgress or ConcurrentModification as we'd expected from the
infrastructure.

Updates the unit tests to use the structure without the suppression of
decoding - the differentiation wasn't important previously but now the
structure handling is asymmetric depending on whether it's tether or API
so the correct pacakge reference is now important.
hickeng added a commit to hickeng/vic that referenced this pull request Jun 27, 2018
There are outstanding issues to address with concurrent exec. This work is
palliative rather than an actual fix.

Removes checking for "started" in the status string - we reliably see this
field not propagating to the property collector despite being logged as
set in the tether. This _only_ applies to execs at this time as that is
the only path calling task.State (via InspectTask).

Adds locking around dispatch of execs, with a timeout, to serialize that
initial dispatch path against a single container. If the timeout expires
it reverts to current behaviour and relies on concurrent modification and
retry.
hickeng added a commit to hickeng/vic that referenced this pull request Jun 27, 2018
…e#8101)

Makes use of extraconfig update for suppressing decode of fields into
existing structures to prevent overwriting of in-memory state updates
during a reload. This is necessary because there's no test-and-set
guarantees between API and guest side updates with guestinfo.
namespacedb would address this at an infrastructure level.

Adds mapping of InvalidState that we can receive when multiple guest
operations collide to a concurrent modification so that a retry can be
attempted by the caller. Handling of guest operations does not trigger
TaskInProgress or ConcurrentModification as we'd expected from the
infrastructure.

Updates the unit tests to use the structure without the suppression of
decoding - the differentiation wasn't important previously but now the
structure handling is asymmetric depending on whether it's tether or API
so the correct pacakge reference is now important.

(cherry picked from commit 014952b)
hickeng added a commit to hickeng/vic that referenced this pull request Jun 27, 2018
There are outstanding issues to address with concurrent exec. This work is
palliative rather than an actual fix.

Removes checking for "started" in the status string - we reliably see this
field not propagating to the property collector despite being logged as
set in the tether. This _only_ applies to execs at this time as that is
the only path calling task.State (via InspectTask).

Adds locking around dispatch of execs, with a timeout, to serialize that
initial dispatch path against a single container. If the timeout expires
it reverts to current behaviour and relies on concurrent modification and
retry.

(cherry picked from commit c99f021)
hickeng added 2 commits June 27, 2018 17:35
Makes use of extraconfig update for suppressing decode of fields into
existing structures to prevent overwriting of in-memory state updates
during a reload. This is necessary because there's no test-and-set
guarantees between API and guest side updates with guestinfo.
namespacedb would address this at an infrastructure level.

Adds mapping of InvalidState that we can receive when multiple guest
operations collide to a concurrent modification so that a retry can be
attempted by the caller. Handling of guest operations does not trigger
TaskInProgress or ConcurrentModification as we'd expected from the
infrastructure.

Updates the unit tests to use the structure without the suppression of
decoding - the differentiation wasn't important previously but now the
structure handling is asymmetric depending on whether it's tether or API
so the correct pacakge reference is now important.
There are outstanding issues to address with concurrent exec. This work is
palliative rather than an actual fix.

Removes checking for "started" in the status string - we reliably see this
field not propagating to the property collector despite being logged as
set in the tether. This _only_ applies to execs at this time as that is
the only path calling task.State (via InspectTask).

Adds locking around dispatch of execs, with a timeout, to serialize that
initial dispatch path against a single container. If the timeout expires
it reverts to current behaviour and relies on concurrent modification and
retry.
hickeng added a commit to hickeng/vic that referenced this pull request Jun 28, 2018
…e#8101)

Makes use of extraconfig update for suppressing decode of fields into
existing structures to prevent overwriting of in-memory state updates
during a reload. This is necessary because there's no test-and-set
guarantees between API and guest side updates with guestinfo.
namespacedb would address this at an infrastructure level.

Adds mapping of InvalidState that we can receive when multiple guest
operations collide to a concurrent modification so that a retry can be
attempted by the caller. Handling of guest operations does not trigger
TaskInProgress or ConcurrentModification as we'd expected from the
infrastructure.

Updates the unit tests to use the structure without the suppression of
decoding - the differentiation wasn't important previously but now the
structure handling is asymmetric depending on whether it's tether or API
so the correct pacakge reference is now important.

(cherry picked from commit f907974)
hickeng added a commit to hickeng/vic that referenced this pull request Jun 28, 2018
There are outstanding issues to address with concurrent exec. This work is
palliative rather than an actual fix.

Removes checking for "started" in the status string - we reliably see this
field not propagating to the property collector despite being logged as
set in the tether. This _only_ applies to execs at this time as that is
the only path calling task.State (via InspectTask).

Adds locking around dispatch of execs, with a timeout, to serialize that
initial dispatch path against a single container. If the timeout expires
it reverts to current behaviour and relies on concurrent modification and
retry.

(cherry picked from commit c99f021)
hickeng added a commit that referenced this pull request Jun 28, 2018
Makes use of extraconfig update for suppressing decode of fields into
existing structures to prevent overwriting of in-memory state updates
during a reload. This is necessary because there's no test-and-set
guarantees between API and guest side updates with guestinfo.
namespacedb would address this at an infrastructure level.

Adds mapping of InvalidState that we can receive when multiple guest
operations collide to a concurrent modification so that a retry can be
attempted by the caller. Handling of guest operations does not trigger
TaskInProgress or ConcurrentModification as we'd expected from the
infrastructure.

Updates the unit tests to use the structure without the suppression of
decoding - the differentiation wasn't important previously but now the
structure handling is asymmetric depending on whether it's tether or API
so the correct pacakge reference is now important.

(cherry picked from commit f907974)
hickeng added a commit that referenced this pull request Jun 28, 2018
There are outstanding issues to address with concurrent exec. This work is
palliative rather than an actual fix.

Removes checking for "started" in the status string - we reliably see this
field not propagating to the property collector despite being logged as
set in the tether. This _only_ applies to execs at this time as that is
the only path calling task.State (via InspectTask).

Adds locking around dispatch of execs, with a timeout, to serialize that
initial dispatch path against a single container. If the timeout expires
it reverts to current behaviour and relies on concurrent modification and
retry.

(cherry picked from commit c99f021)
@hickeng hickeng merged commit fddf519 into vmware:master Jun 28, 2018
hickeng added a commit that referenced this pull request Jun 28, 2018
Makes use of extraconfig update for suppressing decode of fields into
existing structures to prevent overwriting of in-memory state updates
during a reload. This is necessary because there's no test-and-set
guarantees between API and guest side updates with guestinfo.
namespacedb would address this at an infrastructure level.

Adds mapping of InvalidState that we can receive when multiple guest
operations collide to a concurrent modification so that a retry can be
attempted by the caller. Handling of guest operations does not trigger
TaskInProgress or ConcurrentModification as we'd expected from the
infrastructure.

Updates the unit tests to use the structure without the suppression of
decoding - the differentiation wasn't important previously but now the
structure handling is asymmetric depending on whether it's tether or API
so the correct pacakge reference is now important.
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.

4 participants