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

Add APIBinding controller, replace inheritFrom with APIBindings #755

Merged
merged 12 commits into from
Mar 25, 2022

Conversation

sttts
Copy link
Member

@sttts sttts commented Mar 22, 2022

Continues and replaces #702. All comments addressed, or follow-ups added to #417.

Also fixes #731.

Majority of the work by @ncdc, copied from #702.

Copy link
Contributor

@marun marun left a comment

Choose a reason for hiding this comment

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

22/28 files reviewed, need to take a break. Nothing major thus far, just trying to better understand the PR. Will follow up tomorrow.

pkg/apis/apis/v1alpha1/types.go Outdated Show resolved Hide resolved
pkg/apis/apis/v1alpha1/types.go Outdated Show resolved Hide resolved
pkg/apis/apis/v1alpha1/types.go Outdated Show resolved Hide resolved
pkg/apis/apis/v1alpha1/types.go Outdated Show resolved Hide resolved
pkg/apis/apis/v1alpha1/types.go Show resolved Hide resolved
pkg/reconciler/apibinding/apibinding_controller.go Outdated Show resolved Hide resolved
pkg/reconciler/apibinding/apibinding_controller.go Outdated Show resolved Hide resolved
Copy link
Contributor

@marun marun left a comment

Choose a reason for hiding this comment

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

Reviewing check-in. The last 3 files are big.

test/e2e/apibinding/apibinding_test.go Outdated Show resolved Hide resolved
test/e2e/apibinding/apibinding_test.go Outdated Show resolved Hide resolved
return ws.Status.Phase == tenancyv1alpha1.ClusterWorkspacePhaseReady
}, wait.ForeverTestTimeout, 100*time.Millisecond, "error waiting for source workspace to be ready")

