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

Upgrading deps to k8s 1.27 and adding 1.27 to test matrix #763

Merged
merged 8 commits into from
May 25, 2023
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 .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
strategy:
fail-fast: false
matrix:
k8s-version: ['v1.20.7', 'v1.21.2', 'v1.22.4', 'v1.23.6', 'v1.24.7', 'v1.25.3', 'v1.26.3']
k8s-version: ['v1.20.7', 'v1.21.2', 'v1.22.4', 'v1.23.6', 'v1.24.7', 'v1.25.3', 'v1.26.3', 'v1.27.2']
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ apidocs-gen: ## Download crdoc locally if necessary.

GINKGO = $(shell pwd)/bin/ginkgo
ginkgo: ## Download ginkgo locally if necessary.
$(call go-install-tool,$(GINKGO),github.com/onsi/ginkgo/ginkgo@v1.16.5)
$(call go-install-tool,$(GINKGO),github.com/onsi/ginkgo/v2/ginkgo@v2.9.5)

CT = $(shell pwd)/bin/ct
ct: ## Download ct locally if necessary.
Expand Down
6 changes: 3 additions & 3 deletions api/v1alpha1/conversion_hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ func (in *Tenant) ConvertTo(dstRaw conversion.Hub) error {
dst.Spec.ServiceOptions.AllowedServices = &api.AllowedServices{}
}

dst.Spec.ServiceOptions.AllowedServices.NodePort = pointer.BoolPtr(val)
dst.Spec.ServiceOptions.AllowedServices.NodePort = pointer.Bool(val)
}

enableExternalName, ok := annotations[enableExternalNameAnnotation]
Expand All @@ -312,7 +312,7 @@ func (in *Tenant) ConvertTo(dstRaw conversion.Hub) error {
dst.Spec.ServiceOptions.AllowedServices = &api.AllowedServices{}
}

dst.Spec.ServiceOptions.AllowedServices.ExternalName = pointer.BoolPtr(val)
dst.Spec.ServiceOptions.AllowedServices.ExternalName = pointer.Bool(val)
}

loadBalancerService, ok := annotations[enableLoadBalancerAnnotation]
Expand All @@ -330,7 +330,7 @@ func (in *Tenant) ConvertTo(dstRaw conversion.Hub) error {
dst.Spec.ServiceOptions.AllowedServices = &api.AllowedServices{}
}

