Skip to content

Commit

Permalink
skip failing e2e, add telepresence to integration
Browse files Browse the repository at this point in the history
  • Loading branch information
czeslavo committed Feb 21, 2025
1 parent 43dec4c commit 6c45411
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 412 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,8 @@ test.crds-validation.pretty:
$(MAKE) _test.envtest GOTESTSUM_FORMAT=testname ENVTEST_TEST_PATHS=./test/crdsvalidation/...

.PHONY: _test.integration
_test.integration: gotestsum
_test.integration: gotestsum download.telepresence
PATH=$(PROJECT_DIR)/bin:$(PATH) \
GOFLAGS=$(GOFLAGS) \
GOTESTSUM_FORMAT=$(GOTESTSUM_FORMAT) \
$(GOTESTSUM) -- $(GOTESTFLAGS) \
Expand Down
19 changes: 0 additions & 19 deletions config/rbac/role/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ rules:
- get
- list
- watch
- apiGroups:
- ""
resources:
- serviceaccounts
verbs:
- delete
- apiGroups:
- ""
resources:
Expand All @@ -63,12 +57,6 @@ rules:
- get
- patch
- update
- apiGroups:
- admissionregistration.k8s.io
resources:
- validatingwebhookconfigurations
verbs:
- delete
- apiGroups:
- apiextensions.k8s.io
resources:
Expand Down Expand Up @@ -442,10 +430,3 @@ rules:
- patch
- update
- watch
- apiGroups:
- rbac.authorization.k8s.io
resources:
- clusterrolebindings
- clusterroles
verbs:
- delete
122 changes: 0 additions & 122 deletions pkg/utils/kubernetes/reduce/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@ package reduce

