Skip to content

Commit

Permalink
fix configuration reconcile loop
Browse files Browse the repository at this point in the history
  • Loading branch information
skonto committed Oct 30, 2024
1 parent c8e131b commit 36762d1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 7 additions & 2 deletions pkg/reconciler/labeler/accessors.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package labeler

import (
"context"
"sort"
"strings"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -128,15 +129,19 @@ func updateRouteAnnotation(acc kmeta.Accessor, routeName string, diffAnn map[str
return
}
valSet.Delete(routeName)
diffAnn[serving.RoutesAnnotationKey] = strings.Join(valSet.UnsortedList(), ",")
sorted := valSet.UnsortedList()
sort.Strings(sorted)
diffAnn[serving.RoutesAnnotationKey] = strings.Join(sorted, ",")

case !has && !remove:
if len(valSet) == 0 {
diffAnn[serving.RoutesAnnotationKey] = routeName
return
}
valSet.Insert(routeName)
diffAnn[serving.RoutesAnnotationKey] = strings.Join(valSet.UnsortedList(), ",")
sorted := valSet.UnsortedList()
sort.Strings(sorted)
diffAnn[serving.RoutesAnnotationKey] = strings.Join(sorted, ",")
}
}

Expand Down
5 changes: 4 additions & 1 deletion pkg/reconciler/service/resources/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package resources

import (
"sort"
"strings"

corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -48,7 +49,9 @@ func MakeConfigurationFromExisting(service *v1.Service, existing *v1.Configurati
routeName := names.Route(service)
set := labeler.GetListAnnValue(existing.Annotations, serving.RoutesAnnotationKey)
set.Insert(routeName)
anns[serving.RoutesAnnotationKey] = strings.Join(set.UnsortedList(), ",")
sorted := set.UnsortedList()
sort.Strings(sorted)
anns[serving.RoutesAnnotationKey] = strings.Join(sorted, ",")

return &v1.Configuration{
ObjectMeta: metav1.ObjectMeta{
Expand Down

0 comments on commit 36762d1

Please sign in to comment.