Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ YAML_PATCH_BIN := yaml-patch
YAML_PATCH := $(TOOLS_DIR)/$(YAML_PATCH_BIN)-$(YAML_PATCH_VER)
export YAML_PATCH # so hack scripts can use it

GOLANGCI_LINT_VER := 2.1.6
GOLANGCI_LINT_VER := 2.6.0
GOLANGCI_LINT_BIN := golangci-lint
GOLANGCI_LINT := $(TOOLS_GOBIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER)
GOLANGCI_LINT_FLAGS ?=
Expand Down
6 changes: 3 additions & 3 deletions hack/tools.checksums
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
controller-gen|GOARCH=amd64;GOOS=linux|21e5f3239666fc0c5e2d23c2a3a83fd655af40a969ede7a118b86832c35a829f
controller-gen|GOARCH=arm64;GOOS=darwin|2ca28be7185d9279ed82e3355529b0543938f392cb812add3f25a62196ed7441
controller-gen|GOARCH=arm64;GOOS=linux|a1a1f758435d05933c4b2f8c292f8ab2448e81a02c45f14dbd81c10e87ec4b20
golangci-lint|GOARCH=amd64;GOOS=linux|7009324a8aad93c1f84dce1c3cf61181bdd6b68e5f1b8b5d6971662258255050
golangci-lint|GOARCH=arm64;GOOS=darwin|96dc1dbbb686fc7982b9ea4b800f3d234a2d9fb78b0344f287e8d28ee11bc72b
golangci-lint|GOARCH=arm64;GOOS=linux|c51ff5b21be688b043baea44de7dd855cf07b855c14f0de405bfaf922b1d7634
golangci-lint|GOARCH=amd64;GOOS=linux|f0cdf40b6c161524898d79cad40fa92d7fde7d4a5ecfa07360937160cb61fb2b
golangci-lint|GOARCH=arm64;GOOS=darwin|2a2c09731f02f890aec506c2558c5eb67613aaf268806aa66956ee63858647fb
golangci-lint|GOARCH=arm64;GOOS=linux|be2ea9fc5ecf9a64b7d1291a3b62694edbff3b3d29fe566a3e43ef2e89d4556d
gotestsum|GOARCH=amd64;GOOS=linux|2e505a9368568aa7422e0a90ef77acc8807c0d3272ab81c7a69e3e8688d1cf65
gotestsum|GOARCH=arm64;GOOS=darwin|020be8d14358c7ac4155e296436057cf4b1f1232f8f8f3d71f22a0e7a5504340
gotestsum|GOARCH=arm64;GOOS=linux|2f8517768c2831750cb372e379404a059dbd20f2b1f79bcc235c4cab4540cb10
Expand Down
1 change: 0 additions & 1 deletion pkg/network/dialer_linux.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build linux
// +build linux

