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

Acquire resources on exporter #481

Merged
merged 11 commits into from Sep 9, 2019

Conversation

@jluebbe
Copy link
Member

commented Jul 31, 2019

Description
Currently, the coordinator doesn't track which resources are used by which places. Accordingly, it can't detect if two places configured for the same resource are acquired at the same time.
To solve this, we need to refactor the coordinator to track the acquired state of resources and let it detect conflicts.
Additionally, as the exporter now knows which resources are acquired, we can start any helper processes only when needed.

Checklist

  • Documentation for the feature
  • Tests for the feature
  • CHANGES.rst has been updated
  • PR has been tested

@jluebbe jluebbe added the enhancement label Jul 31, 2019

@jluebbe jluebbe requested a review from Emantor Jul 31, 2019

@jluebbe jluebbe self-assigned this Jul 31, 2019

@codecov

This comment has been minimized.

Copy link

commented Jul 31, 2019

Codecov Report

Merging #481 into master will decrease coverage by 0.6%.
The diff coverage is 15.6%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master    #481     +/-   ##
========================================
- Coverage    57.7%   57.1%   -0.7%     
========================================
  Files         121     121             
  Lines        7718    7840    +122     
========================================
+ Hits         4455    4478     +23     
- Misses       3263    3362     +99
Impacted Files Coverage Δ
labgrid/remote/coordinator.py 0% <0%> (ø) ⬆️
labgrid/remote/exporter.py 36% <10%> (-0.7%) ⬇️
labgrid/remote/common.py 77.5% <54.1%> (-6.2%) ⬇️
labgrid/remote/client.py 40.8% <81.2%> (+0.8%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ac78cc3...eae7e58. Read the comment docs.

@jluebbe jluebbe force-pushed the jluebbe:resource-locks branch from 7a652f0 to ef9ab14 Aug 2, 2019

labgrid/remote/client.py Outdated Show resolved Hide resolved
@jluebbe jluebbe referenced this pull request Aug 2, 2019
5 of 7 tasks complete
jluebbe added 11 commits Jul 29, 2019
remote/coordinator: make resource object persistent
Prevously, we would create new ResourceEntry objects even for updates of
existing resources. To keep coordinator-specific information for
individual resources (such as whether they are acquired for a place),
the natural way is to keep the objects around.

Introduce a ResourceImport class analogous to ResourceExport (used by
the exporter), which also stores the resource path as exposed to the
clients. This also avoids recreating the resource path every time.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
remote/coordinator: store resource objects instead of only the path f…
…or acquired_resources

This will allow us to release the resources when the place is released
without searching for each resource by path.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
remote/coordinator: acquire and release resources for acquired places
Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
remote: track resource acquired state in the exporter
This will allow the exporter to perform actions on acquire/release.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
remote/client: report conflicting resources if acquire fails
Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
remote/exporter: register methods early
As the coordinator may call us back to acquire newly registered
resources, we need to register the methods sooner. They only affect
individual resources, so this doesn't introduce race conditions.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
remote/coordinator: add locking via asyncio
To avoid problems resulting from concurrent modification calls from
clients, we need add coarse-grained locking at the exported entry-points
as a first step.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
remote/exporter: unset port parameter after stopping ser2net
Otherwise, a old and invalid port would still be shown after the ser2net
was stopped.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
remote/exporter: only start acquired resources
Also refactor the ResourceExport.poll() method to reduce complexity.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
remote/exporter: reduce update delay
To reduce the waiting time for USB devices like fastboot or serial in
test suites, call poll slightly more often.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>

@jluebbe jluebbe force-pushed the jluebbe:resource-locks branch from ef9ab14 to eae7e58 Aug 6, 2019

@jluebbe jluebbe marked this pull request as ready for review Aug 6, 2019

@jluebbe jluebbe requested a review from Emantor Aug 6, 2019

@Emantor Emantor added the breaking label Aug 16, 2019

@jluebbe jluebbe merged commit 9413f35 into labgrid-project:master Sep 9, 2019

2 of 4 checks passed

codecov/patch 15.6% of diff hit (target 57.7%)
Details
codecov/project 57.1% (-0.7%) compared to ac78cc3
Details
DCO DCO
Details
Travis CI - Pull Request Build Passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.