Skip to content

Commit

Permalink
debug cert-manager
Browse files Browse the repository at this point in the history
  • Loading branch information
chrischdi committed Feb 23, 2024
1 parent 785ffa4 commit c9899e2
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ test-test-extension-junit: $(SETUP_ENVTEST) $(GOTESTSUM) ## Run unit and integra
.PHONY: test-e2e
test-e2e: $(GINKGO) generate-e2e-templates ## Run the end-to-end tests
$(GINKGO) -v --trace -poll-progress-after=$(GINKGO_POLL_PROGRESS_AFTER) \
-poll-progress-interval=$(GINKGO_POLL_PROGRESS_INTERVAL) --tags=e2e --focus="$(GINKGO_FOCUS)" \
-poll-progress-interval=$(GINKGO_POLL_PROGRESS_INTERVAL) --tags=e2e --focus="$(GINKGO_FOCUS)" --label-filter=Foo \
$(_SKIP_ARGS) --nodes=$(GINKGO_NODES) --timeout=$(GINKGO_TIMEOUT) --no-color=$(GINKGO_NOCOLOR) \
--output-dir="$(ARTIFACTS)" --junit-report="junit.e2e_suite.1.xml" $(GINKGO_ARGS) $(ROOT_DIR)/$(TEST_DIR)/e2e -- \
-e2e.artifacts-folder="$(ARTIFACTS)" \
Expand Down
14 changes: 11 additions & 3 deletions scripts/ci-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ docker events > "${ARTIFACTS_LOCAL}/docker-events.txt" 2>&1 &
ctr -n moby events > "${ARTIFACTS_LOCAL}/containerd-events.txt" 2>&1 &

# Run e2e tests
mkdir -p "$ARTIFACTS"
echo "+ run tests!"
make test-e2e

ORIGINAL_ARTIFACTS="${ARTIFACTS}"

for i in {1..10}; do
ARTIFACTS="${ORIGINAL_ARTIFACTS}/${i}"
echo "Using artifacts location: $ARTIFACTS"
mkdir -p "$ARTIFACTS"
echo "+ run tests!"

make test-e2e
done
2 changes: 1 addition & 1 deletion test/e2e/clusterctl_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"sigs.k8s.io/cluster-api/test/framework"
)

var _ = Describe("When testing clusterctl upgrades (v0.4=>current)", func() {
var _ = Describe("When testing clusterctl upgrades (v0.4=>current) [PR-Blocking]", Label("Foo"), func() {
ClusterctlUpgradeSpec(ctx, func() ClusterctlUpgradeSpecInput {
return ClusterctlUpgradeSpecInput{
E2EConfig: e2eConfig,
Expand Down
7 changes: 6 additions & 1 deletion test/framework/alltypes_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,12 @@ func getClusterAPITypes(ctx context.Context, lister Lister) []metav1.TypeMeta {
Eventually(func() error {
return lister.List(ctx, crdList, capiProviderOptions()...)
}, retryableOperationTimeout, retryableOperationInterval).Should(Succeed(), "failed to list CRDs for CAPI providers")
crdListCertManager := &apiextensionsv1.CustomResourceDefinitionList{}
Eventually(func() error {
return lister.List(ctx, crdListCertManager, client.MatchingLabels{"app": "cert-manager"})
}, retryableOperationTimeout, retryableOperationInterval).Should(Succeed(), "failed to list CRDs for CAPI providers")

for _, crd := range crdList.Items {
for _, crd := range append(crdList.Items, crdListCertManager.Items...) {
for _, version := range crd.Spec.Versions {
if !version.Storage {
continue
Expand All @@ -104,6 +108,7 @@ func getClusterAPITypes(ctx context.Context, lister Lister) []metav1.TypeMeta {
})
}
}

return discoveredTypes
}

Expand Down
31 changes: 31 additions & 0 deletions test/framework/clusterctl/clusterctl_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package clusterctl

import (
"context"
"fmt"
"os"
"path/filepath"
"time"
Expand Down Expand Up @@ -128,6 +129,36 @@ func InitManagementClusterAndWatchControllerLogs(ctx context.Context, input Init
})
}
}

certManagerDeployments := framework.GetCertManagerDeployments(ctx, framework.GetControllerDeploymentsInput{
Lister: client,
})
for _, deployment := range certManagerDeployments {
fmt.Printf("Pod status of %q:\n%++v\n", deployment.Namespace, deployment.Name, deployment.Status)
// framework.WaitForDeploymentsAvailable(ctx, framework.WaitForDeploymentsAvailableInput{
// Getter: client,
// Deployment: deployment,
// }, intervals...)

// Start streaming logs from all controller providers
framework.WatchDeploymentLogsByName(ctx, framework.WatchDeploymentLogsByNameInput{
GetLister: client,
Cache: input.ClusterProxy.GetCache(ctx),
ClientSet: input.ClusterProxy.GetClientSet(),
Deployment: deployment,
LogPath: filepath.Join(input.LogFolder, "logs", deployment.GetNamespace()),
})

// if !input.DisableMetricsCollection {
// framework.WatchPodMetrics(ctx, framework.WatchPodMetricsInput{
// GetLister: client,
// ClientSet: input.ClusterProxy.GetClientSet(),
// Deployment: deployment,
// MetricsPath: filepath.Join(input.LogFolder, "metrics", deployment.GetNamespace()),
// })
// }
}

}

// UpgradeManagementClusterAndWaitInput is the input type for UpgradeManagementClusterAndWait.
Expand Down
18 changes: 18 additions & 0 deletions test/framework/controller_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

. "github.com/onsi/gomega"
appsv1 "k8s.io/api/apps/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)

// GetControllerDeploymentsInput is the input for GetControllerDeployments.
Expand All @@ -46,6 +47,23 @@ func GetControllerDeployments(ctx context.Context, input GetControllerDeployment
return deployments
}

// GetControllerDeployments returns all the deployment for the cluster API controllers existing in a management cluster.
func GetCertManagerDeployments(ctx context.Context, input GetControllerDeploymentsInput) []*appsv1.Deployment {
deploymentList := &appsv1.DeploymentList{}
Eventually(func() error {
return input.Lister.List(ctx, deploymentList, client.InNamespace("cert-manager"))
}, retryableOperationTimeout, retryableOperationInterval).Should(Succeed(), "Failed to list deployments for the cluster API controllers")

deployments := make([]*appsv1.Deployment, 0, len(deploymentList.Items))
for i := range deploymentList.Items {
d := &deploymentList.Items[i]
if !skipDeployment(d, input.ExcludeNamespaces) {
deployments = append(deployments, d)
}
}
return deployments
}

func skipDeployment(d *appsv1.Deployment, excludeNamespaces []string) bool {
if !d.DeletionTimestamp.IsZero() {
return true
Expand Down

0 comments on commit c9899e2

Please sign in to comment.