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

Update supervisor methods to handle MC supervisor changes #509

Merged
merged 5 commits into from
May 18, 2018

Conversation

pimterry
Copy link
Contributor

Also removed an existing deprecated method - if we're breaking things, might as well clean up a bit.

It's not supported in recent supervisors (>= 7.0.0)

Change-Type: major
They're not supported on devices with more than one container.

Change-Type: patch
Copy link
Contributor

@LucianBuzzo LucianBuzzo left a comment

Choose a reason for hiding this comment

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

Small nits but otherwise LGTM

@@ -895,6 +905,10 @@ getDeviceModel = (deps, opts) ->
# @function
# @memberof resin.models.device
#
# @deprecated
# This is not supported on multicontainer devices, and will
# be removed in future
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: removed in future --> removed in the future or removed in a future release

@@ -849,6 +855,10 @@ getDeviceModel = (deps, opts) ->
# @function
# @memberof resin.models.device
#
# @deprecated
# This is not supported on multicontainer devices, and will
# be removed in future
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: removed in future --> removed in the future or removed in a future release

device.supervisor_version,
MIN_SUPERVISOR_MC_API
).then ->
appId = device.belongs_to__application[0].id
Copy link
Member

Choose a reason for hiding this comment

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

I've started thinking about moving the getExpanded,... util methods to the SDK.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not going to do that right now, but in general I do think you're right. Really imo, those should live in Pine, as nice helper methods for anybody using the pine client.

Copy link
Member

Choose a reason for hiding this comment

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

Yea sure, never meant to have this in this PR :)

# @memberof resin.models.device
#
# @param {String|Number} uuidOrId - device uuid (string) or id (number)
# @param {Number} imageId - id of the image to start
Copy link
Member

Choose a reason for hiding this comment

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

After reading Start service on device, I would expect this to be the service ID 😕
Not-for-now: Wouldn't it be great if we could handle the service name as well?
I guess that getting the currently running image from the service name & deviceId isn't straightforward, but I imagine that the consumers might need to do this on their own.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not that easy. The main problem is that it's possible to have two images from the same service running on one device at the same time, if you're using handovers, or plausibly if something goes wrong somewhere or something. That's important because it's a risky case, and it's a time when you're mostly likely to want to manually kill one of your containers (because your handover has got stuck).

This model is also a slightly nicer in that it makes it hard to hit race conditions, where you try to stop one image while another is downloading and end up stopping a different one, because the supervisor is changing things at the same time you're talking to it. You can avoid that if you specify image ids, but if you can only use services then there's nothing you can do to be more specific.

All that said, I can see it's still not super convenient. What do you think about startService + startServiceByName? The 2nd would do what you're suggesting (and throw an error if it's ambiguous), but we'd also have the 1st option so you can disambiguate when it matters.

Copy link
Member

Choose a reason for hiding this comment

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

All that said, I can see it's still not super convenient. What do you think about startService + startServiceByName? The 2nd would do what you're suggesting (and throw an error if it's ambiguous), but we'd also have the 1st option so you can disambiguate when it matters.

Sounds great 👍 . I also don't think that this need to block this PR. We could do it in a separate minor release.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created an issue for later: #512

@@ -971,6 +985,159 @@ getDeviceModel = (deps, opts) ->
.catch(notFoundResponse, treatAsMissingDevice(uuidOrId))
.asCallback(callback)

###*
# @summary Start service on device
Copy link
Member

Choose a reason for hiding this comment

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

NIT: How about Start a service on a device?

.asCallback(callback)

###*
# @summary Stop service on device
Copy link
Member

Choose a reason for hiding this comment

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

NIT: How about Stop a service on a device?

.asCallback(callback)

###*
# @summary Restart service on device
Copy link
Member

Choose a reason for hiding this comment

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

NIT: How about Restart a service on a device?

@pimterry
Copy link
Contributor Author

One question left to think about image ids vs service names, but I've pushed changes to fix all the other comments.

@ghost
Copy link

ghost commented May 17, 2018

@pimterry, status checks have failed for this PR. Please make appropriate changes and recommit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants