-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
feat(app): limit the docker API version supported by the frontend #11855
feat(app): limit the docker API version supported by the frontend #11855
Conversation
b2afc2e
to
ad883ce
Compare
ad883ce
to
e11f9f3
Compare
Technical note about fix(app): ensure axios functions are running inside AngularJS digest cycle Initial issues
To avoid creating noise by adding the environmentId to all AngularJS services functions signatures (thus changing all the places where the functions are called), and support the fact that axios/react services don't have a reference to
Illustration // the original AngularJS signature doesn't accept an environmentId
// we need to maintain this behaviour
service.volume = function (id) {
var deferred = $q.defer(); // $q automatically triggers a UI sync when it resolves/rejects
// Volume is the $resource definition leveraging EndpointProvider
// to generate the request URL /api/endpoints/{environmentId}/volumes/{id}
Volume.get({ id: id })
.$promise.then(function success(data) {
var volume = new VolumeViewModel(data);
deferred.resolve(volume);
})
.catch(function error(err) {
deferred.reject({ msg: 'Unable to retrieve volume details', err: err });
});
return deferred.promise;
};
---
// usage
VolumeService.volume(volumeId).then(...) Now const { useAxios, injectEnvironmentId } = AngularToReact;
return {
volume: useAxios(injectEnvironmentId(volumeAngularJS)),
};
/**
* this function is async (1) and receives an environmentId as first parameter (2)
* (1): the async nature of the function is handled by useAxios to keep AngularJS aware of its execution
* (2): the environmentId param is injected by injectEnvironmentId
*
* @param {EnvironmentId} environmentId - injected by AngularToReact
* @param {string} id - provided by the caller
*/
async function volumeAngularJS(environmentId, id) {
// getVolume is an Axios function and needs an environmentId
const data = await getVolume(environmentId, id);
return new VolumeViewModel(data);
}
---
// axios implementation of the previous $resource() definition
export async function getVolume(
environmentId: EnvironmentId,
name: Volume['Name']
) {
try {
const { data } = await axios.get(
buildDockerProxyUrl(environmentId, 'volumes', name)
);
return data;
} catch (e) {
throw parseAxiosError(e, 'Unable to retrieve volume details');
}
}
---
// usage didn't change on the caller's side
VolumeService.volume(volumeId).then(...) |
bb8af42
to
a382525
Compare
a382525
to
59536ad
Compare
Close EE-6918
Introduced auto versioned calls to the docker API proxy.
To avoid payload changes side effects, our defined MAX API VERSION should be the lowest version we decide to officially support.
Right now the latest Docker version is Docker 26 (API v1.45) and we state to officially support latest minus 2 versions (Docker 24 = API v1.43).
As our frontend code is currently using v1.41 types, the MAX API VERSION is currently v1.41 (Docker 20).
Example
/endpoints/{id}/docker/volumes
/endpoints/{id}/docker/v1.41/volumes
(guarantee to return the proper payload, because we ask for a specific version)/endpoints/{id}/docker/volumes
with no guarantee to work! (call will return with 1.40 format which is below our minimum supported version)To reduce the overhead of proxying all requests in Axios (used by React) and AngularJS $resources / $http, all AngularJS services emitting requests to the docker API proxy have been migrated to Axios.