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 952be59
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 30 deletions.
60 changes: 31 additions & 29 deletions test/e2e/clusterctl_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,35 +26,37 @@ import (
"sigs.k8s.io/cluster-api/test/framework"
)

var _ = Describe("When testing clusterctl upgrades (v0.4=>current)", func() {
ClusterctlUpgradeSpec(ctx, func() ClusterctlUpgradeSpecInput {
return ClusterctlUpgradeSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
InfrastructureProvider: pointer.String("docker"),
InitWithBinary: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.4.8/clusterctl-{OS}-{ARCH}",
InitWithProvidersContract: "v1alpha4",
// NOTE: If this version is changed here the image and SHA must also be updated in all DockerMachineTemplates in `test/data/infrastructure-docker/v0.4/bases.
InitWithKubernetesVersion: "v1.23.17",
WorkloadKubernetesVersion: "v1.23.17",
MgmtFlavor: "topology",
WorkloadFlavor: "",
// This check ensures that ownerReference apiVersions are updated for all types after the upgrade.
PostUpgrade: func(proxy framework.ClusterProxy, namespace, clusterName string) {
framework.AssertOwnerReferences(namespace, proxy.GetKubeconfigPath(),
framework.CoreOwnerReferenceAssertion,
framework.ExpOwnerReferenceAssertions,
framework.DockerInfraOwnerReferenceAssertions,
framework.KubeadmBootstrapOwnerReferenceAssertions,
framework.KubeadmControlPlaneOwnerReferenceAssertions,
framework.KubernetesReferenceAssertions,
)
},
}
})
var _ = FDescribe("When testing clusterctl upgrades (v0.4=>current)", func() {
for i := 0; i < 10; i++ {
ClusterctlUpgradeSpec(ctx, func() ClusterctlUpgradeSpecInput {
return ClusterctlUpgradeSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
InfrastructureProvider: pointer.String("docker"),
InitWithBinary: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.4.8/clusterctl-{OS}-{ARCH}",
InitWithProvidersContract: "v1alpha4",
// NOTE: If this version is changed here the image and SHA must also be updated in all DockerMachineTemplates in `test/data/infrastructure-docker/v0.4/bases.
InitWithKubernetesVersion: "v1.23.17",
WorkloadKubernetesVersion: "v1.23.17",
MgmtFlavor: "topology",
WorkloadFlavor: "",
// This check ensures that ownerReference apiVersions are updated for all types after the upgrade.
PostUpgrade: func(proxy framework.ClusterProxy, namespace, clusterName string) {
framework.AssertOwnerReferences(namespace, proxy.GetKubeconfigPath(),
framework.CoreOwnerReferenceAssertion,
framework.ExpOwnerReferenceAssertions,
framework.DockerInfraOwnerReferenceAssertions,
framework.KubeadmBootstrapOwnerReferenceAssertions,
framework.KubeadmControlPlaneOwnerReferenceAssertions,
framework.KubernetesReferenceAssertions,
)
},
}
})
}
})

var _ = Describe("When testing clusterctl upgrades (v1.0=>current)", func() {
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)

Check failure on line 137 in test/framework/clusterctl/clusterctl_helpers.go

View workflow job for this annotation

GitHub Actions / lint (test)

printf: fmt.Printf call needs 2 args but has 3 args (govet)
// framework.WaitForDeploymentsAvailable(ctx, framework.WaitForDeploymentsAvailableInput{

Check failure on line 138 in test/framework/clusterctl/clusterctl_helpers.go

View workflow job for this annotation

GitHub Actions / lint (test)

commentedOutCode: may want to remove commented-out code (gocritic)
// 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 {

Check failure on line 152 in test/framework/clusterctl/clusterctl_helpers.go

View workflow job for this annotation

GitHub Actions / lint (test)

commentedOutCode: may want to remove commented-out code (gocritic)
// framework.WatchPodMetrics(ctx, framework.WatchPodMetricsInput{
// GetLister: client,
// ClientSet: input.ClusterProxy.GetClientSet(),
// Deployment: deployment,
// MetricsPath: filepath.Join(input.LogFolder, "metrics", deployment.GetNamespace()),
// })
// }
}

Check failure on line 161 in test/framework/clusterctl/clusterctl_helpers.go

View workflow job for this annotation

GitHub Actions / lint (test)

unnecessary trailing newline (whitespace)
}

// 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.

Check warning on line 50 in test/framework/controller_helpers.go

View workflow job for this annotation

GitHub Actions / lint (test)

exported: comment on exported function GetCertManagerDeployments should be of the form "GetCertManagerDeployments ..." (revive)
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 952be59

Please sign in to comment.