diff --git a/pkg/reconciler/labeler/accessors.go b/pkg/reconciler/labeler/accessors.go index bd30b793e87c..688ababcda87 100644 --- a/pkg/reconciler/labeler/accessors.go +++ b/pkg/reconciler/labeler/accessors.go @@ -18,6 +18,7 @@ package labeler import ( "context" + "sort" "strings" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -128,7 +129,9 @@ 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 { @@ -136,7 +139,9 @@ func updateRouteAnnotation(acc kmeta.Accessor, routeName string, diffAnn map[str return } valSet.Insert(routeName) - diffAnn[serving.RoutesAnnotationKey] = strings.Join(valSet.UnsortedList(), ",") + sorted := valSet.UnsortedList() + sort.Strings(sorted) + diffAnn[serving.RoutesAnnotationKey] = strings.Join(sorted, ",") } } diff --git a/pkg/reconciler/service/resources/configuration.go b/pkg/reconciler/service/resources/configuration.go index 241ac7f11d54..f04662cb9b6a 100644 --- a/pkg/reconciler/service/resources/configuration.go +++ b/pkg/reconciler/service/resources/configuration.go @@ -17,6 +17,7 @@ limitations under the License. package resources import ( + "sort" "strings" corev1 "k8s.io/api/core/v1" @@ -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{