Skip to content

Commit

Permalink
Return empty StorageConfig when StorageConfigList is not empty (#8688)
Browse files Browse the repository at this point in the history
  • Loading branch information
itaigilo authored Feb 20, 2025
1 parent 04518de commit 7db5bf3
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions pkg/api/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1869,10 +1869,9 @@ func (c *Controller) GetConfig(w http.ResponseWriter, r *http.Request) {
}
}

storageCfg, _ := c.getStorageConfig(config.SingleBlockstoreID)
storageListCfg := c.getStorageConfigList()
storageCfg, storageCfgList := c.getStorageConfigs()
versionConfig := c.getVersionConfig()
writeResponse(w, r, http.StatusOK, apigen.Config{StorageConfig: storageCfg, VersionConfig: &versionConfig, StorageConfigList: &storageListCfg})
writeResponse(w, r, http.StatusOK, apigen.Config{StorageConfig: storageCfg, VersionConfig: &versionConfig, StorageConfigList: &storageCfgList})
}

func (c *Controller) GetStorageConfig(w http.ResponseWriter, r *http.Request) {
Expand All @@ -1885,10 +1884,21 @@ func (c *Controller) GetStorageConfig(w http.ResponseWriter, r *http.Request) {
return
}

storageCfg, _ := c.getStorageConfig(config.SingleBlockstoreID)
storageCfg, _ := c.getStorageConfigs()
writeResponse(w, r, http.StatusOK, storageCfg)
}

func (c *Controller) getStorageConfigs() (*apigen.StorageConfig, apigen.StorageConfigList) {
storageCfgList := c.getStorageConfigList()
if len(storageCfgList) > 1 {
// non-empty storage-config-list, return empty storage-config
return &apigen.StorageConfig{}, storageCfgList
} else {
storageCfg, _ := c.getStorageConfig(config.SingleBlockstoreID)
return storageCfg, storageCfgList
}
}

func (c *Controller) getStorageConfig(storageID string) (*apigen.StorageConfig, error) {
storage := c.Config.StorageConfig().GetStorageByID(storageID)
if storage == nil {
Expand Down

0 comments on commit 7db5bf3

Please sign in to comment.