server.Artifact(t, func() (runtime.Object, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

(No action required) I don't actually know what these artifact stanzas buy us. Does anyone actually use them?

Copy link
Member Author

Choose a reason for hiding this comment

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

+1

test/e2e/apibinding/apibinding_test.go Show resolved Hide resolved
_, err = kcpClients.Cluster(targetWorkspaceClusterName).ApisV1alpha1().APIBindings().Create(ctx, apiBinding, metav1.CreateOptions{})
require.NoError(t, err)

t.Logf("Make sure %s API group does NOT show up in workspace %q group discovery", wildwest.GroupName, sourceWorkspace.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

(No action required) Aha, so exporting a type doesn't require it to be installed in a workspace? And an apiresourceschema is basically a crd that isn't reconciled into an api without an apibinding?

Copy link
Member Author

Choose a reason for hiding this comment

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

A APIResourceSchema is like a snapshot (in time) of a CRD, but yes: it is not served in that workspace. The objects are in the consumer workspaces.

test/e2e/apibinding/apibinding_test.go Show resolved Hide resolved
@sttts sttts force-pushed the sttts-apibinding-controller branch from 29a75b5 to a506143 Compare March 23, 2022 16:46
Copy link
Contributor

@marun marun left a comment

Choose a reason for hiding this comment

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

How to ensure coverage of corner-cases for apiextensions changes?

next: reviewing apibinding reconcile

pkg/server/apiextensions.go Show resolved Hide resolved
pkg/server/apiextensions.go Show resolved Hide resolved
pkg/server/apiextensions.go Show resolved Hide resolved
pkg/server/apiextensions.go Show resolved Hide resolved
pkg/server/apiextensions.go Show resolved Hide resolved
pkg/server/apiextensions.go Show resolved Hide resolved
pkg/server/apiextensions.go Outdated Show resolved Hide resolved
pkg/server/apiextensions.go Outdated Show resolved Hide resolved
pkg/server/apiextensions.go Show resolved Hide resolved
@sttts
Copy link
Member Author

sttts commented Mar 23, 2022

How to ensure coverage of corner-cases for apiextensions changes?

Schema evolution is not yet part of the implementation.

Copy link
Contributor

@marun marun left a comment

Choose a reason for hiding this comment

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

Phew, apibinding_reconcile reviewed. Only its unit testing to go.

It appears there may be conflicts between wanting to retry while also wanting to set status? These conflicts don't surface in the current unit tests because they involve the controller and there are no tests of the controller and the error paths. Maybe refactor to ensure future conflicts of this nature can be caught by tests rather than in review?

pkg/reconciler/apibinding/apibinding_reconcile.go Outdated Show resolved Hide resolved
pkg/reconciler/apibinding/apibinding_reconcile.go Outdated Show resolved Hide resolved
pkg/reconciler/apibinding/apibinding_reconcile.go Outdated Show resolved Hide resolved
pkg/reconciler/apibinding/apibinding_reconcile.go Outdated Show resolved Hide resolved
@marun
Copy link
Contributor

marun commented Mar 23, 2022

How to ensure coverage of corner-cases for apiextensions changes?

Schema evolution is not yet part of the implementation.

I'm talking about the file pkg/server/apiextensions.go. There appear to be non-trivial changes but no added test coverage.

@sttts
Copy link
Member Author

sttts commented Mar 23, 2022

Something about the precedence would make sense. On the other hand, I would prefer to build something that prevent conflicts in the first place, see #748.

Copy link
Contributor

@marun marun left a comment

Choose a reason for hiding this comment

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

Phew, apibinding_reconcile reviewed. Only its unit testing to go.

It appears there may be conflicts between wanting to retry while also wanting to set status? The methods in which the problems appear are complicated enough that discovering these kinds of errors in test would be challenging if not possible. Not suggesting that the controller requires a refactor in this PR, but I would hope for future iteration towards a more testable implementation.

pkg/reconciler/apibinding/apibinding_reconcile_test.go Outdated Show resolved Hide resolved
return
}

require.Equal(t, status, tc.wantReconcileStatus)
Copy link
Contributor

Choose a reason for hiding this comment

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

(No action required) Maybe use RequireNoDiff (moving to test/common first) to ensure better error messages when status differs?

}

func TestWorkspaceAPIExportReferenceReconciler(t *testing.T) {
tests := map[string]struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

(No action required) The complexity of test case definition suggests that the functionality under test would benefit from refactoring for testability. If not in this PR, then in the near future.

return b
}

func (b *bindingBuilder) WithWorkspaceReference(workspaceName, exportName string) *bindingBuilder {
Copy link
Contributor

Choose a reason for hiding this comment

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

(No action required) I think part of the advantage of builders is removing the need to parametrize them where possible. Ideally the cases would be as simple as WithSomeWorkspaceReference and WithAnotherWorkspaceReference with correspondence across builders (i.e. SomeWorkspace and AnotherWorkspace constants). This minimizes the details in the test cases to the minimum (Some, Another, Different, etc) required to clearly indicate intent.

@sttts
Copy link
Member Author

sttts commented Mar 24, 2022

How to ensure coverage of corner-cases for apiextensions changes?

Added to #417 as follow-up. The whole rebinding is not done yet.

@sttts
Copy link
Member Author

sttts commented Mar 24, 2022

I'm talking about the file pkg/server/apiextensions.go. There appear to be non-trivial changes but no added test coverage.

It is tested, it is the core of the APIBindings being available as types in workspaces. Same for CRD, both custom and system CRD. This is used everywhere.

@sttts sttts force-pushed the sttts-apibinding-controller branch 3 times, most recently from cf71cd0 to aa05066 Compare March 24, 2022 16:02
Copy link
Contributor

@marun marun left a comment

Choose a reason for hiding this comment

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

LGTM

@sttts sttts force-pushed the sttts-apibinding-controller branch from 0d48633 to ad73cbf Compare March 25, 2022 07:23
@sttts sttts enabled auto-merge March 25, 2022 07:23
@sttts sttts merged commit 7901aea into kcp-dev:main Mar 25, 2022
@sttts sttts deleted the sttts-apibinding-controller branch March 25, 2022 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Server is never /readyz after changing the schema of a CRD we bootstrap
3 participants