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

many: delay classic registration until first store interaction #4873

Closed
wants to merge 7 commits into from

Conversation

pedronis
Copy link
Collaborator

@pedronis pedronis commented Mar 19, 2018

XXX UPDATE:

  • this always triggers registration once we have a model and its gadget, if specified, is installed, but then pauses it after creating the device key on classic
  • the store code then is changed to always trigger/restart registration (for most operations) if there is no serial yet, indirectly via AuthContext and devicestate code, the latter code then does a best-effort of waiting for registration to occur before continuing
  • tests/main/classic-custom-device-reg needed adjusting, ideally it should be switched to use the
    fakestore as well (but it's a larger change because it doesn't support the session endpoints yet and
    could be done in a follow up)

@pedronis pedronis added the Squash-merge Please squash this PR when merging. label Mar 20, 2018
@pedronis pedronis added this to the 2.33 milestone Mar 20, 2018
@codecov-io
Copy link

codecov-io commented Mar 21, 2018

Codecov Report

Merging #4873 into master will increase coverage by 0.02%.
The diff coverage is 86.84%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4873      +/-   ##
==========================================
+ Coverage   79.11%   79.13%   +0.02%     
==========================================
  Files         478      478              
  Lines       35491    35606     +115     
==========================================
+ Hits        28079    28178      +99     
- Misses       5192     5199       +7     
- Partials     2220     2229       +9
Impacted Files Coverage Δ
overlord/auth/auth.go 75.2% <100%> (+0.71%) ⬆️
overlord/devicestate/handlers.go 72.66% <100%> (+0.19%) ⬆️
overlord/snapstate/autorefresh.go 82.9% <71.42%> (-0.53%) ⬇️
overlord/snapstate/refreshhints.go 79.16% <71.42%> (-1.79%) ⬇️
overlord/snapstate/catalogrefresh.go 68.62% <72.72%> (+1.96%) ⬆️
overlord/devicestate/devicestate.go 79.01% <85.71%> (+1.07%) ⬆️
store/store.go 81.34% <88.23%> (-0.1%) ⬇️
overlord/devicestate/devicemgr.go 79.12% <90.41%> (+2.99%) ⬆️
overlord/hookstate/hookmgr.go 72% <0%> (-1.15%) ⬇️
overlord/ifacestate/handlers.go 63.25% <0%> (+0.46%) ⬆️

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 f9f097e...c66d35c. Read the comment docs.

@pedronis pedronis added the ⚠ Critical High-priority stuff (e.g. to fix master) label Mar 27, 2018
return nil
}

// waitForRegistrationTimeout is the timeout after which waitForRegistration will give up, about the same as network retries max timeout
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you wrap the comment?

// on classic the first time around we just do
// prepare-device + key gen and then pause the process
// until the first store interaction
full = err != state.ErrNoState
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick, but I find this easier to read when scanning though the code:

if err == state.ErrNoState {
    full = false
}

@pedronis pedronis added ⛔ Blocked and removed ⚠ Critical High-priority stuff (e.g. to fix master) labels Mar 28, 2018
@pedronis pedronis removed this from the 2.33 milestone Apr 24, 2018
@@ -105,6 +130,19 @@ func (m *DeviceManager) markRegistered() {
close(m.reg)
}

func (m *DeviceManager) markRegistrationFirstAttempt() {
if m.registrationFirstAttempted {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this be covered by a mutex or use atomic compare and swap?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it's always called with the state lock taken, otoh this PR is super likely to get closed soon

@pedronis
Copy link
Collaborator Author

closing this as discussed with Bret

@pedronis pedronis closed this May 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⛔ Blocked Squash-merge Please squash this PR when merging.
Projects
None yet
3 participants