Repository navigation
🤖 fix: finish the control plane hold and cleanup record follow-ups of #353 #410
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
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
7c554cc
test: a provider delete pass under the control plane hold ends at the…
ThomasK33 a8a7d15
fix: end a provider delete pass under the control plane hold at the h…
ThomasK33 6f66471
test: count a CoderMCPServer released without a delete in Coder (#353)
ThomasK33 fb7b348
fix: count CoderMCPServer releases without a delete in coder_k8s_clea…
ThomasK33 27eea7d
test: pin the per-kind dependent count of a held control plane for ea…
ThomasK33 c481e35
test: a key record takes the create time that the controller stamps a…
ThomasK33 320e5eb
fix: rewrite a key cleanup record whose create time is older than sta…
ThomasK33 d033519
test: a pending provider create keeps its record after a deployment s…
ThomasK33 38056f2
fix: check the deployment of a provider record without an ID before a…
ThomasK33 6b91172
test: a control plane without operator access or without its Coder De…
ThomasK33 2184060
fix: hold a deleted control plane only while it has operator access a…
ThomasK33 bbfe848
docs: name MCP servers in the control plane hold, and list the new ca…
ThomasK33 b92c573
docs: scope the operator access retry to a control plane that is not …
ThomasK33 a094479
Merge remote-tracking branch 'origin/main' into issue-353-cleanup-fol…
ThomasK33 89b6930
test: a control plane holds without its Coder Deployment, also when i…
ThomasK33 910867b
fix: keep the control plane hold when its Coder Deployment is missing…
ThomasK33 89ce952
test: a control plane that lost operator access before its deletion d…
ThomasK33 a417651
Merge remote-tracking branch 'origin/main' into issue-353-cleanup-fol…
ThomasK33 9edc693
Merge remote-tracking branch 'origin/main' into pr410-r3
ThomasK33 383d0d4
fix: keep the control plane hold without operator access (#353)
ThomasK33 902e888
Merge remote-tracking branch 'origin/main' into pr410-r3
ThomasK33 822a8c1
docs: drop the no-operator-access hold claim from the keys how-to (#353)
ThomasK33 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
internal/controller/coderaiprovider_delete_internal_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| package controller | ||
|
|
||
| import ( | ||
| "context" | ||
| "net/http" | ||
| "net/http/httptest" | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/google/uuid" | ||
| "github.com/stretchr/testify/require" | ||
| corev1 "k8s.io/api/core/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/apimachinery/pkg/runtime" | ||
| clientgoscheme "k8s.io/client-go/kubernetes/scheme" | ||
| "sigs.k8s.io/controller-runtime/pkg/client/fake" | ||
|
|
||
| coderv1alpha1 "github.com/coder/coder-k8s/api/v1alpha1" | ||
| ) | ||
|
|
||
| // #384 follow-up 4 for providers: a delete pass under the control plane hold | ||
| // ends at the hold end, also when Coder does not answer, and its retry counts | ||
| // from the end of the pass. Here the hold ends in 5 s and Coder hangs on the | ||
| // DELETE, whose own request timeout is 30 s. | ||
| func TestAIProviderDeleteUnderHoldEndsAtHoldEnd(t *testing.T) { | ||
| t.Parallel() | ||
| coder := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) { | ||
| <-r.Context().Done() | ||
| })) | ||
| t.Cleanup(coder.Close) | ||
|
|
||
| scheme := runtime.NewScheme() | ||
| require.NoError(t, clientgoscheme.AddToScheme(scheme)) | ||
| require.NoError(t, coderv1alpha1.AddToScheme(scheme)) | ||
| deleted := metav1.NewTime(time.Now().Add(5*time.Second - controlPlaneDependentHold)) | ||
| controlPlane := &coderv1alpha1.CoderControlPlane{ObjectMeta: metav1.ObjectMeta{ | ||
| Name: "coder", Namespace: "ns", UID: "cp-uid", DeletionTimestamp: &deleted, Finalizers: []string{workspaceRBACFinalizer}, | ||
| }} | ||
| controlPlane.Status.URL = coder.URL | ||
| controlPlane.Status.OperatorAccessReady = true | ||
| controlPlane.Status.OperatorTokenSecretRef = &coderv1alpha1.SecretKeySelector{Name: "coder-operator-token"} | ||
| token := &corev1.Secret{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: "coder-operator-token", Namespace: "ns", | ||
| OwnerReferences: []metav1.OwnerReference{*metav1.NewControllerRef(controlPlane, coderv1alpha1.GroupVersion.WithKind("CoderControlPlane"))}, | ||
| }, | ||
| Data: map[string][]byte{coderv1alpha1.DefaultTokenSecretKey: []byte("token")}, | ||
| } | ||
| namespace := &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: "ns"}} | ||
| c := fake.NewClientBuilder().WithScheme(scheme).WithObjects(controlPlane, token, namespace).Build() | ||
| r := &CoderAIProviderReconciler{Client: c, APIReader: c, Scheme: scheme, OperatorNamespace: "coder-system"} | ||
| held, err := controlPlaneHolds(context.Background(), r.Client, controlPlane, time.Now()) | ||
| require.NoError(t, err) | ||
| require.True(t, held, "assertion failed: the test needs a control plane that holds") | ||
|
|
||
| provider := &coderv1alpha1.CoderAIProvider{ObjectMeta: metav1.ObjectMeta{Name: "openai", Namespace: "ns", UID: "provider-uid"}} | ||
| provider.Spec.ControlPlaneRef.Name = "coder" | ||
| provider.Status.ProviderID = uuid.NewString() | ||
| start := time.Now() | ||
| release, step, err := r.deleteStep(context.Background(), provider) | ||
| require.NoError(t, err) | ||
| require.Less(t, time.Since(start), 15*time.Second, "the pass ends at the hold end, not at the 30 s request timeout") | ||
| require.False(t, release, "a pass under the hold never releases without a delete") | ||
| require.NotNil(t, step) | ||
| require.Equal(t, "CoderUnavailable", step.reason) | ||
| // The requeue counts from the end of the pass: the time left to the hold | ||
| // end, which is about 0 here, plus 1 s (controlPlaneHoldRequeue). | ||
| require.LessOrEqual(t, step.requeue, 2*time.Second, "the next pass runs right after the hold end") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.