Skip to content

Commit

Permalink
Fix the app and version names in the MultidimPodAutoscaler resources. (
Browse files Browse the repository at this point in the history
…#126)

These names have to be valid label names. Moreover, they have to match
the resources we're deleting.

Without these changes, the multidimpodautoscaler resources will end up
hanging.
  • Loading branch information
spetrovic77 authored Mar 7, 2024
1 parent c5acd54 commit a3952f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
10 changes: 5 additions & 5 deletions internal/gke/gke.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ var autoJSONTmpl = template.Must(template.New("auto").Parse(`{
// configured for the given Kubernetes ReplicaSet.
func ensureReplicaSetAutoscaler(ctx context.Context, cluster *ClusterInfo, logger *slog.Logger, cfg *config.GKEConfig, replicaSet string) error {
dep := cfg.Deployment
name := name{dep.App.Name, replicaSet, dep.Id[:8]}.DNSLabel()
aName := name{dep.App.Name, replicaSet, dep.Id[:8]}.DNSLabel()
var b strings.Builder
if err := autoJSONTmpl.Execute(&b, struct {
Name string
Expand All @@ -462,14 +462,14 @@ func ensureReplicaSetAutoscaler(ctx context.Context, cluster *ClusterInfo, logge
TargetKind string
TargetName string
}{
Name: name,
Name: aName,
Namespace: namespaceName,
AppName: dep.App.Name,
DeploymentID: dep.Id,
AppName: name{dep.App.Name}.DNSLabel(),
DeploymentID: name{dep.Id}.DNSLabel(),
AppContainerName: appContainerName,
MinMemory: memoryUnit.String(),
TargetKind: "Deployment",
TargetName: name,
TargetName: aName,
}); err != nil {
return err
}
Expand Down
5 changes: 3 additions & 2 deletions internal/gke/nanny.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,14 @@ func RunManager(ctx context.Context, port int) error {
},
// deleteAppVersions
func(_ context.Context, app string, versions []*config.GKEConfig) error {
var errs []error
for _, version := range versions {
id := version.Deployment.Id
if err := kill(ctx, cluster, logger, app, id); err != nil {
return fmt.Errorf("kill %q: %w", version, err)
errs = append(errs, fmt.Errorf("kill %q: %w", version, err))
}
}
return nil
return errors.Join(errs...)
},
)

Expand Down

0 comments on commit a3952f4

Please sign in to comment.