Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

PUT on /v2/apps has a PATCH semantic. #5157

Merged
merged 7 commits into from
Feb 10, 2017
Merged

PUT on /v2/apps has a PATCH semantic. #5157

merged 7 commits into from
Feb 10, 2017

Conversation

aquamatthias
Copy link
Contributor

@aquamatthias aquamatthias commented Feb 10, 2017

[EDIT] Add a query parameter, that allows for proper PUT semantics which will overwrite all values.

Add a command line parameter, that allows for proper PUT semantics which will overwrite all values.
@aquamatthias
Copy link
Contributor Author

cc @orlandohohmeier

Copy link
Contributor

@janisz janisz left a comment

Choose a reason for hiding this comment

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

Missing test when updateExisting is false.

@nLight
Copy link
Contributor

nLight commented Feb 10, 2017

We're happy with the name, thank you for addressing this!

@@ -90,6 +90,16 @@
Note: This operation will create a deployment. The operation finishes, if the deployment succeeds.
You can query the deployments endoint to see the status of the deployment.
is: [ secured, deployable ]
queryParameters:
updateExisting:
Copy link
Contributor

Choose a reason for hiding this comment

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

i'm confused by this parameter name. aren't we updating via PUT or PATCH? how does updateExisting imply "I'd like to partially update"?

suggestions: partialUpdate, patchUpdate, applyAsPatch

@@ -251,6 +261,16 @@
Note: This operation will create a deployment. The operation finishes, if the deployment succeeds.
You can query the deployments endoint to see the status of the deployment.
is: [ secured, deployable ]
queryParameters:
updateExisting:
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@jdef
Copy link
Contributor

jdef commented Feb 10, 2017

or else, perhaps invert the meaning parameter: call it replaceAll and default it to false?

@nLight
Copy link
Contributor

nLight commented Feb 10, 2017

We went ahead and created a tag in docker hub v1.4.0-RC6.5157 then I launched is as MoM and pointed my dcos-ui to it instead of the root Marathon. Then I added the param to the API request, I can see the UI sending it but Marathon still replies with the same error.

@aquamatthias
Copy link
Contributor Author

@nLight
That is a different problem: the problem arises, if the updated appdefinition defines an ipAdress, but no portDefinition.

  • AppDefinition.empty has a default port
  • AppDefinition (L92) has a require statement not allowing ipAddress/ports at the same time

@jdef can you have a look?

@jdef jdef added this to the Marathon 1.4 milestone Feb 10, 2017
@jdef jdef self-assigned this Feb 10, 2017
@jdef jdef added API labels Feb 10, 2017
| },
| "ipAddress": { "name": "dcos" }
|}""".stripMargin.getBytes("UTF-8")
val appUpdate = appsResource.canonicalAppUpdateFromJson(app.id, body, false)
Copy link
Contributor

Choose a reason for hiding this comment

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

should we also include a test case where partialUpdate=true to demonstrate that it will fail validation?

@jdef
Copy link
Contributor

jdef commented Feb 10, 2017

also discussed with @aquamatthias that we should add support for the PATCH method so that people can migrate their patch-semantic-dependent code to the PATCH API during the 1.4 release cycle so that when we roll out 1.5 we don't break people who are using PUT to get patch-like behavior.

(The plan for 1.5 should be to, at least, change the default of partialUpdate to false)

@@ -141,20 +143,66 @@ class AppsResource @Inject() (
}
}

/**
* Validate and normalize an array of application updates submitted via the REST API. Validation exceptions are not
Copy link
Contributor

Choose a reason for hiding this comment

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

copy/paste doc error

// some hackery here to pass initial JSON parsing.
val jsObj = Json.parse(body).as[JsObject] + ("id" -> Json.toJson(appId.toString))
// the version is thrown away in toUpdate so just pass `zero` for now
normalizedApp(validateOrThrow(jsObj.as[AppDefinition].copy(id = appId).withCanonizedIds()), Timestamp.zero).toUpdate
Copy link
Contributor

Choose a reason for hiding this comment

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

we don't actually need to copy the id in this step since we just did it in the previous one

@jdef
Copy link
Contributor

jdef commented Feb 10, 2017

overall i'm not super happy w/ the efficiency when partialUpdate==false because we basically go from AppDefinition to AppUpdate back to AppDefinition again. but this approach minimizes the changes required for this PR and probably doesn't actually add "too much" overhead for app update operations. if performance concerns crop up in testing we can tackle a larger refactor then

@jdef
Copy link
Contributor

jdef commented Feb 10, 2017

GroupDeployIntegrationTest seems to flake out when integration testing on CI but runs just fine locally

[EDIT] I'm guessing it's the 3s timeout for "update a group with application with health checks"

@jdef jdef merged commit 8df2a5d into releases/1.4 Feb 10, 2017
@jdef jdef removed the in progress label Feb 10, 2017
@jdef jdef deleted the mv/put_like_put branch February 10, 2017 21:59
@janisz janisz mentioned this pull request Feb 25, 2017
@marcomonaco marcomonaco added the pr label Mar 6, 2017
unterstein added a commit that referenced this pull request Mar 15, 2017
Summary:
1.) PUT on /v2/apps has a PATCH semantic. (#5157)
See 8df2a5d

* document that, by default, PUT on /v2/apps has a PATCH semantic: only the fields specified in the app update are applied to the existing app definition.
* add a query parameter, `partialUpdate`, that allows for proper PUT semantics for an app. `false` means "completely replace the existing app with the new one that I'm **fully specifying** here"

2.) Add support for PATCH updates to apps in 1.4 (#5183)
See 1ba8ea7

* added support to PATCH apps

also-by: unterstein

3.) Fixes #5211 by defining the jersey annotated methods explicitly. (#5217)
See e1b7952

* With the newly introduced `PATCH` semantic, we introduced a misleading method declaration which is not resolvable for jersey. Therefore this logic was restructured and methods are defined explicitly.

Test Plan:
sbt test
sbt integration:test

Reviewers: meichstedt, aquamatthias, jasongilanfarr, jenkins, jdef

Reviewed By: meichstedt, aquamatthias, jenkins, jdef

Subscribers: jdef, marathon-team

Differential Revision: https://phabricator.mesosphere.com/D552
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants