Skip to content
Open
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
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-20260629123346-784126000268
github.com/openshift/api v0.0.0-20260714141955-8bc26b0fcc2d
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-20260629081241-b769428f4111
Expand Down
4 changes: 2 additions & 2 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-20260629123346-784126000268 h1:s2Z/n/ihnmPddz89PnLMkcOgjoe28VlkuDOMUu7y3uI=
github.com/openshift/api v0.0.0-20260629123346-784126000268/go.mod h1:Jm45pE7O6/G0tYYhiLzNyZykTjmf9BfhsKYuGfLLwTE=
github.com/openshift/api v0.0.0-20260714141955-8bc26b0fcc2d h1:wu0NFMDd8ZZOIOCTfDVjMDsmlBFptbAQVr41wiJbyPQ=
github.com/openshift/api v0.0.0-20260714141955-8bc26b0fcc2d/go.mod h1:7WJ3IPaK6nmWT8bDcaNooHqd0H5WepjVqV/10VlkMEM=
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
252 changes: 252 additions & 0 deletions test/extended/console/label_propagation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
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 = 60 * time.Second
pollInterval = 2 * time.Second
)

var _ = g.Describe("[sig-console][OCPFeatureGate:IngressComponentRouteLabels] 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() {
removeAllTestComponentRoutes(configClient)
})
Comment thread
coderabbitai[bot] marked this conversation as resolved.

g.It("should propagate labels from componentRoute spec to the route object [Serial]", 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"}

addComponentRouteWithLabels(configClient, name, hostname, labels)
route := waitForRouteWithLabels(routeV1, name, hostname, labels)

o.Expect(route.Labels[additionalRouteLabel]).To(o.Equal("true"))
o.Expect(route.Labels["app"]).To(o.Equal("console"))
})
Comment thread
coderabbitai[bot] marked this conversation as resolved.

g.It("should update route labels when componentRoute labels change [Serial]", 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"}

addComponentRouteWithLabels(configClient, name, hostname, labels)
waitForRouteWithLabels(routeV1, name, hostname, labels)

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

err := wait.Poll(pollInterval, pollTimeout, func() (bool, error) {
route, err := routeV1.RouteV1().Routes(consoleNamespace).Get(context.TODO(), 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 [Serial]", 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"}

addComponentRouteWithLabels(configClient, name, hostname, labels)
waitForRouteWithLabels(routeV1, name, hostname, labels)

updateComponentRouteLabels(configClient, name, map[string]configv1.LabelValue{"ingress": "shard-test"})

err := wait.Poll(pollInterval, pollTimeout, func() (bool, error) {
route, err := routeV1.RouteV1().Routes(consoleNamespace).Get(context.TODO(), 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 [Serial]", func() {
name := "console-label-test-4"
hostname := fmt.Sprintf("%s-%s.%s", name, consoleNamespace, domain)
labels := map[string]configv1.LabelValue{"custom-key": "custom-value"}

addComponentRouteWithLabels(configClient, name, hostname, labels)
route := waitForRouteWithLabels(routeV1, name, hostname, labels)

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 [Serial]", func() {
name := "console-label-test-5"
hostname := fmt.Sprintf("%s-%s.%s", name, consoleNamespace, domain)
labels := map[string]configv1.LabelValue{"ingress": "shard-test"}

addComponentRouteWithLabels(configClient, name, hostname, labels)
waitForRouteWithLabels(routeV1, name, hostname, labels)

removeComponentRoute(configClient, name)

err := wait.Poll(pollInterval, pollTimeout, func() (bool, error) {
_, err := routeV1.RouteV1().Routes(consoleNamespace).Get(context.TODO(), 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")
})
Comment thread
coderabbitai[bot] marked this conversation as resolved.
})

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 string(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 string(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)
}

func removeAllTestComponentRoutes(client configclient.Interface) {
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 !strings.HasPrefix(string(cr.Name), "console-label-test-") {
filtered = append(filtered, cr)
}
}
if len(filtered) == len(ingress.Spec.ComponentRoutes) {
return nil
}
ingress.Spec.ComponentRoutes = filtered
_, err = client.ConfigV1().Ingresses().Update(context.TODO(), ingress, metav1.UpdateOptions{})
return err
})
if err != nil {
e2e.Logf("warning: failed to clean up test componentRoutes: %v", 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
err := wait.Poll(pollInterval, pollTimeout, func() (bool, error) {
var err error
route, err = client.RouteV1().Routes(consoleNamespace).Get(context.TODO(), 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.

2 changes: 1 addition & 1 deletion vendor/github.com/openshift/api/Makefile

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

2 changes: 2 additions & 0 deletions vendor/github.com/openshift/api/apps/.codegen.yaml

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

2 changes: 2 additions & 0 deletions vendor/github.com/openshift/api/authorization/.codegen.yaml

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

2 changes: 2 additions & 0 deletions vendor/github.com/openshift/api/build/.codegen.yaml

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

2 changes: 2 additions & 0 deletions vendor/github.com/openshift/api/cloudnetwork/.codegen.yaml

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.

36 changes: 36 additions & 0 deletions vendor/github.com/openshift/api/config/v1/types_ingress.go

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

3 changes: 3 additions & 0 deletions vendor/github.com/openshift/api/config/v1/types_network.go

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

Loading