Skip to content

Commit

Permalink
clean up (#15418)
Browse files Browse the repository at this point in the history
Co-authored-by: Stavros Kontopoulos <st.kontopoulos@gmail.com>
  • Loading branch information
knative-prow-robot and skonto authored Jul 29, 2024
1 parent 83d3e5e commit 4f73244
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
13 changes: 13 additions & 0 deletions pkg/cleanup/cmd/cleanup/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"flag"
"log"
"strings"

"go.uber.org/zap"
apierrs "k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -55,6 +56,18 @@ func main() {
}
}

leases, err := client.CoordinationV1().Leases(system.Namespace()).List(context.Background(), metav1.ListOptions{})
if err != nil {
logger.Fatal("failed to fetch leases: ", err)
}
for _, lease := range leases.Items {
if strings.HasPrefix(lease.Name, "domainmapping") || strings.HasPrefix(lease.Name, "net-certmanager") {
if err = client.CoordinationV1().Leases(system.Namespace()).Delete(context.Background(), lease.Name, metav1.DeleteOptions{}); err != nil && !apierrs.IsNotFound(err) {
logger.Fatalf("failed to delete lease %s: %v", lease.Name, err)
}
}
}

// Delete the rest of the domain mapping resources
if err = client.CoreV1().Services(system.Namespace()).Delete(context.Background(), "domainmapping-webhook", metav1.DeleteOptions{}); err != nil && !apierrs.IsNotFound(err) {
logger.Fatal("failed to delete service domainmapping-webhook: ", err)
Expand Down
26 changes: 12 additions & 14 deletions pkg/reconciler/autoscaling/hpa/resources/hpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,19 @@ func MakeHPA(pa *autoscalingv1alpha1.PodAutoscaler, config *autoscalerconfig.Con
},
}}
default:
if target, ok := pa.Target(); ok {
targetQuantity := resource.NewQuantity(int64(target), resource.DecimalSI)
hpa.Spec.Metrics = []autoscalingv2.MetricSpec{{
Type: autoscalingv2.PodsMetricSourceType,
Pods: &autoscalingv2.PodsMetricSource{
Metric: autoscalingv2.MetricIdentifier{
Name: pa.Metric(),
},
Target: autoscalingv2.MetricTarget{
Type: autoscalingv2.AverageValueMetricType,
AverageValue: targetQuantity,
},
targetQuantity := resource.NewQuantity(int64(target), resource.DecimalSI)
hpa.Spec.Metrics = []autoscalingv2.MetricSpec{{
Type: autoscalingv2.PodsMetricSourceType,
Pods: &autoscalingv2.PodsMetricSource{
Metric: autoscalingv2.MetricIdentifier{
Name: pa.Metric(),
},
Target: autoscalingv2.MetricTarget{
Type: autoscalingv2.AverageValueMetricType,
AverageValue: targetQuantity,
},
}}
}
},
}}
}
}

Expand Down

0 comments on commit 4f73244

Please sign in to comment.