Skip to content

Commit

Permalink
Paradise timeout (#96)
Browse files Browse the repository at this point in the history
* Update to timeout for Paradise

* Added Changelog

* Update to copyright date

* Removed test code
  • Loading branch information
mbuchmann-hpe authored May 1, 2024
1 parent e1fa9c1 commit 46f54f4
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.31.0
1.32.0
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.32.0] - 2024-04-29

- Updated timeout for Paradise updates redfish calls to 120 seconds

## [1.31.0] - 2024-04-16

- Fixed loader zip file error
Expand Down
2 changes: 1 addition & 1 deletion cmd/hms-firmware-action/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const manufacturerFoxconn = "foxconn"

const (
dfltMaxHTTPRetries = 5
dfltMaxHTTPTimeout = 40
dfltMaxHTTPTimeout = 120
dfltMaxHTTPBackoff = 8
)
const defaultS3Endpoint = "s3"
Expand Down
12 changes: 9 additions & 3 deletions cmd/hms-firmware-action/updateScheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ func doLaunch(operation storage.Operation, image storage.Image, command storage.
mainLogger.Debug(operation.HsmData.UpdateURI)
mainLogger.Debug(pcs)
passback = SendSecureRedfish(globals, operation.HsmData.FQDN, operation.HsmData.UpdateURI,
pcs, operation.HsmData.User, operation.HsmData.Password, "POST")
pcs, operation.HsmData.User, operation.HsmData.Password, "POST", 120)
if !(passback.IsError || passback.StatusCode >= 400) {
// Foxconn return a link to a task which we can monitor for update progress
tasklink := new(model.TaskLink)
Expand Down Expand Up @@ -1080,7 +1080,13 @@ func fileCheck(fileLocation string) (returnLocation string, err error) {
}

func SendSecureRedfish(globals *domain.DOMAIN_GLOBALS, server string, path string, bodyStr string, authUser string,
authPass string, method string) (pb model.Passback) {
authPass string, method string, timeout_override ...int) (pb model.Passback) {

timeout := 40
if len(timeout_override) > 0 {
timeout = timeout_override[0]
}
mainLogger.WithFields(logrus.Fields{"Timeout": timeout}).Debug("TIMEOUT SETTING")

tmpURL, _ := url.Parse("https://" + server + path)
req, err := http.NewRequest(method, tmpURL.String(), bytes.NewBuffer([]byte(bodyStr)))
Expand All @@ -1093,7 +1099,7 @@ func SendSecureRedfish(globals *domain.DOMAIN_GLOBALS, server string, path strin
if !(authUser == "" && authPass == "") {
req.SetBasicAuth(authUser, authPass)
}
reqContext, _ := context.WithTimeout(context.Background(), time.Second*40)
reqContext, _ := context.WithTimeout(context.Background(), time.Second*time.Duration(timeout))
req = req.WithContext(reqContext)
if err != nil {
mainLogger.Error(err)
Expand Down
7 changes: 6 additions & 1 deletion internal/domain/version.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
*
* (C) Copyright [2020-2021] Hewlett Packard Enterprise Development LP
* (C) Copyright [2020-2024] Hewlett Packard Enterprise Development LP
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -477,6 +477,11 @@ func RetrieveTaskStatus(hd *hsm.HsmData, tasklink string) (stateStatus model.Tas
logrus.Error(err)
return
}
if resp.StatusCode >= 400 {
err = fmt.Errorf("Task Status Code: %d", resp.StatusCode)
logrus.Error(err)
return
}
defer resp.Body.Close()

body, err := ioutil.ReadAll(resp.Body)
Expand Down

0 comments on commit 46f54f4

Please sign in to comment.