Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update how too-long endpoint hostnames are handled #1801

Merged
merged 1 commit into from Jan 23, 2024

Conversation

amisevsk
Copy link
Contributor

What does this PR do?

Update the hostname format used for endpoints whose hostnames are too long from

  <workspace-id>-<order>.<base-domain>

to

  <workspace-id>-<endpoint-name>.<base-domain>

This is necessary as the iteration order through endpoints is random (iterating through Go maps is random), resulting in inconsistent numbers used for <order>.

Using a combination of workspace ID and endpoint name should always be valid:

  • Workspace IDs are 25 characters long (ref)
  • Endpoint names are restricted to max 15 characters by the Devfile API (ref)
  • Endpoint names and workspace IDs are required to be alphanumeric with dashes, starting and ending with an alphanumeric character (ref)
  • Endpoint names are unique across all endpoints in the workspace (ref)

Screenshot/screencast of this PR

N/A

What issues does this PR fix or reference?

Closes eclipse-che/che#22774

How to test this PR?

See reproducer in linked issue; after change, long endpoints should get the hostname

workspaceID-endpointname.baseDomain

PR Checklist

As the author of this Pull Request I made sure that:

Reviewers

Reviewers, please comment how you tested the PR when approving it.

Update the hostname format used for endpoints whose hostnames are too
long from

  <workspace-id>-<order>.<base-domain>

to

  <workspace-id>-<endpoint-name>.<base-domain>

This is necessary as the iteration order through endpoints is random
(iterating through Go maps is random), resulting in inconsistent numbers
used for <order>.

Using a combination of workspace ID and endpoint name should always be
valid:

* Workspace IDs are 25 characters long
* Endpoint names are restricted to max 15 characters by the Devfile API
* Endpoint names and workspace IDs are required to be alphanumeric with
  dashes, starting and ending with an alphanumeric character
* Endpoint names are unique across all endpoints in the workspace

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
// If subdomain is not valid (e.g. too long), use alternate format
// The below should always be under 63 characters, as endpoint names are limited to 15 characters and workspace IDs are
// 25 characters.
return fmt.Sprintf("%s-%s.%s", u.workspaceID, endpointInfo.endpointName, baseDomain)
Copy link
Contributor

Choose a reason for hiding this comment

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

What about sorting endpoints by theirs names here [1] instead of changing host names?
I just have some concerns, maybe someone relies on hostnames.

[1]