/*
Copyright 2024 The KCP Authors.
Expand Down
1 change: 0 additions & 1 deletion pkg/network/dialer_other.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build !linux
// +build !linux

/*
Copyright 2024 The KCP Authors.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ const (
PartitionValid conditionsv1alpha1.ConditionType = "PartitionValid"

// EndpointURLsReady is a condition for APIExportEndpointSlice that reflects the readiness of the URLs.
//
// Deprecated: This condition is deprecated and will be removed in a future release.
APIExportEndpointSliceURLsReady conditionsv1alpha1.ConditionType = "EndpointURLsReady"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ const (
PartitionValid conditionsv1alpha1.ConditionType = "PartitionValid"

// EndpointURLsReady is a condition for CachedResourceEndpointSlice that reflects the readiness of the URLs.
//
// Deprecated: This condition is deprecated and will be removed in a future release.
CachedResourceEndpointSliceURLsReady conditionsv1alpha1.ConditionType = "EndpointURLsReady"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const kcpBinariesDirEnvDir = "KCP_BINARIES_DIR"

// RunInProcessFunc instantiates the kcp server in process for easier debugging.
// It is here to decouple the rest of the code from kcp core dependencies.
//
// Deprecated: Use ContextRunInProcessFunc instead.
var RunInProcessFunc func(t TestingT, dataDir string, args []string) (<-chan struct{}, error)

Expand Down
42 changes: 37 additions & 5 deletions test/e2e/conformance/cross_logical_cluster_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package conformance
import (
"context"
"fmt"
"strings"
"testing"
"time"

Expand All @@ -27,6 +28,7 @@ import (
corev1 "k8s.io/api/core/v1"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand All @@ -45,6 +47,7 @@ import (
tenancyv1alpha1 "github.com/kcp-dev/sdk/apis/tenancy/v1alpha1"
kcpclientset "github.com/kcp-dev/sdk/client/clientset/versioned/cluster"
kcptesting "github.com/kcp-dev/sdk/testing"
kcptestinghelpers "github.com/kcp-dev/sdk/testing/helpers"

configcrds "github.com/kcp-dev/kcp/config/crds"
"github.com/kcp-dev/kcp/pkg/informer"
Expand Down Expand Up @@ -196,20 +199,20 @@ func TestCRDCrossLogicalClusterListPartialObjectMetadata(t *testing.T) {
t.Logf("Install a different sheriffs CRD into workspace %q", wsNormalCRD2)
bootstrapCRD(t, wsNormalCRD2, crdClusterClient.ApiextensionsV1().CustomResourceDefinitions(), sheriffCRD2)

apifixtures.CreateSheriff(ctx, t, dynamicClusterClient, wsNormalCRD1a, group, wsNormalCRD1a.String())
apifixtures.CreateSheriff(ctx, t, dynamicClusterClient, wsNormalCRD1b, group, wsNormalCRD1b.String())
createSheriff(ctx, t, dynamicClusterClient, wsNormalCRD1a, group)
createSheriff(ctx, t, dynamicClusterClient, wsNormalCRD1b, group)

apifixtures.CreateSheriffsSchemaAndExport(ctx, t, wsExport1a, kcpClusterClient, group, "export1")
apifixtures.BindToExport(ctx, t, wsExport1a, group, wsConsume1a, kcpClusterClient)
apifixtures.CreateSheriff(ctx, t, dynamicClusterClient, wsConsume1a, group, wsConsume1a.String())
createSheriff(ctx, t, dynamicClusterClient, wsConsume1a, group)

apifixtures.CreateSheriffsSchemaAndExport(ctx, t, wsExport1b, kcpClusterClient, group, "export1")
apifixtures.BindToExport(ctx, t, wsExport1b, group, wsConsume1b, kcpClusterClient)
apifixtures.CreateSheriff(ctx, t, dynamicClusterClient, wsConsume1b, group, wsConsume1b.String())
createSheriff(ctx, t, dynamicClusterClient, wsConsume1b, group)

apifixtures.CreateSheriffsSchemaAndExport(ctx, t, wsExport2, kcpClusterClient, group, "export2")
apifixtures.BindToExport(ctx, t, wsExport2, group, wsConsume2, kcpClusterClient)
apifixtures.CreateSheriff(ctx, t, dynamicClusterClient, wsConsume2, group, wsConsume2.String())
createSheriff(ctx, t, dynamicClusterClient, wsConsume2, group)

t.Logf("Trying to wildcard list with PartialObjectMetadata content-type and it should work")
rootShardMetadataClusterClient, err := metadataclient.NewDynamicMetadataClusterClientForConfig(rootShardConfig)
Expand Down Expand Up @@ -321,3 +324,32 @@ func TestBuiltInCrossLogicalClusterListPartialObjectMetadata(t *testing.T) {

require.Subset(t, sets.List[string](names), expected)
}

func createSheriff(
ctx context.Context,
t *testing.T,
dynamicClusterClient kcpdynamic.ClusterInterface,
clusterName logicalcluster.Path,
group string,
) {
t.Helper()

name := strings.ReplaceAll(clusterName.String(), ":", "-")

t.Logf("Creating %s/v1 sheriffs %s|default/%s", group, clusterName, name)

sheriffsGVR := schema.GroupVersionResource{Group: group, Resource: "sheriffs", Version: "v1"}

sheriff := &unstructured.Unstructured{}
sheriff.SetAPIVersion(group + "/v1")
sheriff.SetKind("Sheriff")
sheriff.SetName(name)

// CRDs are asynchronously served because they are informer based.
kcptestinghelpers.Eventually(t, func() (bool, string) {
if _, err := dynamicClusterClient.Cluster(clusterName).Resource(sheriffsGVR).Namespace("default").Create(ctx, sheriff, metav1.CreateOptions{}); err != nil {
return false, fmt.Sprintf("failed to create Sheriff %s|%s: %v", clusterName, name, err.Error())
}
return true, ""
}, wait.ForeverTestTimeout, time.Millisecond*100, "error creating Sheriff %s|%s", clusterName, name)
}
1 change: 1 addition & 0 deletions test/e2e/fixtures/apifixtures/sheriffs.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ func CreateSheriffsSchemaAndExport(

// CreateSheriff creates an instance of a Sheriff CustomResource in the logical cluster identified by clusterName, in
// the specific API group, and with the specified name.
//
// Deprecated: use local fixtures instead.
func CreateSheriff(
ctx context.Context,
Expand Down
52 changes: 38 additions & 14 deletions test/e2e/quota/quota_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package quota
import (
"context"
"fmt"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -314,15 +315,15 @@ func TestKubeQuotaNormalCRDs(t *testing.T) {
}, wait.ForeverTestTimeout, 100*time.Millisecond, "error waiting for ws %d quota to show usage in status", wsIndex)

t.Logf("Create 2 sheriffs to reach the quota limit")
apifixtures.CreateSheriff(ctx, t, dynamicClusterClient, ws, group, fmt.Sprintf("ws%d-1", wsIndex))
apifixtures.CreateSheriff(ctx, t, dynamicClusterClient, ws, group, fmt.Sprintf("ws%d-2", wsIndex))
createSheriff(ctx, t, dynamicClusterClient, ws, group, fmt.Sprintf("ws%d-1", wsIndex))
createSheriff(ctx, t, dynamicClusterClient, ws, group, fmt.Sprintf("ws%d-2", wsIndex))

t.Logf("Make sure quota is enforcing limits")
i := 0
sheriffsGVR := schema.GroupVersionResource{Group: group, Resource: "sheriffs", Version: "v1"}
kcptestinghelpers.Eventually(t, func() (bool, string) {
t.Logf("Trying to create a sheriff")
sheriff := NewSheriff(group, fmt.Sprintf("ws%d-%d", wsIndex, i))
sheriff := newSheriff(group, fmt.Sprintf("ws%d-%d", wsIndex, i))
i++
_, err := dynamicClusterClient.Cluster(ws).Resource(sheriffsGVR).Namespace("default").Create(ctx, sheriff, metav1.CreateOptions{})
return apierrors.IsForbidden(err), fmt.Sprintf("expected a forbidden error, got: %v", err)
Expand Down Expand Up @@ -461,15 +462,38 @@ func bootstrapCRD(
require.NoError(t, err, "error bootstrapping CRD %s in cluster %s", crd.Name, clusterName)
}

// NewSheriff returns a new *unstructured.Unstructured for a Sheriff with the given group and name.
func NewSheriff(group, name string) *unstructured.Unstructured {
return &unstructured.Unstructured{
Object: map[string]interface{}{
"apiVersion": group + "/v1",
"kind": "Sheriff",
"metadata": map[string]interface{}{
"name": name,
},
},
}
// newSheriff returns a new *unstructured.Unstructured for a Sheriff with the given group and name.
func newSheriff(group, name string) *unstructured.Unstructured {
sheriff := &unstructured.Unstructured{}
sheriff.SetAPIVersion(group + "/v1")
sheriff.SetKind("Sheriff")
sheriff.SetName(name)

return sheriff
}

func createSheriff(
ctx context.Context,
t *testing.T,
dynamicClusterClient kcpdynamic.ClusterInterface,
clusterName logicalcluster.Path,
group, name string,
) {
t.Helper()

name = strings.ReplaceAll(name, ":", "-")

t.Logf("Creating %s/v1 sheriffs %s|default/%s", group, clusterName, name)

sheriffsGVR := schema.GroupVersionResource{Group: group, Resource: "sheriffs", Version: "v1"}

sheriff := newSheriff(group, name)

// CRDs are asynchronously served because they are informer based.
kcptestinghelpers.Eventually(t, func() (bool, string) {
if _, err := dynamicClusterClient.Cluster(clusterName).Resource(sheriffsGVR).Namespace("default").Create(ctx, sheriff, metav1.CreateOptions{}); err != nil {
return false, fmt.Sprintf("failed to create Sheriff %s|%s: %v", clusterName, name, err.Error())
}
return true, ""
}, wait.ForeverTestTimeout, time.Millisecond*100, "error creating Sheriff %s|%s", clusterName, name)
}
36 changes: 33 additions & 3 deletions test/e2e/virtual/apiexport/virtualworkspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/sets"
Expand Down Expand Up @@ -603,11 +604,11 @@ func TestAPIExportPermissionClaims(t *testing.T) {

t.Logf("Bind sheriffs into %s and create initial sheriff", consumer1Path)
apifixtures.BindToExport(ctx, t, sheriffProviderPath, "wild.wild.west", consumer1Path, kcpClusterClient)
apifixtures.CreateSheriff(ctx, t, dynamicClusterClient, consumer1Path, "wild.wild.west", "in-vw-before")
createSheriff(ctx, t, dynamicClusterClient, consumer1Path, "wild.wild.west", "in-vw-before")

t.Logf("Bind sheriffs into %s and create initial sheriff", consumer2Path)
apifixtures.BindToExport(ctx, t, sheriffProviderPath, "wild.wild.west", consumer2Path, kcpClusterClient)
apifixtures.CreateSheriff(ctx, t, dynamicClusterClient, consumer2Path, "wild.wild.west", "not-in-vw")
createSheriff(ctx, t, dynamicClusterClient, consumer2Path, "wild.wild.west", "not-in-vw")

t.Logf("Create cowboys API Export in %v with permission claims to core resources and sheriffs provided by %v", claimerPath, sheriffProviderPath)
setUpServiceProviderWithPermissionClaims(ctx, t, dynamicClusterClient, kcpClusterClient, claimerPath, cfg, identityHash)
Expand Down Expand Up @@ -718,7 +719,7 @@ func TestAPIExportPermissionClaims(t *testing.T) {
}, wait.ForeverTestTimeout, 100*time.Millisecond, "expected to see more than 1 binding")

t.Logf("Creating a sheriff in %s", consumer1Path)
apifixtures.CreateSheriff(ctx, t, dynamicClusterClient, consumer1Path, "wild.wild.west", "in-vw")
createSheriff(ctx, t, dynamicClusterClient, consumer1Path, "wild.wild.west", "in-vw")

t.Logf("Verify that two sherrifs are eventually returned")
kcptestinghelpers.Eventually(t, func() (done bool, str string) {
Expand Down Expand Up @@ -1188,3 +1189,32 @@ func toJSON(t *testing.T, obj interface{}) string {
require.NoError(t, err)
return string(ret)
}

func createSheriff(
ctx context.Context,
t *testing.T,
dynamicClusterClient kcpdynamic.ClusterInterface,
clusterName logicalcluster.Path,
group, name string,
) {
t.Helper()

name = strings.ReplaceAll(name, ":", "-")

t.Logf("Creating %s/v1 sheriffs %s|default/%s", group, clusterName, name)

sheriffsGVR := schema.GroupVersionResource{Group: group, Resource: "sheriffs", Version: "v1"}

sheriff := &unstructured.Unstructured{}
sheriff.SetAPIVersion(group + "/v1")
sheriff.SetKind("Sheriff")
sheriff.SetName(name)

// CRDs are asynchronously served because they are informer based.
kcptestinghelpers.Eventually(t, func() (bool, string) {
if _, err := dynamicClusterClient.Cluster(clusterName).Resource(sheriffsGVR).Namespace("default").Create(ctx, sheriff, metav1.CreateOptions{}); err != nil {
return false, fmt.Sprintf("failed to create Sheriff %s|%s: %v", clusterName, name, err.Error())
}
return true, ""
}, wait.ForeverTestTimeout, time.Millisecond*100, "error creating Sheriff %s|%s", clusterName, name)
}
33 changes: 32 additions & 1 deletion test/e2e/watchcache/watchcache_enabled_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ import (

v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/rest"

kcpapiextensionsclientset "github.com/kcp-dev/client-go/apiextensions/client"
kcpdynamic "github.com/kcp-dev/client-go/dynamic"
kcpkubernetesclientset "github.com/kcp-dev/client-go/kubernetes"
"github.com/kcp-dev/logicalcluster/v3"
"github.com/kcp-dev/sdk/apis/core"
kcpclientset "github.com/kcp-dev/sdk/client/clientset/versioned/cluster"
kcptesting "github.com/kcp-dev/sdk/testing"
Expand Down Expand Up @@ -131,7 +133,7 @@ func TestWatchCacheEnabledForAPIBindings(t *testing.T) {

apifixtures.CreateSheriffsSchemaAndExport(ctx, t, wsExport1aPath, kcpClusterClient, group, "export1")
apifixtures.BindToExport(ctx, t, wsExport1aPath, group, wsConsume1aPath, kcpClusterClient)
apifixtures.CreateSheriff(ctx, t, dynamicKcpClusterClient, wsConsume1aPath, group, wsConsume1aPath.String())
createSheriff(ctx, t, dynamicKcpClusterClient, wsConsume1aPath, group, wsConsume1aPath.String())

sheriffsGVR := schema.GroupVersionResource{Group: group, Resource: "sheriffs", Version: "v1"}
t.Logf("Waiting until the watch cache is primed for %v for cluster %v", sheriffsGVR, wsConsume1aPath)
Expand Down Expand Up @@ -261,3 +263,32 @@ func assertWatchCacheIsPrimed(t *testing.T, fn func() error) {
return true, ""
}, wait.ForeverTestTimeout, time.Millisecond*200, "the watch cache hasn't been primed in the allotted time")
}

func createSheriff(
ctx context.Context,
t *testing.T,
dynamicClusterClient kcpdynamic.ClusterInterface,
clusterName logicalcluster.Path,
group, name string,
) {
t.Helper()

name = strings.ReplaceAll(name, ":", "-")

t.Logf("Creating %s/v1 sheriffs %s|default/%s", group, clusterName, name)

sheriffsGVR := schema.GroupVersionResource{Group: group, Resource: "sheriffs", Version: "v1"}

sheriff := &unstructured.Unstructured{}
sheriff.SetAPIVersion(group + "/v1")
sheriff.SetKind("Sheriff")
sheriff.SetName(name)

// CRDs are asynchronously served because they are informer based.
kcptestinghelpers.Eventually(t, func() (bool, string) {
if _, err := dynamicClusterClient.Cluster(clusterName).Resource(sheriffsGVR).Namespace("default").Create(ctx, sheriff, metav1.CreateOptions{}); err != nil {
return false, fmt.Sprintf("failed to create Sheriff %s|%s: %v", clusterName, name, err.Error())
}
return true, ""
}, wait.ForeverTestTimeout, time.Millisecond*100, "error creating Sheriff %s|%s", clusterName, name)
}