Skip to content

Conversation

@tchap
Copy link
Contributor

@tchap tchap commented Jan 28, 2026

The --labels option was being ignored when exposing a service.
This is now fixed and .metadata.labels is set to the desired value.

@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Jan 28, 2026
@openshift-ci-robot
Copy link

@tchap: This pull request references Jira Issue OCPBUGS-74543, which is invalid:

  • expected the bug to target the "4.22.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

The --labels option was being ignored when exposing a service.
This is now fixed and .metadata.labels is set to the desired value.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai
Copy link

coderabbitai bot commented Jan 28, 2026

Walkthrough

Encapsulated route customization in a new finalizeRoute method on ExposeOptions that sets Route.Spec.Host, Route.Spec.Path, Route.Spec.WildcardPolicy and parses/merges user-provided labels into route.ObjectMeta.Labels; added unit tests for success, label merge, and invalid-label error handling.

Changes

Cohort / File(s) Summary
Expose command implementation
pkg/cli/expose/expose.go
Added finalizeRoute(route) helper on ExposeOptions; replaced direct Host/Path/WildcardPolicy assignments with it; parse labels via generate.ParseLabels() and return unable to parse labels: %w on error; merge parsed labels into route.ObjectMeta.Labels (assign if empty, otherwise add/overwrite keys).
Unit tests for finalizeRoute
pkg/cli/expose/expose_test.go
Added tests covering: Host/Path/WildcardPolicy population, successful label parsing and merging into route labels, and error on invalid label syntax.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@tchap
Copy link
Contributor Author

tchap commented Jan 28, 2026

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Jan 28, 2026
@openshift-ci-robot
Copy link

@tchap: This pull request references Jira Issue OCPBUGS-74543, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.22.0) matches configured target version for branch (4.22.0)
  • bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @zhouying7780

Details

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@pkg/cli/expose/expose.go`:
- Around line 188-205: The code unconditionally overwrites
route.ObjectMeta.Labels with the local variable labels (which is nil when
o.ExposeServiceOptions.Labels is omitted), discarding labels copied by
route.UnsecuredRoute; change the code to only assign route.ObjectMeta.Labels
when o.ExposeServiceOptions.Labels is non-empty (i.e., after parsing via
generate.ParseLabels or by checking len(o.ExposeServiceOptions.Labels) > 0) so
existing service labels from route.UnsecuredRoute are preserved when --labels is
not provided.

@tchap tchap force-pushed the expose-service-use-labels branch 2 times, most recently from b02b779 to d49d3a9 Compare January 28, 2026 15:19
@tchap
Copy link
Contributor Author

tchap commented Jan 28, 2026

I don't mind adding an e2e test for this once the OTE tests are merged.

@tchap tchap changed the title OCPBUGS-74543: expose: Fix labels not being added to service WIP: OCPBUGS-74543: expose: Fix labels not being added to service Jan 28, 2026
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 28, 2026
@tchap tchap changed the title WIP: OCPBUGS-74543: expose: Fix labels not being added to service WIP: OCPBUGS-74543: expose: Fix labels not being added to route Jan 28, 2026
@tchap tchap force-pushed the expose-service-use-labels branch from d49d3a9 to d5afaa8 Compare January 28, 2026 15:28
@zhouying7780
Copy link
Contributor

/label qe-approved

@openshift-ci openshift-ci bot added the qe-approved Signifies that QE has signed off on this PR label Jan 29, 2026
@openshift-ci-robot
Copy link

@tchap: This pull request references Jira Issue OCPBUGS-74543, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.22.0) matches configured target version for branch (4.22.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @zhouying7780

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

The --labels option was being ignored when exposing a service.
This is now fixed and .metadata.labels is set to the desired value.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@zhouying7780
Copy link
Contributor

/test e2e-aws-ovn-serial-2of2

@zhouying7780
Copy link
Contributor

/test e2e-agnostic-ovn-cmd

@tchap tchap force-pushed the expose-service-use-labels branch from d5afaa8 to 022f13d Compare January 30, 2026 10:02
@tchap tchap changed the title WIP: OCPBUGS-74543: expose: Fix labels not being added to route OCPBUGS-74543: expose: Fix labels not being added to route Jan 30, 2026
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 30, 2026
Copy link
Member

@ardaguclu ardaguclu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good to me. Some trivial comments for tests.

@ardaguclu
Copy link
Member

I don't mind adding an e2e test for this once the OTE tests are merged.

That would be great

@tchap tchap force-pushed the expose-service-use-labels branch from 022f13d to 377cb34 Compare January 30, 2026 12:59
@tchap
Copy link
Contributor Author

tchap commented Jan 30, 2026

I was then thinking the change is a bit too small to spend time on e2e tests, so I added the unit tests.

@ardaguclu
Copy link
Member

Thanks
/lgtm
/approve

@openshift-ci openshift-ci bot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jan 30, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@pkg/cli/expose/expose_test.go`:
- Around line 97-99: The test currently calls err.Error() directly which can
panic if err is nil; change the comparison to safely derive errMsg (e.g., set
errMsg := "" if err == nil else err.Error()) and then compare tc.expectedErrMsg
to errMsg (referencing tc.expectedErrMsg, err, errMsg and the test function in
expose_test.go) so no nil pointer dereference occurs during t.Errorf.

The --labels option was being ignored when exposing a service.
This is now fixed and .metadata.labels is set to the desired value.
@tchap tchap force-pushed the expose-service-use-labels branch from 377cb34 to 08d5f27 Compare January 30, 2026 13:17
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Jan 30, 2026
@ardaguclu
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 30, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 30, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ardaguclu, tchap

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 30, 2026

@tchap: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@tchap
Copy link
Contributor Author

tchap commented Jan 30, 2026

/verified by CI

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Jan 30, 2026
@openshift-ci-robot
Copy link

@tchap: This PR has been marked as verified by CI.

Details

In response to this:

/verified by CI

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-merge-bot openshift-merge-bot bot merged commit 7e80dba into openshift:main Jan 30, 2026
17 checks passed
@openshift-ci-robot
Copy link

@tchap: Jira Issue Verification Checks: Jira Issue OCPBUGS-74543
✔️ This pull request was pre-merge verified.
✔️ All associated pull requests have merged.
✔️ All associated, merged pull requests were pre-merge verified.

Jira Issue OCPBUGS-74543 has been moved to the MODIFIED state and will move to the VERIFIED state when the change is available in an accepted nightly payload. 🕓

Details

In response to this:

The --labels option was being ignored when exposing a service.
This is now fixed and .metadata.labels is set to the desired value.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@tchap tchap deleted the expose-service-use-labels branch January 30, 2026 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. qe-approved Signifies that QE has signed off on this PR verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants