Skip to content

Commit

Permalink
don't set alternate annotations on internal types (#12313)
Browse files Browse the repository at this point in the history
  • Loading branch information
dprotaso authored Nov 23, 2021
1 parent 9bf9590 commit 89ac2aa
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
5 changes: 1 addition & 4 deletions pkg/reconciler/domainmapping/resources/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package resources

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"

Expand All @@ -42,9 +41,7 @@ func MakeIngress(dm *servingv1alpha1.DomainMapping, backendServiceName, hostName
Namespace: dm.Namespace,
Annotations: kmeta.FilterMap(kmeta.UnionMaps(map[string]string{
networking.IngressClassAnnotationKey: ingressClass,
}, dm.GetAnnotations()), func(key string) bool {
return key == corev1.LastAppliedConfigAnnotation
}),
}, dm.GetAnnotations()), routeresources.ExcludedAnnotations.Has),
Labels: kmeta.UnionMaps(dm.Labels, map[string]string{
serving.DomainMappingUIDLabelKey: string(dm.UID),
serving.DomainMappingNamespaceLabelKey: dm.Namespace,
Expand Down
5 changes: 1 addition & 4 deletions pkg/reconciler/route/resources/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"knative.dev/networking/pkg/apis/networking"
"knative.dev/serving/pkg/apis/serving"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
networkingv1alpha1 "knative.dev/networking/pkg/apis/networking/v1alpha1"
"knative.dev/pkg/kmeta"
Expand All @@ -43,9 +42,7 @@ func MakeCertificate(owner kmeta.OwnerRefableAccessor, ownerLabelKey string, dns
OwnerReferences: []metav1.OwnerReference{*kmeta.NewControllerRef(owner)},
Annotations: kmeta.FilterMap(kmeta.UnionMaps(map[string]string{
networking.CertificateClassAnnotationKey: certClass,
}, owner.GetAnnotations()), func(key string) bool {
return key == corev1.LastAppliedConfigAnnotation
}),
}, owner.GetAnnotations()), ExcludedAnnotations.Has),
Labels: map[string]string{
ownerLabelKey: owner.GetName(),
},
Expand Down
13 changes: 13 additions & 0 deletions pkg/reconciler/route/resources/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,24 @@ package resources

import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/sets"
network "knative.dev/networking/pkg"
"knative.dev/networking/pkg/apis/networking"
"knative.dev/serving/pkg/apis/serving"
)

// IsClusterLocalService returns whether a service is cluster local.
func IsClusterLocalService(svc *corev1.Service) bool {
return svc.GetLabels()[network.VisibilityLabelKey] == serving.VisibilityClusterLocal
}

// ExcludedAnnotations is the set of annotations that should not propagate to the
// Ingress or Certificate Resources
var ExcludedAnnotations = sets.NewString(
corev1.LastAppliedConfigAnnotation,

// We're probably never going to drop support for the older annotation casing (camelCase)
// so we don't need to propagate these to the internal types
networking.CertificateClassAnnotationAltKey,
networking.IngressClassAnnotationAltKey,
)
5 changes: 1 addition & 4 deletions pkg/reconciler/route/resources/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (

"github.com/davecgh/go-spew/spew"
"go.uber.org/zap"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/apimachinery/pkg/util/sets"
Expand Down Expand Up @@ -98,9 +97,7 @@ func MakeIngressWithRollout(
Annotations: kmeta.FilterMap(kmeta.UnionMaps(map[string]string{
networking.IngressClassAnnotationKey: ingressClass,
networking.RolloutAnnotationKey: serializeRollout(ctx, ro),
}, r.GetAnnotations()), func(key string) bool {
return key == corev1.LastAppliedConfigAnnotation
}),
}, r.GetAnnotations()), ExcludedAnnotations.Has),
OwnerReferences: []metav1.OwnerReference{*kmeta.NewControllerRef(r)},
},
Spec: spec,
Expand Down

0 comments on commit 89ac2aa

Please sign in to comment.