Skip to content

Commit

Permalink
Merge pull request #57 from OpenCHAMI/synackd/fix-put
Browse files Browse the repository at this point in the history
Add postgres.Set to handle PUT; small fixes
  • Loading branch information
alexlovelltroy authored Jan 8, 2025
2 parents 245f5da + 1b50bd6 commit 45f42a5
Show file tree
Hide file tree
Showing 5 changed files with 381 additions and 147 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ all: binaries
.PHONY: binaries
binaries: version $(BINARIES)

.PHONY: docker
.PHONY: container
container: version $(BINARIES)
$(DOCKER) build --tag openchami/bss:$(VERSION)-dirty $(DOCKEROPTS) .

Expand Down
20 changes: 12 additions & 8 deletions cmd/boot-script-service/boot_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,15 @@ func SqlGetBootParams(macs, xnames []string, nids []int32) (results []bssTypes.B
}

func StoreNew(bp bssTypes.BootParams) (error, string) {
// postgres.Add will handle duplicates, and it is called in New().
// Therefore, if Postgres is enabled, simply call Store().
// postgres.Add will handle duplicates.
if useSQL {
return Store(bp)
debugf("postgres.Add(%v)\n", bp)
if result, err := bssdb.Add(bp); err != nil {
return err, ""
} else {
debugf("postgres.Add(%v) result: %v\n", bp, result)
return err, uuid.New().String()
}
}

item := ""
Expand Down Expand Up @@ -544,13 +549,12 @@ func Store(bp bssTypes.BootParams) (error, string) {
debugf("Store(%v)\n", bp)

if useSQL {
debugf("postgres.Add(%v)\n", bp)
result, err := bssdb.Add(bp)
if err != nil {
debugf("postgres.Set(%v)\n", bp)
if err := bssdb.Set(bp); err != nil {
return err, ""
} else {
return err, uuid.New().String()
}
debugf("postgres.Add result: %v\n", result)
return err, uuid.New().String()
}

var kernel_id, initrd_id string
Expand Down
2 changes: 1 addition & 1 deletion cmd/boot-script-service/default_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ func BootparametersPut(w http.ResponseWriter, r *http.Request) {
}
w.WriteHeader(http.StatusOK)
} else {
LogBootParameters(fmt.Sprintf("/bootparameters PATCH FAILED: %s", err.Error()), args)
LogBootParameters(fmt.Sprintf("/bootparameters PUT FAILED: %s", err.Error()), args)
herr, ok := base.GetHMSError(err)
if ok && herr.GetProblem() != nil {
base.SendProblemDetails(w, herr.GetProblem(), 0)
Expand Down
Loading

0 comments on commit 45f42a5

Please sign in to comment.