Remove the retry on conflict
Since it's already be handled on the function `HandleError`, we don't
need the same logic twice.
package api
import (
- "fmt"
"net/http"
"strings"
@@ -11,9 +10,6 @@ import (
"github.com/rancher/go-rancher/client"
"github.com/longhorn/longhorn-manager/types"
- "github.com/longhorn/longhorn-manager/util"
-
- longhorn "github.com/longhorn/longhorn-manager/k8s/pkg/apis/longhorn/v1beta1"
)
func (s *Server) SettingList(w http.ResponseWriter, req *http.Request) error {
@@ -57,22 +53,16 @@ func (s *Server) SettingSet(w http.ResponseWriter, req *http.Request) error {
name := mux.Vars(req)["name"]
sName := types.SettingName(name)
-
- obj, err := util.RetryOnConflictCause(func() (interface{}, error) {
si, err := s.m.GetSetting(sName)
if err != nil {
- return nil, err
+ return err
}
+
si.Value = strings.TrimSpace(setting.Value)
- return s.m.CreateOrUpdateSetting(si)
- })
+ si, err = s.m.CreateOrUpdateSetting(si)
if err != nil {
return err
}
- si, ok := obj.(*longhorn.Setting)
- if !ok {
- return fmt.Errorf("BUG: cannot convert to setting %v object", name)
- }
apiContext.Write(toSettingResource(si))
return nil
