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

Fix testLogBug and changeSomeVariableName #6420

Merged
merged 4 commits into from
Jan 2, 2025
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
2 changes: 1 addition & 1 deletion apis/keda/v1alpha1/scaledobject_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const (
// HealthStatusFailing means the status of the health object is failing
HealthStatusFailing HealthStatusType = "Failing"

// Composite metric name used for scalingModifiers composite metric
// CompositeMetricName is used for scalingModifiers composite metric
CompositeMetricName string = "composite-metric"

defaultHPAMinReplicas int32 = 1
Expand Down
14 changes: 7 additions & 7 deletions apis/keda/v1alpha1/scaledobject_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ func verifyHpas(incomingSo *ScaledObject, action string, _ bool) error {
return err
}

var incomingSoGckr GroupVersionKindResource
incomingSoGckr, err = ParseGVKR(restMapper, incomingSo.Spec.ScaleTargetRef.APIVersion, incomingSo.Spec.ScaleTargetRef.Kind)
var incomingSoGvkr GroupVersionKindResource
incomingSoGvkr, err = ParseGVKR(restMapper, incomingSo.Spec.ScaleTargetRef.APIVersion, incomingSo.Spec.ScaleTargetRef.Kind)
if err != nil {
scaledobjectlog.Error(err, "Failed to parse Group, Version, Kind, Resource from incoming ScaledObject", "apiVersion", incomingSo.Spec.ScaleTargetRef.APIVersion, "kind", incomingSo.Spec.ScaleTargetRef.Kind)
return err
Expand All @@ -245,13 +245,13 @@ func verifyHpas(incomingSo *ScaledObject, action string, _ bool) error {
val, _ := json.MarshalIndent(hpa, "", " ")
scaledobjectlog.V(1).Info(fmt.Sprintf("checking hpa %s: %v", hpa.Name, string(val)))

hpaGckr, err := ParseGVKR(restMapper, hpa.Spec.ScaleTargetRef.APIVersion, hpa.Spec.ScaleTargetRef.Kind)
hpaGvkr, err := ParseGVKR(restMapper, hpa.Spec.ScaleTargetRef.APIVersion, hpa.Spec.ScaleTargetRef.Kind)
if err != nil {
scaledobjectlog.Error(err, "Failed to parse Group, Version, Kind, Resource from HPA", "hpaName", hpa.Name, "apiVersion", hpa.Spec.ScaleTargetRef.APIVersion, "kind", hpa.Spec.ScaleTargetRef.Kind)
return err
}

if hpaGckr.GVKString() == incomingSoGckr.GVKString() &&
if hpaGvkr.GVKString() == incomingSoGvkr.GVKString() &&
hpa.Spec.ScaleTargetRef.Name == incomingSo.Spec.ScaleTargetRef.Name {
owned := false
for _, owner := range hpa.OwnerReferences {
Expand All @@ -268,7 +268,7 @@ func verifyHpas(incomingSo *ScaledObject, action string, _ bool) error {
incomingSo.Spec.Advanced.HorizontalPodAutoscalerConfig.Name == hpa.Name {
scaledobjectlog.Info(fmt.Sprintf("%s hpa ownership being transferred to %s", hpa.Name, incomingSo.Name))
} else {
err = fmt.Errorf("the workload '%s' of type '%s' is already managed by the hpa '%s'", incomingSo.Spec.ScaleTargetRef.Name, incomingSoGckr.GVKString(), hpa.Name)
err = fmt.Errorf("the workload '%s' of type '%s' is already managed by the hpa '%s'", incomingSo.Spec.ScaleTargetRef.Name, incomingSoGvkr.GVKString(), hpa.Name)
scaledobjectlog.Error(err, "validation error")
metricscollector.RecordScaledObjectValidatingErrors(incomingSo.Namespace, action, "other-hpa")
return err
Expand Down Expand Up @@ -363,13 +363,13 @@ func verifyCPUMemoryScalers(incomingSo *ScaledObject, action string, dryRun bool
Namespace: incomingSo.Namespace,
Name: incomingSo.Spec.ScaleTargetRef.Name,
}
incomingSoGckr, err := ParseGVKR(restMapper, incomingSo.Spec.ScaleTargetRef.APIVersion, incomingSo.Spec.ScaleTargetRef.Kind)
incomingSoGvkr, err := ParseGVKR(restMapper, incomingSo.Spec.ScaleTargetRef.APIVersion, incomingSo.Spec.ScaleTargetRef.Kind)
if err != nil {
scaledobjectlog.Error(err, "Failed to parse Group, Version, Kind, Resource from incoming ScaledObject", "apiVersion", incomingSo.Spec.ScaleTargetRef.APIVersion, "kind", incomingSo.Spec.ScaleTargetRef.Kind)
return err
}

switch incomingSoGckr.GVKString() {
switch incomingSoGvkr.GVKString() {
case "apps/v1.Deployment":
deployment := &appsv1.Deployment{}
if err := getFromCacheOrDirect(context.Background(), key, deployment); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions tests/internals/events/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,12 @@ func getTemplateData() (templateData, []Template) {
}, []Template{}
}

func checkingEvent(t *testing.T, namespace string, scaledObject string, index int, eventreason string, message string) {
func checkingEvent(t *testing.T, namespace string, scaledObject string, index int, eventReason string, message string) {
result, err := ExecuteCommand(fmt.Sprintf("kubectl get events -n %s --field-selector involvedObject.name=%s --sort-by=.metadata.creationTimestamp -o jsonpath=\"{.items[%d].reason}:{.items[%d].message}\"", namespace, scaledObject, index, index))

assert.NoError(t, err)
lastEventMessage := strings.Trim(string(result), "\"")
assert.Equal(t, lastEventMessage, eventreason+":"+message)
assert.Equal(t, eventReason+":"+message, lastEventMessage)
}

func testNormalEvent(t *testing.T, kc *kubernetes.Clientset, data templateData) {
Expand Down
Loading