Skip to content

Commit

Permalink
Resolved various scaling/resource issues in SMD (#164)
Browse files Browse the repository at this point in the history
CASMHMS-6294
  • Loading branch information
jwlv authored Dec 12, 2024
1 parent 25f0e05 commit b1c19fd
Show file tree
Hide file tree
Showing 449 changed files with 79,073 additions and 36,527 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.11.17
2.11.18
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ 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).

## [2.11.18] - 2024-12-13

### Fixed

- Resolved various scaling/resource issues
- Upgraded Go to 1.23
- Updated go-retryablehttp to 0.7.7
- Fixed docker compose build issues

## [2.11.17] - 2024-07-22

### Fixed
Expand Down
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# (C) Copyright [2019-2023] Hewlett Packard Enterprise Development LP
# (C) Copyright [2019-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 All @@ -25,7 +25,7 @@

### Build Base Stage ###
# Build base just has the packages installed we need.
FROM artifactory.algol60.net/docker.io/library/golang:1.16-alpine AS build-base
FROM artifactory.algol60.net/docker.io/library/golang:1.23-alpine AS build-base

RUN set -ex \
&& apk -U upgrade \
Expand All @@ -50,9 +50,9 @@ FROM base AS builder

# Base image contains everything needed for Go building, just build.
RUN set -ex \
&& go build -v -tags musl -i github.com/Cray-HPE/hms-smd/v2/cmd/smd \
&& go build -v -tags musl -i github.com/Cray-HPE/hms-smd/v2/cmd/smd-loader \
&& go build -v -tags musl -i github.com/Cray-HPE/hms-smd/v2/cmd/smd-init
&& go build -v -tags musl github.com/Cray-HPE/hms-smd/v2/cmd/smd \
&& go build -v -tags musl github.com/Cray-HPE/hms-smd/v2/cmd/smd-loader \
&& go build -v -tags musl github.com/Cray-HPE/hms-smd/v2/cmd/smd-init


### Final Stage ###
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.test.unit.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# (C) Copyright [2019-2023] Hewlett Packard Enterprise Development LP
# (C) Copyright [2019-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 All @@ -22,7 +22,7 @@


### Build Base Stage ###
FROM artifactory.algol60.net/docker.io/library/golang:1.16-alpine AS build-base
FROM artifactory.algol60.net/docker.io/library/golang:1.23-alpine AS build-base

RUN set -ex \
&& apk -U upgrade \
Expand Down
19 changes: 16 additions & 3 deletions cmd/smd/job-types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MIT License
//
// (C) Copyright [2018-2023] Hewlett Packard Enterprise Development LP
// (C) Copyright [2018-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 All @@ -27,18 +27,30 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/hashicorp/go-retryablehttp"
"io"
"io/ioutil"
"log"
"net/http"
"strings"
"sync"
"time"

"github.com/hashicorp/go-retryablehttp"

base "github.com/Cray-HPE/hms-base"
"github.com/Cray-HPE/hms-smd/v2/pkg/sm"
)

// Response bodies should always be drained and closed, else we leak resources
// and fail to reuse network connections.
// TODO: This should be moved into hms-base
func DrainAndCloseResponseBody(resp *http.Response) {
if resp != nil && resp.Body != nil {
_, _ = io.Copy(io.Discard, resp.Body) // ok even if already drained
resp.Body.Close() // ok even if already closed
}
}

///////////////////////////////////////////////////////////////////////////////
// Job definitions
///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -195,12 +207,13 @@ func (j *JobSCN) Run() {
}
rsp, err := client.Do(newRequest)
if err != nil {
DrainAndCloseResponseBody(rsp)
j.s.LogAlways("WARNING: SCN POST failed for %s: %v", urlStr, err)
} else {
if rsp.Body != nil {
strbody, _ = ioutil.ReadAll(rsp.Body)
rsp.Body.Close()
}
DrainAndCloseResponseBody(rsp)
if rsp.StatusCode != 200 {
j.s.LogAlways("WARNING: An error occurred uploading SCN to %s: %s %s", urlStr, rsp.Status, string(strbody))
} else {
Expand Down
3 changes: 3 additions & 0 deletions cmd/smd/rfevent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,7 @@ func TestDoHandleRFEvent(t *testing.T) {

func DummyHandler(w http.ResponseWriter, req *http.Request) {
w.WriteHeader(404)
DrainAndCloseRequestBody(req)
return
}

Expand All @@ -750,6 +751,8 @@ func DummyHandler(w http.ResponseWriter, req *http.Request) {
//////////////////////////////////////////////////////////////////////////////

func GigabyteHandler(w http.ResponseWriter, req *http.Request) {
defer DrainAndCloseRequestBody(req)

// Test request parameters
switch req.URL.RequestURI() {

Expand Down
Loading

0 comments on commit b1c19fd

Please sign in to comment.