Skip to content
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
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ require (
github.com/intel/power-optimization-library v1.5.0
github.com/onsi/ginkgo/v2 v2.14.0
github.com/onsi/gomega v1.30.0
github.com/prometheus/client_golang v1.18.0
github.com/stretchr/testify v1.9.0
go.uber.org/zap v1.27.0
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e
golang.org/x/sys v0.18.0
google.golang.org/grpc v1.64.0
k8s.io/api v0.29.3
k8s.io/apimachinery v0.29.3
Expand Down Expand Up @@ -51,17 +54,14 @@ require (
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.18.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.2 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/oauth2 v0.18.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/cstates_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (r *CStatesReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct

// prepare system by resetting configuration
logger.V(4).Info("resetting C-States configuration")
err = r.restoreCStates(ctx, &logger)
err = r.restoreCStates(&logger)
if err != nil {
logger.Error(err, "failed to restore C-States", "error", err.Error())
return ctrl.Result{}, err
Expand Down Expand Up @@ -197,7 +197,7 @@ func (r *CStatesReconciler) applyCStates(cStatesSpec *powerv1.CStatesSpec, logge
return e.Join(errs...)
}

func (r *CStatesReconciler) restoreCStates(ctx context.Context, logger *logr.Logger) error {
func (r *CStatesReconciler) restoreCStates(logger *logr.Logger) error {
var errs = make([]error, 0)

logger.V(5).Info("resetting to default state for the shared pool")
Expand Down
6 changes: 3 additions & 3 deletions internal/controller/powerpod_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func (r *PowerPodReconciler) getPowerProfileRequestsFromContainers(containers []
logger.V(5).Info("reserving cores to container.", "ContainerID", containerID, "Cores", cleanCoreList)
// accounts for case where cores aquired through DRA don't match profile requests
if len(cleanCoreList) != requestNum {
recoverableErrs = append(recoverableErrs, fmt.Errorf(fmt.Sprintf("assigned cores did not match requested profiles. cores:%d, profiles %d", len(cleanCoreList), requestNum)))
recoverableErrs = append(recoverableErrs, fmt.Errorf("assigned cores did not match requested profiles. cores:%d, profiles %d", len(cleanCoreList), requestNum))
continue
}
logger.V(5).Info("creating the power container")
Expand Down Expand Up @@ -371,7 +371,7 @@ func getNewWorkloadContainerList(nodeContainers []powerv1.Container, podStateCon

logger.V(5).Info("checking if there are new containers for the workload")
for _, container := range nodeContainers {
if !isContainerInList(container.Name, container.Id, podStateContainers, logger) {
if !isContainerInList(container.Name, container.Id, podStateContainers) {
newNodeContainers = append(newNodeContainers, container)
}
}
Expand All @@ -380,7 +380,7 @@ func getNewWorkloadContainerList(nodeContainers []powerv1.Container, podStateCon
}

// Helper function - if container is in a list of containers
func isContainerInList(name string, uid string, containers []powerv1.Container, logger *logr.Logger) bool {
func isContainerInList(name string, uid string, containers []powerv1.Container) bool {
for _, container := range containers {
if container.Name == name && container.Id == uid {
return true
Expand Down
6 changes: 2 additions & 4 deletions internal/controller/powerpod_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1794,17 +1794,15 @@ func TestPowerPod_getNewWorkloadContainerList(t *testing.T) {
}

func TestPowerPodisContainerInList(t *testing.T) {
logger := logr.Discard()

// positive test
containers := []powerv1.Container{
{
Name: "test1",
Id: "12-34",
},
}
assert.True(t, isContainerInList("test1", "12-34", containers, &logger))
assert.True(t, isContainerInList("test1", "12-34", containers))

// negative test
assert.False(t, isContainerInList("not-in-list", "not-in-list", containers, &logger))
assert.False(t, isContainerInList("not-in-list", "not-in-list", containers))
}
2 changes: 1 addition & 1 deletion internal/controller/powerprofile_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ func TestPowerProfile_Reconcile_DeleteProfile(t *testing.T) {
t.Error(err)
t.Fatalf("%s - error retrieving the cstate object", tc.testCase)
}
for profile, _ := range cstate.Spec.ExclusivePoolCStates {
for profile := range cstate.Spec.ExclusivePoolCStates {
if profile == tc.profileName {
t.Error(err)
t.Fatalf("%s - error retrieving the cstate object - profile should be deleted", tc.testCase)
Expand Down
8 changes: 4 additions & 4 deletions internal/controller/powerworkload_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ func (r *PowerWorkloadReconciler) Reconcile(c context.Context, req ctrl.Request)
sharedPowerWorkloadName = req.NamespacedName.Name
wrappedErrs := e.Join(recoveryErrs...)
if wrappedErrs != nil {
errString := "error(s) encountered establishing reserved pool"
logger.Error(wrappedErrs, errString)
return ctrl.Result{Requeue: false}, fmt.Errorf(errString)
errString := fmt.Errorf("error(s) encountered establishing reserved pool")
logger.Error(wrappedErrs, errString.Error())
return ctrl.Result{Requeue: false}, errString
}
return ctrl.Result{}, nil
}
Expand Down Expand Up @@ -300,7 +300,7 @@ func createReservedPool(library power.Host, coreConfig powerv1.ReservedSpec, log
}

logger.Error(err, "error setting retrieving exclusive pool for reserved cores")
return fmt.Errorf(fmt.Sprintf("specified profile %s has no existing pool", coreConfig.PowerProfile))
return fmt.Errorf("specified profile %s has no existing pool", coreConfig.PowerProfile)
}
if err := pseudoReservedPool.SetPowerProfile(corePool.GetPowerProfile()); err != nil {
if removePoolError := pseudoReservedPool.Remove(); removePoolError != nil {
Expand Down
Loading