Re-load config after 'mc admin config reset' (#15771)

This commit is contained in:
Shireesh Anjal 2022-09-30 23:25:53 +05:30 committed by GitHub
parent c302d1cfc8
commit 45edd27ad7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -81,6 +81,7 @@ func (a adminAPIHandlers) DelConfigKVHandler(w http.ResponseWriter, r *http.Requ
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL) writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
return return
} }
if err = validateConfig(cfg, subSys); err != nil { if err = validateConfig(cfg, subSys); err != nil {
writeCustomErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAdminConfigBadJSON), err.Error(), r.URL) writeCustomErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrAdminConfigBadJSON), err.Error(), r.URL)
return return
@ -91,6 +92,12 @@ func (a adminAPIHandlers) DelConfigKVHandler(w http.ResponseWriter, r *http.Requ
return return
} }
// freshly retrieve the config so that default values are loaded for reset config
if cfg, err = getValidConfig(objectAPI); err != nil {
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
return
}
dynamic := config.SubSystemsDynamic.Contains(subSys) dynamic := config.SubSystemsDynamic.Contains(subSys)
if dynamic { if dynamic {
applyDynamic(ctx, objectAPI, cfg, subSys, r, w) applyDynamic(ctx, objectAPI, cfg, subSys, r, w)
@ -173,6 +180,7 @@ func (a adminAPIHandlers) SetConfigKVHandler(w http.ResponseWriter, r *http.Requ
if dynamic { if dynamic {
applyDynamic(ctx, objectAPI, cfg, subSys, r, w) applyDynamic(ctx, objectAPI, cfg, subSys, r, w)
} }
writeSuccessResponseHeadersOnly(w) writeSuccessResponseHeadersOnly(w)
} }