MXS-2954: Use correct object for PATCH

The destination object instead of the source object was used. This caused
the PATCH to be a no-op.

Due to how the REST API behaves when it received parameters, the set of
synced parameters must be filtered. The REST API should be more lenient
towards alterations to parameters that don't actually change the value.
This commit is contained in:
Markus Mäkelä
2020-04-06 11:24:00 +03:00
parent 071501ea1f
commit 1ed6304281
2 changed files with 30 additions and 1 deletions

View File

@ -273,9 +273,29 @@ exports.builder = function(yargs) {
promises.push(doAsyncRequest(host, i + '/' + j.id, null, {method: 'PATCH', body: {data: j}}))
})
})
if (src['maxscale']) {
// TODO: Don't filter the altered parameters on the client side. The REST
// API should ignore no-op changes.
src['maxscale'].data.attributes.parameters = _.pick(
src['maxscale'].data.attributes.parameters,
['auth_connect_timeout',
'auth_read_timeout',
'auth_write_timeout',
'admin_auth',
'admin_log_auth_failures',
'passive',
'ms_timestamp',
'skip_permission_checks',
'query_retries',
'query_retry_timeout',
'retain_last_statements',
'dump_last_statements'])
}
// Do the same for individual resources
endpoints.forEach(function(i) {
promises.push(doAsyncRequest(host, i, null, {method: 'PATCH', body: dest[i]}))
promises.push(doAsyncRequest(host, i, null, {method: 'PATCH', body: src[i]}))
})
return Promise.all(promises)
})