MCPcopy Index your code
hub / github.com/scality/cloudserver / saveConfigurationVersion

Function saveConfigurationVersion

lib/management/configuration.js:149–178  ·  view source on GitHub ↗

* Writes configuration version to the management database * * @param {object} cachedOverlay Latest stored configuration version * for freshness comparison purposes * @param {object} remoteOverlay New configuration version * @param {werelogs~Logger} log Request-scoped logger * @param {func

(cachedOverlay, remoteOverlay, log, cb)

Source from the content-addressed store, hash-verified

147 * @returns {undefined}
148 */
149function saveConfigurationVersion(cachedOverlay, remoteOverlay, log, cb) {
150 if (remoteOverlayIsNewer(cachedOverlay, remoteOverlay)) {
151 const objName = `configuration/overlay/${remoteOverlay.version}`;
152 metadata.putObjectMD(managementDatabaseName, objName, remoteOverlay,
153 {}, log, error => {
154 if (error) {
155 const exceptionError = reshapeExceptionError(error);
156 log.error('could not save configuration',
157 { error: exceptionError,
158 method: 'saveConfigurationVersion',
159 configurationVersion: remoteOverlay.version });
160 cb(exceptionError);
161 return;
162 }
163 metadata.putObjectMD(managementDatabaseName,
164 latestOverlayVersionKey, remoteOverlay.version, {}, log,
165 error => {
166 if (error) {
167 log.error('could not save configuration version', {
168 configurationVersion: remoteOverlay.version,
169 });
170 }
171 cb(error, remoteOverlay);
172 });
173 });
174 } else {
175 log.debug('no remote configuration to cache yet');
176 process.nextTick(cb, null, remoteOverlay);
177 }
178}
179
180/**
181 * Loads the latest cached configuration overlay from the management

Callers 3

onNewOverlayMethod · 0.85
applyAndSaveOverlayFunction · 0.85

Calls 3

remoteOverlayIsNewerFunction · 0.85
errorMethod · 0.80
debugMethod · 0.80

Tested by

no test coverage detected