order := 1
for componentName, endpoints := range routing.Spec.Endpoints {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I considered sorting the endpoints instead of this approach, but honestly iterating through a map in sorted order in Go is annoying (since there's no way to easily get a keyset, etc.) :)

These hostnames are not going to be reliably static in any case since this functionality is triggered only when the default endpoint name becomes too long. For example, some users might see the normal format while others see the legacy format (depending on how long usernames are). You could even end up in a situation where half your endpoints are normal, and half are legacy. In the past, we've pointed people at the endpoint-url attribute to determine the actual hostname used for each devfile endpoint.

I'm fine with sorting the endpoints, though I had a small concern that I was missing something in how they're handled, as the original issue has order numbers going up to 13 (which may just be how many endpoints the devfile has, I don't know).

An additional bonus of doing it this way is that we don't run into situations where endpoints could be updated unexpectedly -- e.g. with order, even sorted, if you update the devfile to have an endpoint earlier in the order, all your legacy-hostname endpoints might change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for explanation, make sense to me.

@tolusha
Copy link
Contributor

tolusha commented Jan 23, 2024

/test v14-operator-test

Copy link

openshift-ci bot commented Jan 23, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: amisevsk, dkwon17, tolusha

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

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

@amisevsk
Copy link
Contributor Author

I took some extra time to test edge cases here:

  • Endpoints that expose the same port (allowed if they're on the same container) still end up with unique names
  • Devfiles with non-unique endpoint names cannot be started in Che as they fail validation

@amisevsk
Copy link
Contributor Author

/test v14-che-behind-proxy

Copy link

openshift-ci bot commented Jan 23, 2024

@amisevsk: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/v14-che-behind-proxy 9acf840 link true /test v14-che-behind-proxy

Full PR test history. Your PR dashboard.

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/test-infra repository. I understand the commands that are listed here.

@tolusha
Copy link
Contributor

tolusha commented Jan 23, 2024

@amisevsk
Please ignore ci/prow/v14-che-behind-proxy check.

@amisevsk amisevsk merged commit d295ee1 into eclipse-che:main Jan 23, 2024
18 of 19 checks passed
@amisevsk amisevsk deleted the long-endpoint-hostnames branch January 23, 2024 20:51
@devstudio-release
Copy link

Build 3.12 :: operator_3.x/341: Console, Changes, Git Data

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

Build 3.12 :: operator_3.x/341: SUCCESS

Upstream sync done; /DS_CI/sync-to-downstream_3.x/6043 triggered

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

Build 3.12 :: copyIIBsToQuay/2437: Console, Changes, Git Data

@devstudio-release
Copy link

Build 3.12 :: sync-to-downstream_3.x/6045: SUCCESS

Build container: devspaces-operator-bundle synced; /DS_CI/get-sources-rhpkg-container-build_3.x/5920 triggered; /job/DS_CI/job/dsc_3.x triggered;

@devstudio-release
Copy link

Build 3.12 :: operator-bundle_3.x/2570: SUCCESS

Upstream sync done; /DS_CI/sync-to-downstream_3.x/6045 triggered

@devstudio-release
Copy link

Build 3.12 :: dsc_3.x/1767: Console, Changes, Git Data

@devstudio-release
Copy link

Build 3.12 :: update-digests_3.x/5644: SUCCESS

Detected new images: rebuild operator-bundle
* devspaces-operator; /DS_CI/operator-bundle_3.x/2570 triggered

@devstudio-release
Copy link

Build 3.12 :: dsc_3.x/1767: SUCCESS

3.12.0-CI

@devstudio-release
Copy link

Build 3.12 :: copyIIBsToQuay/2437: SUCCESS

3.12
arches = x86_64, s390x, ppc64le;
  * LATEST DS OPERATOR BUNDLE = <a href=https://quay.io/repository/devspaces/devspaces-operator-bundle?tab=tags>registry-proxy.engineering.redhat.com/rh-osbs/devspaces-operator-bundle:3.12-127
  * LATEST DWO OPERATOR BUNDLE = <a href=https://quay.io/repository/devworkspace/devworkspace-operator-bundle?tab=tags>registry-proxy.engineering.redhat.com/rh-osbs/devworkspace-operator-bundle:0.21-7
+ s390x-rhel8 IIB(s) copied:
  + quay.io/devspaces/iib:3.12-v4.15-654758-s390x
  + quay.io/devspaces/iib:3.12-v4.15-s390x
  + quay.io/devspaces/iib:next-v4.15-s390x
  + quay.io/devspaces/iib:3.12-v4.14-654783-533291-s390x
  + quay.io/devspaces/iib:3.12-v4.14-s390x
  + quay.io/devspaces/iib:next-v4.14-s390x
  + quay.io/devspaces/iib:3.12-v4.13-654743-533286-s390x
  + quay.io/devspaces/iib:3.12-v4.12-655175-533281-s390x
  + quay.io/devspaces/iib:3.12-v4.12-s390x
  + quay.io/devspaces/iib:next-v4.12-s390x
+ x86_64-rhel8 IIB(s) copied:
  + quay.io/devspaces/iib:3.12-v4.15-654758-x86_64
  + quay.io/devspaces/iib:3.12-v4.15-x86_64
  + quay.io/devspaces/iib:next-v4.15-x86_64
  + quay.io/devspaces/iib:3.12-v4.14-654783-533291-x86_64
  + quay.io/devspaces/iib:3.12-v4.14-x86_64
  + quay.io/devspaces/iib:next-v4.14-x86_64
  + quay.io/devspaces/iib:3.12-v4.13-654743-533286-x86_64
  + quay.io/devspaces/iib:3.12-v4.12-655175-533281-x86_64
  + quay.io/devspaces/iib:3.12-v4.12-x86_64
  + quay.io/devspaces/iib:next-v4.12-x86_64
+ ppc64le-rhel8 IIB(s) copied:
  + quay.io/devspaces/iib:3.12-v4.15-654758-ppc64le
  + quay.io/devspaces/iib:3.12-v4.15-ppc64le
  + quay.io/devspaces/iib:next-v4.15-ppc64le
  + quay.io/devspaces/iib:3.12-v4.14-654783-533291-ppc64le
  + quay.io/devspaces/iib:3.12-v4.14-ppc64le
  + quay.io/devspaces/iib:next-v4.14-ppc64le
  + quay.io/devspaces/iib:3.12-v4.13-654743-533286-ppc64le
  + quay.io/devspaces/iib:3.12-v4.12-655175-533281-ppc64le
  + quay.io/devspaces/iib:3.12-v4.12-ppc64le
  + quay.io/devspaces/iib:next-v4.12-ppc64le

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

@devstudio-release
Copy link

Build 3.12 :: copyIIBsToQuay/2438: Console, Changes, Git Data

@devstudio-release
Copy link

Build 3.12 :: sync-to-downstream_3.x/6047: SUCCESS

Build container: devspaces-operator-bundle synced; /DS_CI/get-sources-rhpkg-container-build_3.x/5922 triggered; /job/DS_CI/job/dsc_3.x triggered;

@devstudio-release
Copy link

Build 3.12 :: operator-bundle_3.x/2571: SUCCESS

Upstream sync done; /DS_CI/sync-to-downstream_3.x/6047 triggered

@devstudio-release
Copy link

Build 3.12 :: dsc_3.x/1768: Console, Changes, Git Data

@devstudio-release
Copy link

Build 3.12 :: dsc_3.x/1768: SUCCESS

3.12.0-CI

@devstudio-release
Copy link

Build 3.12 :: copyIIBsToQuay/2438: SUCCESS

3.12
arches = x86_64, s390x, ppc64le;
  * LATEST DS OPERATOR BUNDLE = <a href=https://quay.io/repository/devspaces/devspaces-operator-bundle?tab=tags>registry-proxy.engineering.redhat.com/rh-osbs/devspaces-operator-bundle:3.12-128
  * LATEST DWO OPERATOR BUNDLE = <a href=https://quay.io/repository/devworkspace/devworkspace-operator-bundle?tab=tags>registry-proxy.engineering.redhat.com/rh-osbs/devworkspace-operator-bundle:0.21-7
+ s390x-rhel8 IIB(s) copied:
  + quay.io/devspaces/iib:3.12-v4.15-655199-s390x
  + quay.io/devspaces/iib:3.12-v4.15-s390x
  + quay.io/devspaces/iib:next-v4.15-s390x
  + quay.io/devspaces/iib:3.12-v4.14-655208-533291-s390x
  + quay.io/devspaces/iib:3.12-v4.14-s390x
  + quay.io/devspaces/iib:next-v4.14-s390x
  + quay.io/devspaces/iib:3.12-v4.13-655223-533286-s390x
  + quay.io/devspaces/iib:3.12-v4.13-s390x
  + quay.io/devspaces/iib:next-v4.13-s390x
  + quay.io/devspaces/iib:3.12-v4.12-655219-533281-s390x
  + quay.io/devspaces/iib:3.12-v4.12-s390x
  + quay.io/devspaces/iib:next-v4.12-s390x
+ x86_64-rhel8 IIB(s) copied:
  + quay.io/devspaces/iib:3.12-v4.15-655199-x86_64
  + quay.io/devspaces/iib:3.12-v4.15-x86_64
  + quay.io/devspaces/iib:next-v4.15-x86_64
  + quay.io/devspaces/iib:3.12-v4.14-655208-533291-x86_64
  + quay.io/devspaces/iib:3.12-v4.14-x86_64
  + quay.io/devspaces/iib:next-v4.14-x86_64
  + quay.io/devspaces/iib:3.12-v4.13-655223-533286-x86_64
  + quay.io/devspaces/iib:3.12-v4.13-x86_64
  + quay.io/devspaces/iib:next-v4.13-x86_64
  + quay.io/devspaces/iib:3.12-v4.12-655219-533281-x86_64
  + quay.io/devspaces/iib:3.12-v4.12-x86_64
  + quay.io/devspaces/iib:next-v4.12-x86_64
+ ppc64le-rhel8 IIB(s) copied:
  + quay.io/devspaces/iib:3.12-v4.15-655199-ppc64le
  + quay.io/devspaces/iib:3.12-v4.15-ppc64le
  + quay.io/devspaces/iib:next-v4.15-ppc64le
  + quay.io/devspaces/iib:3.12-v4.14-655208-533291-ppc64le
  + quay.io/devspaces/iib:3.12-v4.14-ppc64le
  + quay.io/devspaces/iib:next-v4.14-ppc64le
  + quay.io/devspaces/iib:3.12-v4.13-655223-533286-ppc64le
  + quay.io/devspaces/iib:3.12-v4.13-ppc64le
  + quay.io/devspaces/iib:next-v4.13-ppc64le
  + quay.io/devspaces/iib:3.12-v4.12-655219-533281-ppc64le
  + quay.io/devspaces/iib:3.12-v4.12-ppc64le
  + quay.io/devspaces/iib:next-v4.12-ppc64le

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Che Operator gets stuck updating endpoint URLs when "legacy" hostname is used
4 participants