Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base image update #149

Merged
merged 4 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ jobs:
name: Image Scanner
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.20+
- name: Set up Go 1.21+
uses: actions/setup-go@v2
with:
go-version: ^1.20
go-version: ^1.21
id: go
- name: Checkout the code
uses: actions/checkout@v2
Expand All @@ -70,11 +70,8 @@ jobs:
- name: Get dependencies
run: go mod download
- name: Build csm-metrics-powerflex Docker Image
run: make clean build docker
- name: Image scanner
uses: Azure/container-scan@v0
run: make clean build docker
- name: Run Trivy action
uses: aquasecurity/trivy-action@master
with:
image-name: csm-metrics-powerflex
severity-threshold: HIGH
env:
DOCKLE_HOST: "unix:///var/run/docker.sock"
image-ref: csm-metrics-powerflex
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM registry.access.redhat.com/ubi9/ubi-micro
FROM registry.access.redhat.com/ubi9/ubi-micro@sha256:630cf7bdef807f048cadfe7180d6c27eb3aaa99323ffc3628811da230ed3322a
LABEL vendor="Dell Inc." \
name="csm-metrics-powerflex" \
summary="Dell Container Storage Modules (CSM) for Observability - Metrics for PowerFlex" \
Expand Down
6 changes: 2 additions & 4 deletions cmd/metrics-powerflex/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"fmt"
"math"
"os"
"strconv"
"strings"
"time"
Expand All @@ -34,8 +35,6 @@ import (
sio "github.com/dell/goscaleio"
"go.opentelemetry.io/otel/metric/global"

"os"

"github.com/fsnotify/fsnotify"
"github.com/spf13/viper"
)
Expand All @@ -47,7 +46,6 @@ const (
)

func main() {

logger := logrus.New()

viper.SetConfigFile(defaultConfigFile)
Expand Down Expand Up @@ -188,7 +186,7 @@ func updatePowerFlexConnection(config *entrypoint.Config, sdcFinder *k8s.SDCFind
if powerFlexSystemID == "" {
logger.WithError(err).Fatal("powerflex system ID was empty")
}
var storageID = k8s.StorageSystemID{
storageID := k8s.StorageSystemID{
ID: powerFlexSystemID,
IsDefault: storageSystem.IsDefault,
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/dell/karavi-metrics-powerflex
go 1.21

require (
github.com/dell/goscaleio v1.10.0
github.com/dell/goscaleio v1.11.1-0.20230816075825-380ffbcbcd75
github.com/fsnotify/fsnotify v1.5.3
github.com/golang/mock v1.6.0
github.com/sirupsen/logrus v1.8.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dell/goscaleio v1.10.0 h1:XCEI9j+IlbqNPY7uvBjNNlT0Nt2PMXlnyxUavmennVY=
github.com/dell/goscaleio v1.10.0/go.mod h1:Zh2iQ44Jd8FMqU2h+rT5x1K6mdPMKQ15lkFxojU4z3w=
github.com/dell/goscaleio v1.11.1-0.20230816075825-380ffbcbcd75 h1:2bCpRCPqfzueF+ASLyjc1ZH7SN7GH8+rB6jbBcxeCck=
github.com/dell/goscaleio v1.11.1-0.20230816075825-380ffbcbcd75/go.mod h1:dMTrHnXSsPus+Kd9mrs0JuyrCndoKvFP/bbEdc21Bi8=
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
Expand Down
12 changes: 5 additions & 7 deletions internal/entrypoint/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,13 @@ const (
// MinimumVolTickInterval is the minimum allowed interval when querying volume metrics
MinimumVolTickInterval = 5 * time.Second
// DefaultEndPoint for leader election path
DefaultEndPoint = "karavi-metrics-powerflex"
DefaultEndPoint = "karavi-metrics-powerflex" // #nosec G101
// DefaultNameSpace for powerflex pod running metrics collection
DefaultNameSpace = "karavi"
)

var (
// ConfigValidatorFunc is used to override config validation in testing
ConfigValidatorFunc func(*Config) error = ValidateConfig
)
// ConfigValidatorFunc is used to override config validation in testing
var ConfigValidatorFunc = ValidateConfig

// Config holds data that will be used by the service
type Config struct {
Expand Down Expand Up @@ -116,7 +114,7 @@ func Run(ctx context.Context, config *Config, exporter otlexporters.Otlexporter,

runtime.GOMAXPROCS(runtime.NumCPU())

//set initial tick intervals
// set initial tick intervals
SDCTickInterval := config.SDCTickInterval
VolumeTickInterval := config.VolumeTickInterval
StoragePoolTickInterval := config.StoragePoolTickInterval
Expand Down Expand Up @@ -248,7 +246,7 @@ func Run(ctx context.Context, config *Config, exporter otlexporters.Otlexporter,
return nil
}

//check if tick interval config settings have changed
// check if tick interval config settings have changed
if SDCTickInterval != config.SDCTickInterval {
SDCTickInterval = config.SDCTickInterval
sdcTicker = time.NewTicker(SDCTickInterval)
Expand Down
1 change: 0 additions & 1 deletion internal/entrypoint/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func Test_Run(t *testing.T) {
validVolumeTickInterval := entrypoint.MinimumSDCTickInterval

tests := map[string]func(t *testing.T) (expectError bool, config *entrypoint.Config, exporter otlexporters.Otlexporter, pflexSvc pflexServices.Service, prevConfigValidationFunc func(*entrypoint.Config) error, ctrl *gomock.Controller, validatingConfig bool){

"success": func(*testing.T) (bool, *entrypoint.Config, otlexporters.Otlexporter, pflexServices.Service, func(*entrypoint.Config) error, *gomock.Controller, bool) {
ctrl := gomock.NewController(t)
pfClient := metrics.NewMockPowerFlexClient(ctrl)
Expand Down
4 changes: 0 additions & 4 deletions internal/k8s/k8sapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ func Test_GetCSINodes(t *testing.T) {

tests := map[string]func(t *testing.T) (connectFn, configFn, []checkFn){
"success": func(*testing.T) (connectFn, configFn, []checkFn) {

nodes := &v1.CSINodeList{
Items: []v1.CSINode{
{
Expand Down Expand Up @@ -118,7 +117,6 @@ func Test_GetCSINodes(t *testing.T) {
}
})
}

}

func Test_GetPersistentVolumes(t *testing.T) {
Expand Down Expand Up @@ -147,7 +145,6 @@ func Test_GetPersistentVolumes(t *testing.T) {

tests := map[string]func(t *testing.T) (connectFn, configFn, []checkFn){
"success": func(*testing.T) (connectFn, configFn, []checkFn) {

volumes := &corev1.PersistentVolumeList{
Items: []corev1.PersistentVolume{
{
Expand Down Expand Up @@ -196,7 +193,6 @@ func Test_GetPersistentVolumes(t *testing.T) {
}
})
}

}

func Test_GetStorageClasses(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion internal/k8s/leader_elector.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ type LeaderElector struct {

// InitLeaderElection will run algorithm for leader election, call during service initialzation process
func (elect *LeaderElector) InitLeaderElection(endpoint string, namespace string) error {

k8sconfig, err := InClusterConfigFn()
if err != nil {
return err
Expand Down
1 change: 0 additions & 1 deletion internal/k8s/node_finder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func Test_K8sNodeFinder(t *testing.T) {

tests := map[string]func(t *testing.T) (k8s.NodeFinder, []checkFn, *gomock.Controller){
"success finding nodes": func(*testing.T) (k8s.NodeFinder, []checkFn, *gomock.Controller) {

ctrl := gomock.NewController(t)
api := mocks.NewMockNodeGetter(ctrl)

Expand Down
1 change: 0 additions & 1 deletion internal/k8s/sdc_finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ func (f *SDCFinder) isMatch(driver v1.CSINodeDriver) bool {
return true
}
}

}
}
return false
Expand Down
3 changes: 0 additions & 3 deletions internal/k8s/sdc_finder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func Test_K8sSDCFinder(t *testing.T) {

tests := map[string]func(t *testing.T) (k8s.SDCFinder, []checkFn, *gomock.Controller){
"success": func(*testing.T) (k8s.SDCFinder, []checkFn, *gomock.Controller) {

ctrl := gomock.NewController(t)
api := mocks.NewMockKubernetesAPI(ctrl)

Expand Down Expand Up @@ -113,7 +112,6 @@ func Test_K8sSDCFinder(t *testing.T) {
return finder, check(hasNoError, checkExpectedOutput([]string{"node-1", "node-3"})), ctrl
},
"success with multiple driver names": func(*testing.T) (k8s.SDCFinder, []checkFn, *gomock.Controller) {

ctrl := gomock.NewController(t)
api := mocks.NewMockKubernetesAPI(ctrl)

Expand Down Expand Up @@ -181,5 +179,4 @@ func Test_K8sSDCFinder(t *testing.T) {
ctrl.Finish()
})
}

}
1 change: 0 additions & 1 deletion internal/k8s/storageclass_finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func (f *StorageClassFinder) GetStorageClasses() ([]v1.StorageClass, error) {
}

func (f *StorageClassFinder) isMatch(class v1.StorageClass) bool {

for _, storage := range f.StorageSystemID {
if !Contains(storage.DriverNames, class.Provisioner) {
continue
Expand Down
6 changes: 0 additions & 6 deletions internal/k8s/storageclass_finder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func Test_K8sStorageClassFinder(t *testing.T) {

tests := map[string]func(t *testing.T) (k8s.StorageClassFinder, []checkFn, *gomock.Controller){
"success not selecting storageclass that is not in config": func(*testing.T) (k8s.StorageClassFinder, []checkFn, *gomock.Controller) {

ctrl := gomock.NewController(t)
api := mocks.NewMockStorageClassGetter(ctrl)

Expand Down Expand Up @@ -96,7 +95,6 @@ func Test_K8sStorageClassFinder(t *testing.T) {
return finder, check(hasNoError, checkExpectedOutput(expected.Items)), ctrl
},
"success selecting the matching driver name with storage classes": func(*testing.T) (k8s.StorageClassFinder, []checkFn, *gomock.Controller) {

ctrl := gomock.NewController(t)
api := mocks.NewMockStorageClassGetter(ctrl)

Expand Down Expand Up @@ -133,7 +131,6 @@ func Test_K8sStorageClassFinder(t *testing.T) {
return finder, check(hasNoError, checkExpectedOutput(storageClasses.Items)), ctrl
},
"success selecting storage classes matching multiple driver names": func(*testing.T) (k8s.StorageClassFinder, []checkFn, *gomock.Controller) {

ctrl := gomock.NewController(t)
api := mocks.NewMockStorageClassGetter(ctrl)

Expand Down Expand Up @@ -191,7 +188,6 @@ func Test_K8sStorageClassFinder(t *testing.T) {
return finder, check(hasNoError, checkExpectedOutput(storageClasses.Items)), ctrl
},
"success matching storage classes without systemID based on a default system being used": func(*testing.T) (k8s.StorageClassFinder, []checkFn, *gomock.Controller) {

ctrl := gomock.NewController(t)
api := mocks.NewMockStorageClassGetter(ctrl)

Expand Down Expand Up @@ -260,7 +256,6 @@ func Test_K8sStorageClassFinder(t *testing.T) {
)), ctrl
},
"success selecting storage classes matching one of two driver names": func(*testing.T) (k8s.StorageClassFinder, []checkFn, *gomock.Controller) {

ctrl := gomock.NewController(t)
api := mocks.NewMockStorageClassGetter(ctrl)

Expand Down Expand Up @@ -358,7 +353,6 @@ func Test_K8sStorageClassFinder(t *testing.T) {
ctrl.Finish()
})
}

}

func Test_GetStoragePools(t *testing.T) {
Expand Down
3 changes: 0 additions & 3 deletions internal/k8s/volume_finder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ func Test_K8sPersistentVolumeFinder(t *testing.T) {

tests := map[string]func(t *testing.T) (k8s.VolumeFinder, []checkFn, *gomock.Controller){
"success selecting the matching driver name with multiple volumes": func(*testing.T) (k8s.VolumeFinder, []checkFn, *gomock.Controller) {

ctrl := gomock.NewController(t)
api := mocks.NewMockVolumeGetter(ctrl)

Expand Down Expand Up @@ -152,7 +151,6 @@ func Test_K8sPersistentVolumeFinder(t *testing.T) {
})), ctrl
},
"success selecting multiple volumes matching multiple driver names": func(*testing.T) (k8s.VolumeFinder, []checkFn, *gomock.Controller) {

ctrl := gomock.NewController(t)
api := mocks.NewMockVolumeGetter(ctrl)

Expand Down Expand Up @@ -399,5 +397,4 @@ func Test_K8sPersistentVolumeFinder(t *testing.T) {
ctrl.Finish()
})
}

}
1 change: 0 additions & 1 deletion internal/service/configuration_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ func (c *ConfigurationReader) GetStorageSystemConfiguration(file string) ([]Arra

if string(config) == "" {
return nil, fmt.Errorf("arrays details are not provided in vxflexos-config secret")

}

connectionData := make([]ArrayConnectionData, 0)
Expand Down
7 changes: 3 additions & 4 deletions internal/service/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (mw *MetricsWrapper) initMetrics(prefix, metaID string, labels []attribute.
return metrics, nil
}

func (mw *MetricsWrapper) initCapacityMetrics(prefix, metaID string, labels []attribute.KeyValue) (*CapacityMetrics, error) {
func (mw *MetricsWrapper) initCapacityMetrics(prefix, metaID string, _ []attribute.KeyValue) (*CapacityMetrics, error) {
totalLogicalCapacity, err := mw.Meter.AsyncFloat64().UpDownCounter(prefix + "total_logical_capacity_gigabytes")
if err != nil {
return nil, err
Expand Down Expand Up @@ -155,7 +155,6 @@ func (mw *MetricsWrapper) Record(ctx context.Context, meta interface{},
readIOPS, writeIOPS,
readLatency, writeLatency float64,
) error {

var prefix string
var metaID string
var labels []attribute.KeyValue
Expand Down Expand Up @@ -246,8 +245,8 @@ func (mw *MetricsWrapper) Record(ctx context.Context, meta interface{},

// RecordCapacity will publish capacity metrics for a given instance
func (mw *MetricsWrapper) RecordCapacity(ctx context.Context, meta interface{},
totalLogicalCapacity, logicalCapacityAvailable, logicalCapacityInUse, logicalProvisioned float64) error {

totalLogicalCapacity, logicalCapacityAvailable, logicalCapacityInUse, logicalProvisioned float64,
) error {
switch v := meta.(type) {
case StorageClassMeta:
switch v.Driver {
Expand Down
Loading
Loading