import (
"github.com/samber/lo"
admregv1 "k8s.io/api/admissionregistration/v1"
appsv1 "k8s.io/api/apps/v1"
autoscalingv2 "k8s.io/api/autoscaling/v2"
corev1 "k8s.io/api/core/v1"
discoveryv1 "k8s.io/api/discovery/v1"
networkingv1 "k8s.io/api/networking/v1"
policyv1 "k8s.io/api/policy/v1"
rbacv1 "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

operatorv1beta1 "github.com/kong/gateway-operator/api/v1beta1"
"github.com/kong/gateway-operator/controller/konnect/constraints"
"github.com/kong/gateway-operator/pkg/consts"

configurationv1alpha1 "github.com/kong/kubernetes-configuration/api/configuration/v1alpha1"
konnectv1alpha1 "github.com/kong/kubernetes-configuration/api/konnect/v1alpha1"
Expand Down Expand Up @@ -48,102 +45,6 @@ func filterSecrets(secrets []corev1.Secret) []corev1.Secret {
return append(secrets[:toFilter], secrets[toFilter+1:]...)
}

// -----------------------------------------------------------------------------
// Filter functions - ServiceAccounts
// -----------------------------------------------------------------------------

// filterServiceAccounts filters out the ServiceAccount to be kept and returns
// all the ServiceAccounts to be deleted.
// The filtered-out ServiceAccount is decided as follows:
// 1. creationTimestamp (older is better)
func filterServiceAccounts(serviceAccounts []corev1.ServiceAccount) []corev1.ServiceAccount {
if len(serviceAccounts) < 2 {
return []corev1.ServiceAccount{}
}

toFilter := 0
for i, serviceAccount := range serviceAccounts {
if serviceAccount.CreationTimestamp.Before(&serviceAccounts[toFilter].CreationTimestamp) {
toFilter = i
}
}

return append(serviceAccounts[:toFilter], serviceAccounts[toFilter+1:]...)
}

// -----------------------------------------------------------------------------
// Filter functions - ClusterRoles
// -----------------------------------------------------------------------------

// filterClusterRoles filters out the ClusterRole to be kept and returns
// all the ClusterRoles to be deleted.
// The filtered-out ClusterRole is decided as follows:
// 1. creationTimestamp (newer is better, because newer ClusterRoles can contain new policy rules)
func filterClusterRoles(clusterRoles []rbacv1.ClusterRole) []rbacv1.ClusterRole {
if len(clusterRoles) == 1 {
return []rbacv1.ClusterRole{}
}

best := 0
for i, cr := range clusterRoles {
if cr.CreationTimestamp.After(clusterRoles[best].CreationTimestamp.Time) {
best = i
}
}

return append(clusterRoles[:best], clusterRoles[best+1:]...)
}

// -----------------------------------------------------------------------------
// Filter functions - ClusterRoleBindings
// -----------------------------------------------------------------------------

// filterClusterRoleBindings filters out the ClusterRoleBinding to be kept and returns
// all the ClusterRoleBindings to be deleted.
// The filtered-out ClusterRoleBinding is decided as follows:
// 1. creationTimestamp (older is better)
func filterClusterRoleBindings(clusterRoleBindings []rbacv1.ClusterRoleBinding) []rbacv1.ClusterRoleBinding {
if len(clusterRoleBindings) < 2 {
return []rbacv1.ClusterRoleBinding{}
}

oldestWithManagedByLabels := -1
oldestLegacy := -1
for i, clusterRoleBinding := range clusterRoleBindings {
labels := clusterRoleBinding.GetLabels()

_, okManagedBy := labels[consts.GatewayOperatorManagedByLabel]
_, okManagedByNs := labels[consts.GatewayOperatorManagedByNamespaceLabel]
_, okManagedByName := labels[consts.GatewayOperatorManagedByNameLabel]
if okManagedBy && okManagedByNs && okManagedByName {
if oldestWithManagedByLabels == -1 {
oldestWithManagedByLabels = i
continue
}

if clusterRoleBinding.CreationTimestamp.Before(&clusterRoleBindings[oldestWithManagedByLabels].CreationTimestamp) {
oldestWithManagedByLabels = i
}
continue
}

if oldestLegacy == -1 {
oldestLegacy = i
continue
}

if clusterRoleBinding.CreationTimestamp.Before(&clusterRoleBindings[oldestLegacy].CreationTimestamp) {
oldestLegacy = i
}
continue
}

if oldestWithManagedByLabels != -1 {
return append(clusterRoleBindings[:oldestWithManagedByLabels], clusterRoleBindings[oldestWithManagedByLabels+1:]...)
}
return append(clusterRoleBindings[:oldestLegacy], clusterRoleBindings[oldestLegacy+1:]...)
}

// -----------------------------------------------------------------------------
// Filter functions - Deployments
// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -323,29 +224,6 @@ func FilterPodDisruptionBudgets(pdbs []policyv1.PodDisruptionBudget) []policyv1.
return append(pdbs[:best], pdbs[best+1:]...)
}

// -----------------------------------------------------------------------------
// Filter functions - ValidatingWebhookConfigurations
// -----------------------------------------------------------------------------

// filterValidatingWebhookConfigurations filters out the ValidatingWebhookConfigurations
// to be kept and returns all the ValidatingWebhookConfigurations to be deleted.
// The following criteria are used:
// 1. creationTimestamp (newer is better, because newer ValidatingWebhookConfiguration can contain new rules)
func filterValidatingWebhookConfigurations(vwcs []admregv1.ValidatingWebhookConfiguration) []admregv1.ValidatingWebhookConfiguration {
if len(vwcs) == 1 {
return []admregv1.ValidatingWebhookConfiguration{}
}

best := 0
for i, vwc := range vwcs {
if vwc.CreationTimestamp.After(vwcs[best].CreationTimestamp.Time) {
best = i
}
}

return append(vwcs[:best], vwcs[best+1:]...)
}

// -----------------------------------------------------------------------------
// Filter functions - DataPlanes
// -----------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 6c45411

Please sign in to comment.