Skip to content

Commit

Permalink
Look up stale routes by annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
dmage committed Feb 26, 2019
1 parent 76c641b commit 4d9df6b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/resource/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (g *Generator) removeObsoleteRoutes(cr *imageregistryv1.Config) error {
PropagationPolicy: &propagationPolicy,
}
for _, route := range routes {
if !metaapi.IsControlledBy(route, cr) {
if !RouteIsCreatedByOperator(route) {
continue
}
if _, found := knownNames[route.Name]; found {
Expand Down
3 changes: 1 addition & 2 deletions pkg/resource/imageconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ func (gic *generatorImageConfig) getRouteHostnames() ([]string, error) {
}
defaultHost := ""
for _, route := range routes {
// ignore routes that weren't created by the registry operator
if _, ok := route.Annotations[RouteOwnerAnnotation]; !ok {
if !RouteIsCreatedByOperator(route) {
continue
}
for _, ingress := range route.Status.Ingress {
Expand Down
5 changes: 5 additions & 0 deletions pkg/resource/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ import (

const RouteOwnerAnnotation = "imageregistry.openshift.io"

func RouteIsCreatedByOperator(route *routeapi.Route) bool {
_, ok := route.Annotations[RouteOwnerAnnotation]
return ok
}

var _ Mutator = &generatorRoute{}

type generatorRoute struct {
Expand Down

0 comments on commit 4d9df6b

Please sign in to comment.