dst.Spec.ServiceOptions.AllowedServices.LoadBalancer = pointer.BoolPtr(val)
dst.Spec.ServiceOptions.AllowedServices.LoadBalancer = pointer.Bool(val)
}
// Status
dst.Status = capsulev1beta1.TenantStatus{
Expand Down
6 changes: 3 additions & 3 deletions api/v1alpha1/conversion_hub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ func generateTenantsSpecs() (Tenant, capsulev1beta1.Tenant) {
v1beta1ServiceOptions := &api.ServiceOptions{
AdditionalMetadata: v1beta1AdditionalMetadataSpec,
AllowedServices: &api.AllowedServices{
NodePort: pointer.BoolPtr(false),
ExternalName: pointer.BoolPtr(false),
LoadBalancer: pointer.BoolPtr(false),
NodePort: pointer.Bool(false),
ExternalName: pointer.Bool(false),
LoadBalancer: pointer.Bool(false),
},
ExternalServiceIPs: &api.ExternalServiceIPsSpec{
Allowed: []api.AllowedIP{"192.168.0.1"},
Expand Down
5 changes: 3 additions & 2 deletions api/v1beta2/tenantresource_global.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ type GlobalTenantResourceStatus struct {

type ProcessedItems []ObjectReferenceStatus

func (p *ProcessedItems) AsSet() sets.String {
set := sets.NewString()
func (p *ProcessedItems) AsSet() sets.Set[string] {
set := sets.New[string]()

for _, i := range *p {
set.Insert(i.String())
}
Expand Down
1,431 changes: 714 additions & 717 deletions charts/capsule/crds/tenant-crd.yaml

Large diffs are not rendered by default.

842 changes: 420 additions & 422 deletions config/crd/bases/capsule.clastix.io_tenants.yaml

Large diffs are not rendered by default.

144 changes: 72 additions & 72 deletions config/install.yaml

Large diffs are not rendered by default.

14 changes: 5 additions & 9 deletions controllers/config/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,14 @@ import (
)

type Manager struct {
Log logr.Logger
Client client.Client
}

// InjectClient injects the Client interface, required by the Runnable interface.
func (c *Manager) InjectClient(client client.Client) error {
c.Client = client
client client.Client

return nil
Log logr.Logger
}

func (c *Manager) SetupWithManager(mgr ctrl.Manager, configurationName string) error {
c.client = mgr.GetClient()

return ctrl.NewControllerManagedBy(mgr).
For(&capsulev1beta2.CapsuleConfiguration{}, utils.NamesMatchingPredicate(configurationName)).
Complete(c)
Expand All @@ -38,7 +34,7 @@ func (c *Manager) SetupWithManager(mgr ctrl.Manager, configurationName string) e
func (c *Manager) Reconcile(ctx context.Context, request reconcile.Request) (res reconcile.Result, err error) {
c.Log.Info("CapsuleConfiguration reconciliation started", "request.name", request.Name)

cfg := configuration.NewCapsuleConfiguration(ctx, c.Client, request.Name)
cfg := configuration.NewCapsuleConfiguration(ctx, c.client, request.Name)
// Validating the Capsule Configuration options
if _, err = cfg.ProtectedNamespaceRegexp(); err != nil {
panic(errors.Wrap(err, "Invalid configuration for protected Namespace regex"))
Expand Down
12 changes: 2 additions & 10 deletions controllers/rbac/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"

capsulev1beta2 "github.com/clastix/capsule/api/v1beta2"
"github.com/clastix/capsule/controllers/utils"
Expand All @@ -32,13 +31,6 @@ type Manager struct {
Configuration configuration.Configuration
}

// InjectClient injects the Client interface, required by the Runnable interface.
func (r *Manager) InjectClient(c client.Client) error {
r.Client = c

return nil
}

func (r *Manager) SetupWithManager(ctx context.Context, mgr ctrl.Manager, configurationName string) (err error) {
namesPredicate := utils.NamesMatchingPredicate(ProvisionerRoleName, DeleterRoleName)

Expand All @@ -51,8 +43,8 @@ func (r *Manager) SetupWithManager(ctx context.Context, mgr ctrl.Manager, config

crbErr := ctrl.NewControllerManagedBy(mgr).
For(&rbacv1.ClusterRoleBinding{}, namesPredicate).
Watches(source.NewKindWithCache(&capsulev1beta2.CapsuleConfiguration{}, mgr.GetCache()), handler.Funcs{
UpdateFunc: func(updateEvent event.UpdateEvent, limitingInterface workqueue.RateLimitingInterface) {
Watches(&capsulev1beta2.CapsuleConfiguration{}, handler.Funcs{
UpdateFunc: func(ctx context.Context, updateEvent event.UpdateEvent, limitingInterface workqueue.RateLimitingInterface) {
if updateEvent.ObjectNew.GetName() == configurationName {
if crbErr := r.EnsureClusterRoleBindings(ctx); crbErr != nil {
r.Log.Error(err, "cannot update ClusterRoleBinding upon CapsuleConfiguration update")
Expand Down
9 changes: 4 additions & 5 deletions controllers/resources/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/handler"
ctrllog "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"

capsulev1beta2 "github.com/clastix/capsule/api/v1beta2"
)
Expand All @@ -30,11 +29,11 @@ type Global struct {
processor Processor
}

func (r *Global) enqueueRequestFromTenant(object client.Object) (reqs []reconcile.Request) {
func (r *Global) enqueueRequestFromTenant(ctx context.Context, object client.Object) (reqs []reconcile.Request) {
tnt := object.(*capsulev1beta2.Tenant) //nolint:forcetypeassert

resList := capsulev1beta2.GlobalTenantResourceList{}
if err := r.client.List(context.Background(), &resList); err != nil {
if err := r.client.List(ctx, &resList); err != nil {
return nil
}

Expand Down Expand Up @@ -70,7 +69,7 @@ func (r *Global) SetupWithManager(mgr ctrl.Manager) error {

return ctrl.NewControllerManagedBy(mgr).
For(&capsulev1beta2.GlobalTenantResource{}).
Watches(&source.Kind{Type: &capsulev1beta2.Tenant{}}, handler.EnqueueRequestsFromMapFunc(r.enqueueRequestFromTenant)).
Watches(&capsulev1beta2.Tenant{}, handler.EnqueueRequestsFromMapFunc(r.enqueueRequestFromTenant)).
Complete(r)
}

Expand Down Expand Up @@ -175,7 +174,7 @@ func (r *Global) reconcileNormal(ctx context.Context, tntResource *capsulev1beta
return reconcile.Result{}, err
}

if r.processor.HandlePruning(ctx, tntResource.Status.ProcessedItems.AsSet(), processedItems) {
if r.processor.HandlePruning(ctx, tntResource.Status.ProcessedItems.AsSet(), sets.Set[string](processedItems)) {
tntResource.Status.ProcessedItems = make([]capsulev1beta2.ObjectReferenceStatus, 0, len(processedItems))

for _, item := range processedItems.List() {
Expand Down
2 changes: 1 addition & 1 deletion controllers/resources/namespaced.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (r *Namespaced) reconcileNormal(ctx context.Context, tntResource *capsulev1
return reconcile.Result{}, err
}

if r.processor.HandlePruning(ctx, tntResource.Status.ProcessedItems.AsSet(), processedItems) {
if r.processor.HandlePruning(ctx, tntResource.Status.ProcessedItems.AsSet(), sets.Set[string](processedItems)) {
tntResource.Status.ProcessedItems = make([]capsulev1beta2.ObjectReferenceStatus, 0, len(processedItems))

for _, item := range processedItems.List() {
Expand Down
2 changes: 1 addition & 1 deletion controllers/resources/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type Processor struct {
client client.Client
}

func (r *Processor) HandlePruning(ctx context.Context, current, desired sets.String) (updateStatus bool) {
func (r *Processor) HandlePruning(ctx context.Context, current, desired sets.Set[string]) (updateStatus bool) {
log := ctrllog.FromContext(ctx)

diff := current.Difference(desired)
Expand Down
6 changes: 0 additions & 6 deletions controllers/servicelabels/abstract.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ type abstractServiceLabelsReconciler struct {
log logr.Logger
}

func (r *abstractServiceLabelsReconciler) InjectClient(c client.Client) error {
r.client = c

return nil
}

func (r *abstractServiceLabelsReconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.Result, error) {
tenant, err := r.getTenant(ctx, request.NamespacedName, r.client)
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions controllers/servicelabels/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ type EndpointsLabelsReconciler struct {

func (r *EndpointsLabelsReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager) error {
r.abstractServiceLabelsReconciler = abstractServiceLabelsReconciler{
obj: &corev1.Endpoints{},
log: r.Log,
obj: &corev1.Endpoints{},
client: mgr.GetClient(),
log: r.Log,
}

return ctrl.NewControllerManagedBy(mgr).
Expand Down
3 changes: 2 additions & 1 deletion controllers/servicelabels/endpoint_slices.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ type EndpointSlicesLabelsReconciler struct {

func (r *EndpointSlicesLabelsReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager) error {
r.abstractServiceLabelsReconciler = abstractServiceLabelsReconciler{
log: r.Log,
client: mgr.GetClient(),
log: r.Log,
}

switch {
Expand Down
5 changes: 3 additions & 2 deletions controllers/servicelabels/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ type ServicesLabelsReconciler struct {

func (r *ServicesLabelsReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager) error {
r.abstractServiceLabelsReconciler = abstractServiceLabelsReconciler{
obj: &corev1.Service{},
log: r.Log,
obj: &corev1.Service{},
client: mgr.GetClient(),
log: r.Log,
}

return ctrl.NewControllerManagedBy(mgr).
Expand Down
4 changes: 2 additions & 2 deletions controllers/tenant/namespaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (r *Manager) ensureNamespaceCount(ctx context.Context, tenant *capsulev1bet

found.Status.Size = tenant.Status.Size

return r.Client.Status().Update(ctx, found, &client.UpdateOptions{})
return r.Client.Status().Update(ctx, found, &client.SubResourceUpdateOptions{})
})
}

Expand All @@ -176,7 +176,7 @@ func (r *Manager) collectNamespaces(ctx context.Context, tenant *capsulev1beta2.
_, err = controllerutil.CreateOrUpdate(ctx, r.Client, tenant.DeepCopy(), func() error {
tenant.AssignNamespaces(list.Items)

return r.Client.Status().Update(ctx, tenant, &client.UpdateOptions{})
return r.Client.Status().Update(ctx, tenant, &client.SubResourceUpdateOptions{})
})

return
Expand Down
13 changes: 6 additions & 7 deletions controllers/tls/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"

"github.com/clastix/capsule/controllers/utils"
"github.com/clastix/capsule/pkg/cert"
Expand All @@ -49,7 +48,7 @@ type Reconciler struct {
}

func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {
enqueueFn := handler.EnqueueRequestsFromMapFunc(func(client.Object) []reconcile.Request {
enqueueFn := handler.EnqueueRequestsFromMapFunc(func(context.Context, client.Object) []reconcile.Request {
return []reconcile.Request{
{
NamespacedName: types.NamespacedName{
Expand All @@ -62,13 +61,13 @@ func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {

return ctrl.NewControllerManagedBy(mgr).
For(&corev1.Secret{}, utils.NamesMatchingPredicate(r.Configuration.TLSSecretName())).
Watches(source.NewKindWithCache(&admissionregistrationv1.ValidatingWebhookConfiguration{}, mgr.GetCache()), enqueueFn, builder.WithPredicates(predicate.NewPredicateFuncs(func(object client.Object) bool {
Watches(&admissionregistrationv1.ValidatingWebhookConfiguration{}, enqueueFn, builder.WithPredicates(predicate.NewPredicateFuncs(func(object client.Object) bool {
return object.GetName() == r.Configuration.ValidatingWebhookConfigurationName()
}))).
Watches(source.NewKindWithCache(&admissionregistrationv1.MutatingWebhookConfiguration{}, mgr.GetCache()), enqueueFn, builder.WithPredicates(predicate.NewPredicateFuncs(func(object client.Object) bool {
Watches(&admissionregistrationv1.MutatingWebhookConfiguration{}, enqueueFn, builder.WithPredicates(predicate.NewPredicateFuncs(func(object client.Object) bool {
return object.GetName() == r.Configuration.MutatingWebhookConfigurationName()
}))).
Watches(source.NewKindWithCache(&apiextensionsv1.CustomResourceDefinition{}, mgr.GetCache()), enqueueFn, builder.WithPredicates(predicate.NewPredicateFuncs(func(object client.Object) bool {
Watches(&apiextensionsv1.CustomResourceDefinition{}, enqueueFn, builder.WithPredicates(predicate.NewPredicateFuncs(func(object client.Object) bool {
return object.GetName() == r.Configuration.TenantCRDName()
}))).
Complete(r)
Expand Down Expand Up @@ -235,8 +234,8 @@ func (r *Reconciler) updateTenantCustomResourceDefinition(ctx context.Context, n
Service: &apiextensionsv1.ServiceReference{
Namespace: r.Namespace,
Name: "capsule-webhook-service",
Path: pointer.StringPtr("/convert"),
Port: pointer.Int32Ptr(443),
Path: pointer.String("/convert"),
Port: pointer.Int32(443),
},
CABundle: caBundle,
},
Expand Down
Loading