Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/openshift/origin

go 1.25.0
go 1.26.0

require (
cloud.google.com/go/storage v1.56.0
Expand Down Expand Up @@ -65,7 +65,7 @@ require (
github.com/opencontainers/go-digest v1.0.0
github.com/openshift-eng/openshift-tests-extension v0.0.0-20260127124016-0fed2b824818
github.com/openshift-kni/commatrix v0.0.5-0.20251111204857-e5a931eff73f
github.com/openshift/api v0.0.0-20260703175546-02e2c3de12fb
github.com/openshift/api v0.0.0-20260715165912-72066cc9718b
github.com/openshift/apiserver-library-go v0.0.0-20260303173613-cd3676268d31
github.com/openshift/build-machinery-go v0.0.0-20250530140348-dc5b2804eeee
github.com/openshift/client-go v0.0.0-20260703082747-24d059aea27a
Expand Down Expand Up @@ -106,9 +106,9 @@ require (
gopkg.in/src-d/go-git.v4 v4.13.1
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.35.1
k8s.io/api v0.36.2
k8s.io/apiextensions-apiserver v0.35.1
k8s.io/apimachinery v0.35.1
k8s.io/apimachinery v0.36.2
k8s.io/apiserver v0.35.1
k8s.io/cli-runtime v0.33.4
k8s.io/client-go v0.35.1
Expand Down Expand Up @@ -407,7 +407,7 @@ require (
google.golang.org/genproto v0.0.0-20250603155806-513f23925822 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250818200422-3122310a409c // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250826171959-ef028d996bc1 // indirect
google.golang.org/protobuf v1.36.8 // indirect
google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af // indirect
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
gopkg.in/go-jose/go-jose.v2 v2.6.3 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -903,8 +903,8 @@ github.com/openshift-eng/openshift-tests-extension v0.0.0-20260127124016-0fed2b8
github.com/openshift-eng/openshift-tests-extension v0.0.0-20260127124016-0fed2b824818/go.mod h1:6gkP5f2HL0meusT0Aim8icAspcD1cG055xxBZ9yC68M=
github.com/openshift-kni/commatrix v0.0.5-0.20251111204857-e5a931eff73f h1:E72Zoc+JImPehBrXkgaCbIDbSFuItvyX6RCaZ0FQE5k=
github.com/openshift-kni/commatrix v0.0.5-0.20251111204857-e5a931eff73f/go.mod h1:cDVdp0eda7EHE6tLuSeo4IqPWdAX/KJK+ogBirIGtsI=
github.com/openshift/api v0.0.0-20260703175546-02e2c3de12fb h1:OBv9vTp65mBtFDoz5iqaPhdjtZPv2Y3p4Q0C2yONA0M=
github.com/openshift/api v0.0.0-20260703175546-02e2c3de12fb/go.mod h1:7WJ3IPaK6nmWT8bDcaNooHqd0H5WepjVqV/10VlkMEM=
github.com/openshift/api v0.0.0-20260715165912-72066cc9718b h1:gN3SihCYEwoIksD+f24wHhwiEgvaV0RxNjgmkDvBBeg=
github.com/openshift/api v0.0.0-20260715165912-72066cc9718b/go.mod h1:k6qH5QOVa5GDln2VVm8Jz4NV3Z7R2SATHFLwGS6Wh3M=
github.com/openshift/apiserver-library-go v0.0.0-20260303173613-cd3676268d31 h1:oYPQMrkzyk002L5aN8I2tkUHTEu9lsVrc1qiJmHJdXU=
github.com/openshift/apiserver-library-go v0.0.0-20260303173613-cd3676268d31/go.mod h1:mnTsMMTtXSPBQzqBp5HXBjLvliveKenRADFQy9m5jc0=
github.com/openshift/build-machinery-go v0.0.0-20250530140348-dc5b2804eeee h1:+Sp5GGnjHDhT/a/nQ1xdp43UscBMr7G5wxsYotyhzJ4=
Expand Down Expand Up @@ -1623,8 +1623,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.36.8 h1:xHScyCOEuuwZEc6UtSOvPbAT4zRh0xcNRYekJwfqyMc=
google.golang.org/protobuf v1.36.8/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af h1:+5/Sw3GsDNlEmu7TfklWKPdQ0Ykja5VEmq2i817+jbI=
google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
293 changes: 293 additions & 0 deletions test/extended/console/label_propagation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,293 @@
package console

import (
"context"
"fmt"
"strings"
"time"

g "github.com/onsi/ginkgo/v2"
o "github.com/onsi/gomega"

configv1 "github.com/openshift/api/config/v1"
routev1 "github.com/openshift/api/route/v1"
configclient "github.com/openshift/client-go/config/clientset/versioned"
routeclient "github.com/openshift/client-go/route/clientset/versioned"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/util/retry"
e2e "k8s.io/kubernetes/test/e2e/framework"
)

const (
consoleNamespace = "openshift-console"
additionalRouteLabel = "console.openshift.io/additional-route"
pollTimeout = 2 * time.Minute
pollInterval = 2 * time.Second
)

var _ = g.Describe("[sig-console][apigroup:config.openshift.io][OCPFeatureGate:IngressComponentRouteLabels][Serial] Console operator route label propagation", func() {
defer g.GinkgoRecover()

var (
configClient configclient.Interface
routeV1 routeclient.Interface
domain string
)

g.BeforeEach(func() {
kubeconfig, err := e2e.LoadConfig()
o.Expect(err).NotTo(o.HaveOccurred())

configClient, err = configclient.NewForConfig(kubeconfig)
o.Expect(err).NotTo(o.HaveOccurred())

routeV1, err = routeclient.NewForConfig(kubeconfig)
o.Expect(err).NotTo(o.HaveOccurred())

ingress, err := configClient.ConfigV1().Ingresses().Get(context.TODO(), "cluster", metav1.GetOptions{})
o.Expect(err).NotTo(o.HaveOccurred())
domain = ingress.Spec.Domain
})

g.AfterEach(func() {
cleanupTestRoutes(configClient, routeV1)
})
Comment thread
coderabbitai[bot] marked this conversation as resolved.

g.It("should propagate labels from componentRoute spec to the route object", func() {
name := "console-label-test-1"
hostname := fmt.Sprintf("%s-%s.%s", name, consoleNamespace, domain)
labels := map[string]configv1.LabelValue{"ingress": "shard-test", "env": "ci"}

g.By("adding a componentRoute with labels")
addComponentRouteWithLabels(configClient, name, hostname, labels)

g.By("waiting for the route to be created with the expected labels")
route := waitForRouteWithLabels(routeV1, name, hostname, labels)

g.By("verifying operator-managed labels are preserved")
o.Expect(route.Labels[additionalRouteLabel]).To(o.Equal("true"))
o.Expect(route.Labels["app"]).To(o.Equal("console"))
})

g.It("should update route labels when componentRoute labels change", func() {
name := "console-label-test-2"
hostname := fmt.Sprintf("%s-%s.%s", name, consoleNamespace, domain)
labels := map[string]configv1.LabelValue{"ingress": "shard-test", "env": "ci"}

g.By("adding a componentRoute with initial labels")
addComponentRouteWithLabels(configClient, name, hostname, labels)
waitForRouteWithLabels(routeV1, name, hostname, labels)

g.By("updating the componentRoute labels")
updatedLabels := map[string]configv1.LabelValue{"ingress": "shard-updated", "tier": "frontend"}
updateComponentRouteLabels(configClient, name, updatedLabels)

g.By("waiting for the route labels to be reconciled")
ctx, cancel := context.WithTimeout(context.TODO(), pollTimeout)
defer cancel()
err := wait.PollUntilContextTimeout(ctx, pollInterval, pollTimeout, true, func(ctx context.Context) (bool, error) {
route, err := routeV1.RouteV1().Routes(consoleNamespace).Get(ctx, name, metav1.GetOptions{})
if err != nil {
return false, nil
}
return route.Labels["ingress"] == "shard-updated" && route.Labels["tier"] == "frontend", nil
})
o.Expect(err).NotTo(o.HaveOccurred(), "route labels should be updated")
})

g.It("should remove stale labels from route when removed from componentRoute spec", func() {
name := "console-label-test-3"
hostname := fmt.Sprintf("%s-%s.%s", name, consoleNamespace, domain)
labels := map[string]configv1.LabelValue{"ingress": "shard-test", "env": "ci"}

g.By("adding a componentRoute with initial labels")
addComponentRouteWithLabels(configClient, name, hostname, labels)
waitForRouteWithLabels(routeV1, name, hostname, labels)

g.By("removing the 'env' label from the componentRoute")
updateComponentRouteLabels(configClient, name, map[string]configv1.LabelValue{"ingress": "shard-test"})

g.By("waiting for the stale label to be removed from the route")
ctx, cancel := context.WithTimeout(context.TODO(), pollTimeout)
defer cancel()
err := wait.PollUntilContextTimeout(ctx, pollInterval, pollTimeout, true, func(ctx context.Context) (bool, error) {
route, err := routeV1.RouteV1().Routes(consoleNamespace).Get(ctx, name, metav1.GetOptions{})
if err != nil {
return false, nil
}
_, hasEnv := route.Labels["env"]
return !hasEnv && route.Labels["ingress"] == "shard-test", nil
})
o.Expect(err).NotTo(o.HaveOccurred(), "stale label 'env' should be removed")
})

g.It("should preserve operator-managed labels when user labels are applied", func() {
name := "console-label-test-4"
hostname := fmt.Sprintf("%s-%s.%s", name, consoleNamespace, domain)
labels := map[string]configv1.LabelValue{"custom-key": "custom-value"}

g.By("adding a componentRoute with a custom label")
addComponentRouteWithLabels(configClient, name, hostname, labels)

g.By("waiting for the route with expected labels")
route := waitForRouteWithLabels(routeV1, name, hostname, labels)

g.By("verifying operator-managed labels are not overridden")
o.Expect(route.Labels[additionalRouteLabel]).To(o.Equal("true"))
o.Expect(route.Labels["app"]).To(o.Equal("console"))
})

g.It("should clean up labeled route when componentRoute is removed", func() {
name := "console-label-test-5"
hostname := fmt.Sprintf("%s-%s.%s", name, consoleNamespace, domain)
labels := map[string]configv1.LabelValue{"ingress": "shard-test"}

g.By("adding a componentRoute with labels")
addComponentRouteWithLabels(configClient, name, hostname, labels)
waitForRouteWithLabels(routeV1, name, hostname, labels)

g.By("removing the componentRoute")
removeComponentRoute(configClient, name)

g.By("waiting for the route to be garbage collected")
ctx, cancel := context.WithTimeout(context.TODO(), pollTimeout)
defer cancel()
err := wait.PollUntilContextTimeout(ctx, pollInterval, pollTimeout, true, func(ctx context.Context) (bool, error) {
_, err := routeV1.RouteV1().Routes(consoleNamespace).Get(ctx, name, metav1.GetOptions{})
if apierrors.IsNotFound(err) {
return true, nil
}
if err != nil {
return false, nil
}
return false, nil
})
o.Expect(err).NotTo(o.HaveOccurred(), "route should be garbage collected")
})
})

func addComponentRouteWithLabels(client configclient.Interface, name, hostname string, labels map[string]configv1.LabelValue) {
err := retry.RetryOnConflict(retry.DefaultBackoff, func() error {
ingress, err := client.ConfigV1().Ingresses().Get(context.TODO(), "cluster", metav1.GetOptions{})
if err != nil {
return err
}
ingress.Spec.ComponentRoutes = append(ingress.Spec.ComponentRoutes, configv1.ComponentRouteSpec{
Namespace: consoleNamespace,
Name: name,
Hostname: configv1.Hostname(hostname),
Labels: labels,
})
_, err = client.ConfigV1().Ingresses().Update(context.TODO(), ingress, metav1.UpdateOptions{})
return err
})
o.Expect(err).NotTo(o.HaveOccurred(), "failed to add componentRoute %s", name)
}

func updateComponentRouteLabels(client configclient.Interface, name string, labels map[string]configv1.LabelValue) {
err := retry.RetryOnConflict(retry.DefaultBackoff, func() error {
ingress, err := client.ConfigV1().Ingresses().Get(context.TODO(), "cluster", metav1.GetOptions{})
if err != nil {
return err
}
for i, cr := range ingress.Spec.ComponentRoutes {
if cr.Name == name {
ingress.Spec.ComponentRoutes[i].Labels = labels
break
}
}
_, err = client.ConfigV1().Ingresses().Update(context.TODO(), ingress, metav1.UpdateOptions{})
return err
})
o.Expect(err).NotTo(o.HaveOccurred(), "failed to update labels on componentRoute %s", name)
}

func removeComponentRoute(client configclient.Interface, name string) {
err := retry.RetryOnConflict(retry.DefaultBackoff, func() error {
ingress, err := client.ConfigV1().Ingresses().Get(context.TODO(), "cluster", metav1.GetOptions{})
if err != nil {
return err
}
var filtered []configv1.ComponentRouteSpec
for _, cr := range ingress.Spec.ComponentRoutes {
if cr.Name != name {
filtered = append(filtered, cr)
}
}
ingress.Spec.ComponentRoutes = filtered
_, err = client.ConfigV1().Ingresses().Update(context.TODO(), ingress, metav1.UpdateOptions{})
return err
})
o.Expect(err).NotTo(o.HaveOccurred(), "failed to remove componentRoute %s", name)
}

// cleanupTestRoutes removes test componentRoutes from the Ingress config and
// directly deletes any orphaned route objects as a fallback in case the
// operator hasn't garbage-collected them yet.
func cleanupTestRoutes(configClient configclient.Interface, routeClient routeclient.Interface) {
err := retry.RetryOnConflict(retry.DefaultBackoff, func() error {
ingress, err := configClient.ConfigV1().Ingresses().Get(context.TODO(), "cluster", metav1.GetOptions{})
if err != nil {
return err
}
var filtered []configv1.ComponentRouteSpec
for _, cr := range ingress.Spec.ComponentRoutes {
if !strings.HasPrefix(cr.Name, "console-label-test-") {
filtered = append(filtered, cr)
}
}
if len(filtered) == len(ingress.Spec.ComponentRoutes) {
return nil
}
ingress.Spec.ComponentRoutes = filtered
_, err = configClient.ConfigV1().Ingresses().Update(context.TODO(), ingress, metav1.UpdateOptions{})
return err
})
if err != nil {
e2e.Logf("warning: failed to clean up test componentRoutes: %v", err)
}

routes, err := routeClient.RouteV1().Routes(consoleNamespace).List(context.TODO(), metav1.ListOptions{})
if err != nil {
e2e.Logf("warning: failed to list routes for cleanup: %v", err)
return
}
for _, r := range routes.Items {
if strings.HasPrefix(r.Name, "console-label-test-") {
if err := routeClient.RouteV1().Routes(consoleNamespace).Delete(context.TODO(), r.Name, metav1.DeleteOptions{}); err != nil && !apierrors.IsNotFound(err) {
e2e.Logf("warning: failed to delete orphaned test route %s: %v", r.Name, err)
}
}
}
}

// waitForRouteWithLabels polls until a route exists with the expected hostname,
// the operator-managed additional-route label, and all expected user labels.
func waitForRouteWithLabels(client routeclient.Interface, name, hostname string, expectedLabels map[string]configv1.LabelValue) *routev1.Route {
var route *routev1.Route
ctx, cancel := context.WithTimeout(context.TODO(), pollTimeout)
defer cancel()
err := wait.PollUntilContextTimeout(ctx, pollInterval, pollTimeout, true, func(ctx context.Context) (bool, error) {
var err error
route, err = client.RouteV1().Routes(consoleNamespace).Get(ctx, name, metav1.GetOptions{})
if err != nil {
return false, nil
}
if route.Spec.Host != hostname {
return false, nil
}
if route.Labels[additionalRouteLabel] != "true" {
return false, nil
}
for k, v := range expectedLabels {
if route.Labels[k] != string(v) {
return false, nil
}
}
return true, nil
})
o.Expect(err).NotTo(o.HaveOccurred(), "route %s not created with expected labels within %s", name, pollTimeout)
return route
}
1 change: 1 addition & 0 deletions test/extended/include.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
_ "github.com/openshift/origin/test/extended/clusterversion"
_ "github.com/openshift/origin/test/extended/cmd"
_ "github.com/openshift/origin/test/extended/config_operator"
_ "github.com/openshift/origin/test/extended/console"
_ "github.com/openshift/origin/test/extended/controller_manager"
_ "github.com/openshift/origin/test/extended/coreos"
_ "github.com/openshift/origin/test/extended/cpu_partitioning"
Expand Down
4 changes: 4 additions & 0 deletions vendor/github.com/openshift/api/.golangci.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/github.com/openshift/api/Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading