In this document:
This document compiles all data related to the upgrade processes in APS applications. In the following table are a select few cases when an APS application needs an upgrade.
Root Cause |
Affected APS Components |
Example |
---|---|---|
New service added |
- New service declared in metadata
- New APS type
- New relations with existing APS types
- Provisioning logic of the new service
- New UI views and existing UI views
|
The subscription must include references to available configurations (offers). |
Business related resources must be able to get access to each other’s properties |
- New relationship between APS types
- Permissions in APS types
- UI view
|
On the view presenting VPSes, the server owner must be displayed.
|
A new custom operation added to a service |
- Custom operation in the APS type
- Provisioning logic of the service
- UI view that enables the feature to users
|
The VPS owner is allowed to start and stop the VPS. |
Note
An APS application is uniquely identified by its ID as specified in package metadata. The upgrade process assumes that the same application ID in a current APS package is used as in APS packages that are updates of the current package.
Warning
APS does not support upgrade of packages from APS 1 to APS 2.
In APS packages, versions are assigned to the following components:
Component |
Example |
Description |
Influence on upgrade |
---|---|---|---|
<application… |
Defines the package format |
Note The application upgrade process described here is valid for APS 2. |
|
<version>1.0</version> <release>1</release> VPS_Cloud-1.0-1.app.zip
|
- Application version
- Package release
- Package version combines both above
|
- Typically, the same
version as the integrated cloud application.-
release distinguishes packages with the same version .- The package version must be updated in a new package before importing it to the platform.
|
|
“id”: |
Version of APS resources |
Upgrades all APS resources based on the updated APS type. |
The APS version is specified in the root <application> element inside the APP-META.xml
file, for example:
<application xmlns="http://aps-standard.org/ns/2" version="2.0">
This document is valid for APS version 2.x. Refer to Metadata Descriptor (APP-META.xml) for more details.
The APS version is also specified in each APS type definition by means of the apsVersion property, for example:
{
"apsVersion": "2.0",
"name": "vps",
...
}
The package version is specified by two elements in package metadata:
The <version>
element normally must correspond to the version of the integrated cloud application.
The <release>
element indicates a package release and changes each time there is a need to update the package
without changing the application version.
The package version contains both of the above elements in the form of {version}-{release}. With the following sample metadata
<application>
...
<version>2.0</version>
<release>6</release>
...
</application>
the package release would be 2.0-6.
Note
For the normal upgrade process, the new package version must be higher than any other package versions with the same application ID that are already stored in the APS package repository.
Each *.schema
file in an APS package defines an APS type. The APS type ID contains the APS type version.
In the following example, the APS type for VPSes is declared.
{
"apsVersion": "2.0",
"name": "vps",
"id": "http://aps-standard.org/samples/vpscloud/vps/1.0",
"implements": [
"http://aps-standard.org/types/core/resource/1.0"
],...
}
APS type ID http://aps-standard.org/samples/vpscloud/vps/1.0
contains its version - 1.0
.
If in a new package the APS type version is increased and the application instance is updated to the new package,
then the APS controller will make all APS resources based on this APS type bound to its new version.
Among other APS types, each APS package must contain APS type definition for APS resources representing APS application instances. This APS type implements the core Application APS type as in the following example:
{
"apsVersion": "2.0",
"name": "cloud",
"id": "http://aps-standard.org/samples/vpscloud/1.0",
"implements": [
"http://aps-standard.org/types/core/application/1.0"
],...
}
In the above definition, the APS type implements the
core Application
APS type, whose ID is http://aps-standard.org/types/core/application/1.0
.
Thus, it declares itself as the APS type that must be used for
provisioning an application instance through the root application service declared on an APS connector.
This service must accept the upgrade call during the upgrade process. In the above example, the APS type ID is
http://aps-standard.org/samples/vpscloud/1.0
, and the version is 1.0
.
Each application instance in the platform is upgraded independently, meaning different application instances can be based on different package versions. Therefore, there is no restriction on having different versions of an APS type defined by different package versions on the same platform.
To specify if a package can upgrade other packages of the same application, the <upgrade> meta element must contain an RQL statement identifying upgradable packages as explained later in this document.
The version element in an APS type has the following structure: major[.minor]. Depending on the upgraded part, we call the upgrade correspondingly: major or minor.
Minor upgrades are backward compatible .
It means, after an upgrade, there is no need to change
the APS type ID in existing requests for APS resources. For example, if an APS type is upgraded from
http://www.odin.com/mailbox/1.0
to http://www.odin.com/mailbox/1.4
,
the APS controller returns the upgraded APS resource representation even if it receives
the http://www.odin.com/mailbox/1.0
APS type in the request. The returned APS resource is bound
to the new APS type version.
However the reverse, forward compatibility , is not supported.
For example, when APS type http://www.odin.com/mailbox/1.5
is requested,
the APS controller will not return APS resources bound to http://www.odin.com/mailbox/1.4
.
Different major versions are not compatible, that is
http://www.odin.com/mailbox/1.0
and http://www.odin.com/mailbox/2.0
are two different incompatible APS types.
The following examples illustrate the cases when it is better to use minor upgrade and when a major upgrade is necessary.
Initially there is a vps
APS type containing a number of properties. Its version is 1.0.
{
"apsVersion": "2.0",
"name": "vps",
"id": "http://aps-standard.org/samples/vpscloud/vps/1.0",
...
"properties": {
"name": {
"type": "string",
},
...
}
}
The developer decides to add the optional property “description”. Since the property is not required, the APS resources will be backward compatible after the APS type upgrade. That is why, the developer does a minor upgrade to version 1.4, as follows.
{
"apsVersion": "2.0",
"name": "vps",
"id": "http://aps-standard.org/samples/vpsclouds/vps/1.4",
...
"properties": {
"name": {
"type": "string",
},
"description": {
"type": "string",
},
...
}
}
Note
Starting with OA 8.2.0 HOTFIX 134609 PLATFORM v20, we recommend not changing the version when an APS type is updated in the backward-compatible manner as described in this example. This avoids upgrading all existing APS resources based on the updated APS type. If you follow this recommendation, the previous code must be rewritten using the current version of the APS type:
{
"apsVersion": "2.0",
"name": "vps",
"id": "http://aps-standard.org/samples/vpsclouds/vps/1.0",
...
"properties": {
"name": {
"type": "string",
},
"description": {
"type": "string",
},
...
}
}
With such update, the existing APS resources will not have the new property description
until you
add it by a PUT request.
Following multiple requests from providers, the developer decides to make the “description” a required property. Evidently, the VPSes created earlier will not be compatible with the new APS type version since they may do not have a description. That is why, the developer does a major upgrade, for example, to version 2.0, as follows:
{
"apsVersion": "2.0",
"name": "vps",
"id": "http://aps-standard.org/samples/vpsclouds/vps/2.0",
...
"properties": {
"name": {
"type": "string",
},
"description": {
"type": "string",
"required": true
},
...
}
}
In an APS type, there are three kinds of components that can be upgraded. The following upgrades of them are considered as minor.
Adding weak (non-required) relations
Adding optional (non-required) input parameters
Adding optional (non-required) properties
Changing attributes as specified in the table below:
Property attribute |
Minor upgrade |
---|---|
CANNOT be changed. |
|
CANNOT be changed. |
|
Change from false to true, only if the |
|
Change from true to false |
|
Change from true to false |
|
Change from true to false, only if |
|
Can be changed |
|
Can be changed, but it’s up to the developer to make sure that backwards compatibility of clients that may rely on the format will be kept, for example, change from ‘ip-address’ to ‘ipv4’ is safe, but not vice versa |
|
Can be changed, but it’s up to developer to make sure that backwards compatibility of clients that may rely on the format will be kept |
|
Can be changed |
|
Can be changed |
|
If decreased |
|
If increased |
|
If decreased |
|
If increased |
|
Change from true to false |
|
Can be changed |
|
Can be changed |
To upgrade an APS application, it is necessary to update the APS package and then upgrade the application on the hosting platform in accordance with the workflow.
Generally, the procedure of updating a package resembles the package development steps, but it requires developers to do only those steps that make necessary updates. The following diagram presents candidates for update along with corresponding files and metadata.
Correspondingly, the sequence of recommended steps looks as follows.
Draw the updated resource diagram, reflecting clearly major changes:
Some APS types and respective services are added or deleted
Relations are renamed, added, removed, or updated
Update APS types (types) to change the following:
Change the implements
section
Add or delete properties
Update attributes of properties
Declare new custom operations or remove some of custom operations
Update arguments of custom operations
Update provisioning logic of APS application endpoint:
Create or update classes implementing services declared in metadata
Create or update methods implementing operations declared in APS types
Modify the upgrade()
method in the application root service
Add or update navigation tree declaration in metadata
Update UI scripts
Update localization and text translation:
Add or update localization files
Update declaration of UI navigation
Add or remove declaration of some services
Warning
It is not possible to change the service ID declared in metadata, since it would look as if you removed a service and added a new one.
Increase package version
Specify the range of old packages that this package can upgrade
It is necessary to draw a new resource diagram to clearly reflect the following updates:
Adding or removing APS types
Adding or removing links
Changing link properties that make a link weak or strong, collection or singular
The example below indicates the following updates:
A new APS type named offer
appears.
The new APS type will have two relations, cloud
and vpses
, with existing APS types.
When updating the application, it is necessary to add new links to corresponding
provisioned APS resources. It concerns cloud
and vps
APS resources.
An APS type can be updated in the following ways, each leading to declaration of a new APS type or a new APS type version as well as to updates in the provisioning logic on the APS application endpoint:
Adding or removing APS types
Changing the implements section (adding or removing of an implemented APS type or changing the version of an implemented APS type)
Adding or removing properties and operations
Updating properties
Updating operations
Note
1. When updating an APS type, the APS controller will bind the corresponding APS resources of the updated application instance to the new APS type version.
2. Each APS type is bound to its own application service. Thus, its update might require update of the service declaration in metadata as well as update of the service on the APS application endpoint.
Provisioning logic can be updated or fixed by updating provisioning scripts or other APS types of executables inside the APS package. Respective updates must be performed on the APS application endpoint.
Warning
APS controller refuses an update that requires removing a service if there are APS resources provisioned through it.
Updates described earlier may require update of metadata. The following list contains specifics of metadata updates.
Package version should be increased. If the version of the packaged application was increased, then the <version> element in metadata should be increased accordingly, and it makes sense to reset the <release> element. Otherwise, only the <release> element should be increased.
In the changelog, a new record should be added. It must reflect the changes in the package that help service providers make decision on application update.
Variables specified in navigation trees require update if the versions of APS types they are referring were updated.
Changes in application services, such as addition, removal, and renaming, require respective updates in metadata.
To specify old packages that can be updated by this new package, the <upgrade> elements should be modified accordingly as described in the next section.
The <upgrade> section declares a range of previous package versions that the current package can upgrade.
Its match
attribute defines this range by means of the version
and release
parameters.
It is possible to specify an exact package version or
a range of packages that can be updated by the new package. Therefore,
the match
attribute contains an RQL expression that will be evaluated against metadata of the
installed packages with the same application ID.
Note
If the update specification is absent, the APS controller assumes that updates are not supported by the package at all.
For exact version comparison, the APS controller compares package versions as specified in the Package Version section of the specification with help of the =lt=, =gt=, =ge=, =gt=, =eq= and =ne= RQL operators.
In metadata, update statements define packages that can be updated as illustrated in the following examples.
Match exact package version. In the following example, the update is applicable for version 6.0-2.
<application>
...
<upgrade match="version =eq= 6.0, release =eq= 2"/>
..
</application>
Range of package versions. In the following example, the update is applicable for all versions starting from 1.0-0 and up to 2.0-7.
<application>
...
<upgrade match="(version =ge= 1.0, version =lt= 2.0) or (version =eq= 2.0, release =le= 7)" />
...
</application>
The <upgrade> section allows changing relation names in APS types. For this purpose, the section includes <service> sections, one per each service (APS type). A <service> section contains the <rename> section with <relation> rename elements.
The following example illustrates how to rename two relations from their old names to the new names:
<upgrade match="version=ge=1.0">
<service id="offers" spec="version=eq=2.2">
<rename>
<relation new="servers" old="vpses"/>
<relation new="application" old="root"/>
</rename>
</service>
</upgrade>
Warning
In the above definition, it is not allowed to use concurrently the same name as new
in one <relation> element
and as old
in another.
The above example also illustrates how to specify the APS version that the system must support to apply the requested renaming.
Let us consider the following two major cases.
In package version 1.0, the vps APS type was linked to the user APS type through the myuser relation. In the new package version 1.1, the relation is renamed to user.
The new package must go through the following changes:
In the vps schema definition, rename the myuser relation to user.
Update the vps APS type version to 1.1.
In metadata definition, specify the relation renaming: <relation new=”user” old=”myuser”/>
Update the package version to 1.1.
In package version 1.0, the vps APS type was linked to the user APS type through the myuser link. In the next package version 1.1, the vps APS type implements the standard APS type user/service that has the user relation definition. It means, the vps APS type inherites the user link and there is no need in the old myuser relation.
The new package must go through the following changes:
Make the vps APS type implement the /user/service APS type.
In the vps schema definition, remove the myuser relation.
Update the vps APS type version to 1.1.
In metadata definition, specify the relation renaming: <relation new=”user” old=”myuser”/>
Update the package version to 1.1.
The following updates can be applied to custom UI.
Updating Navigation tree in the <presentation> section of metadata.
Adding, modifying, or deleting UI scripts in the ui
folder of the package.
Update of text translation to different languages is the same as described in the Internationalization and Localization section of the APS specification.
If APS application is to be updated, this update can be automated by modifying the upgrade method of the root appliation service. The method must await for its call from the APS controller.
To build the updated package, use the APS build utility available in command line. Pay attention to the package version that must be higher than the package versions to be updated.
Once an updated package is imported to the APS controller, an administrator of the hosting platform can initiate upgrade of an APS application instance to the new version of the package.
Once the new package is imported to the hosting platform, the provider staff can start upgrade of a selected application instance. Preliminary, they ensure:
There are no failed tasks in the hosting platform related to the application being upgraded.
The application provisioning logic, for example, PHP scripts, is updated on the endpoint host.
APS controller processes the upgrade internally and then calls the upgrade
method of the application root service (implementing the core application APS type) on the application endpoint.
The upgrade
method is executed on the application side to bring the application APS resources in compliance
with the updated package. Once the application responded, the APS controller completes post-upgrade
operations.
The aps.status
property of the application APS resource indicates if the upgrade process is started as
illustrated in the diagram:
The upgrade process for a selected APS application instance is initiated from the control panel of the hosting platform. This makes the APS controller go through the following steps.
Switch the application APS resource status to upgrading.
Updates aps.package.id
in the application instance, thus binding the application instance
to the new package.
Call the upgrade method of the application APS resource and wait for the response. Application specific transfer from the current version to the new one must be done by the application instance itself. Potentially, this operation can be pretty long. The application instance can communicate with the APS controller to get, register, or change some application APS resources. This is the only period, when the application instance has access to both versions of APS types, the current one and the new one. In all its operations, the application should use the APS types updated by the new package, however the result depends on the operation:
When getting (GET operation) an APS resource from the controller, the APS resource bound to the current APS type is returned.
When creating (POST) or updating (PUT) an APS resource, the APS resource will be bound or re-bound to the new APS type.
Warning
1. It is not allowed to call a custom operation declared in an APS type whose version is being changed.
If absolutely necessary, the application can schedule a separate post-upgrade task that will call the required
custom operation,
but the respective REST request must not use the same APS-Transaction-ID header
as in the initial upgrade
operation. The application can just omit the header in the request
to make the APS controller generate a new one.
2. In production, you must avoid having APS application instances bound to different package versions as explained in APS Application Instance Upgrade.
Once the application completes its upgrade, perform internal post-upgrade operations. The goal is to ensure correct transfer of all APS resources to the new package with new APS type definitions. The APS controller achieves it by a number of validation operations.
Verify if every required property is assigned a value. If there is a required property that is empty and no default value is specified in its APS type, complete the whole upgrade process with error message “Required property ‘x’ has no value”.
Ensure proper links between APS resources:
For each declared required relation, there is a link to an APS resource.
APS resources are linked with strong compliance with declaration of relations in APS types.
Unregister all APS resources of the services that are dropped in the new package.
Process major upgrades:
Delete properties whose APS type must change, for example, CPU property was a number before upgrade, but must be an array of numbers after upgrade.
Delete links based on relations that are missed in the new package.
Process minor upgrades:
Assign default values to upgraded or new properties that are required but not assigned a value.
Change status of the application APS resource to ready.
An application developer may need to prepare the application to the upgrade process, for example, by updating the
upgrade
method on the endpoint host and adding some auxiliary files. In such a case,
copy the updated application provisioning scripts to the application endpoint folder in accordance with
the second step in the update workflow.
The upgrade()
method of the application APS resource defines the update activity on the
application side. This method is executed on the new, just upgraded, version of the application
installed on the endpoint host.
In fact it is the first call on the new code.
Note
POST request must contain APS resource representation with old version in the body on input (from controller to application) and new version on output (from application to controller).
If it is necessary to assign value to a new property, which is not defined in the old version of the APS type, the application must explicitly assign the APS resources to the new version of the APS type. This allows operating the new property.
Sample request:
POST /wordpress/80a4b75e-58a7-40e4-a148-dff560e5fa4a/upgrade
{
"aps": {
"type": "http://www.odin.com/web/wordpress/2.0",
"id": "80a4b75e-58a7-40e4-a148-dff560e5fa4a",
"package": {
"id": "b6d35786-8a3b-4931-8122-342aa2130320",
"href": "/aps/2/packages/b6d35786-8a3b-4931-8122-342aa2130320"
}
},
"admin_name": "admin",
"admin_email": "admin@example.com",
"title": [
"The test blog title1",
"The test blog title2"],
...
}
Response:
HTTP/1.1 200 OK
Note
The application gets from the APS controller APS resources based on the old version of APS types.
If it is necessary to assign value to a new property, which is not defined in the old version of the APS type, the application must explicitly reassign the APS resources to the new version of the APS type. This allows operating the new property.
When designing the upgrade
method, the packager can define the following actions.
Update properties of all APS resources whose current properties do not match the new APS type. For this purpose, use:
PUT /aps/2/application/{service-id}/{resource-id} to update APS resource properties
POST /aps/2/application/{service-id} to register a new APS resource
Update new properties of the application instance (core application APS resource) assuming these properties are not defined in the old version of the application. When using PHP runtime, redefine these properties along with the APS type version as in the following example:
public function upgrade() {
...
$this->newProp = "some value";
$this->aps->type = "http://mycompany.com/myapp/cloud/2.0";
...
}
Since versions 2.0-383, 2.1-302, and 2.2-115, PHP runtime updates the APS type automatically, before sending the result to the APS controller. So, you only have to change properties but not the APS type:
public function upgrade() {
...
$this->newProp = "some value";
...
}
Update properties of APS resources that did not exist in the old APS types. It is possible only along with updating the APS resources to the new APS type. When using PHP runtime, it looks as in the following example that defines the new parameter1 property:
public function upgrade() {
...
$apsc = \APS\Request::getController();
/* Here APS resources are still based on the old version */
$resources = $apsc->getResources("implementing(http://mycompany.example.com/myapp/srv-1/1.0)");
foreach ($resources as $resource) {
/* We need to explicitly switch the APS resource to the new APS type */
$resource->aps->type = "http://mycompany.example.com/myapp/srv-1/2.0";
/* Define the property as needed */
$resource->parameter1 = "some value";
/* Request the APS controller to apply both changes */
$apsc->updateResource($resource);
}
...
}
Since versions 2.0-383, 2.1-302, and 2.2-115, PHP runtime provides the getTypeByServiceId
method to get the APS type version the APS resource is currently bound to, so you don’t have to specify the APS type explicitly.
Also, PHP Runtime changes APS type version automatically in updateResource method, if it is called inside the upgrade
method.
So, the example can be changed to the following:
public function upgrade() {
...
$apsc = \APS\Request::getController();
/* Here APS resources are still based on the old version */
$resources = $apsc->getResources("implementing(".$this->getTypeByServiceId("vpses").")");
foreach ($resources as $resource) {
/* Define the property as needed */
$resource->parameter1 = "some value";
/* Request the APS controller to apply changes */
$apsc->updateResource($resource);
}
...
}
Refer to upgrade with PHP runtime article.
Link and unlink APS resources to match the new APS types. Therefore, use:
POST /aps/2/resources/{resource-id}/{relation} to link or re-link a resource {resource-id}
DELETE /aps/2/resources/{resource1-id}/{relation}/{resource2-id} to unlink resources