-
Notifications
You must be signed in to change notification settings - Fork 68
fix: identical endpoint name conflicts #1521
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com>
Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com>
controllers/controller/devworkspacerouting/solvers/basic_solver.go
Outdated
Show resolved
Hide resolved
Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com>
Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com>
Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com>
Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com>
Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com>
Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com>
Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com>
Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: akurinnoy, 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 |
Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com>
New changes are detected. LGTM label has been removed. |
@akurinnoy: The following test failed, say
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-sigs/prow repository. I understand the commands that are listed here. |
err := loadObjectFromFile("workspace-1", workspace, "test-devworkspace.yaml") | ||
assert.NoError(t, err, "Failed to load test workspace") | ||
workspace.SetUID(types.UID("uid-1")) | ||
workspace.SetNamespace("test-namespace") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nitpick: I see that loading objects and setting UID/Namespace are duplicated in most test methods.
Do you think extracting a small helper function for this might improve readability?
// Test for conflict in same namespace | ||
fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithObjects(otherWorkspaceSameNS).Build() | ||
handler := &WebhookHandler{Client: fakeClient} | ||
err = handler.validateEndpoints(context.TODO(), workspace) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, We might consider asserting on the specific error type
err = handler.validateEndpoints(context.TODO(), workspace) | |
err = handler.validateEndpoints(context.TODO(), workspace) | |
assert.ErrorAs(t, err, new(*solvers.ServiceConflictError)) |
workspace := &dwv2.DevWorkspace{} | ||
err := loadObjectFromFile("workspace-1", workspace, "test-devworkspace.yaml") | ||
assert.NoError(t, err, "Failed to load test workspace") | ||
workspace.SetUID(types.UID("uid-1")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, "uid-1"
is already a string and SetUID
expects a types.UID
, which is just a type alias for string
workspace.SetUID(types.UID("uid-1")) | |
workspace.SetUID("uid-1") |
} | ||
|
||
func (e *ServiceConflictError) Error() string { | ||
if e.WorkspaceName == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fallback appears to be unused. I checked usages in code, and all of them seem to populate WorkspaceName
.
Is it for backward compatibility of devworkspaces deployed by older versions?
I tested the PR with abovementioned steps and it seems to work as expected ✔️ |
What does this PR do?
What issues does this PR fix or reference?
This PR implements conflict detection and prevention at both the controller and webhook levels.
Is it tested? How?
Same-namespace conflict detection
oc wait --for=condition=Ready dw/endpoint-test-1 -n test-namespace --timeout=300s
Expected result:
Cross-name isolation
PR Checklist
/test v8-devworkspace-operator-e2e, v8-che-happy-path
to trigger)v8-devworkspace-operator-e2e
: DevWorkspace e2e testv8-che-happy-path
: Happy path for verification integration with Che