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

Log cluster App status on failure to standup cluster #449

Merged
merged 1 commit into from
Aug 23, 2024
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Output some debug logging when Cluster fails to standup during `BeforeSuite`

## [1.66.0] - 2024-08-22

### Added
Expand Down
46 changes: 46 additions & 0 deletions internal/suite/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,55 @@ func Setup(isUpgrade bool, clusterBuilder cb.ClusterBuilder, clusterReadyFns ...
cluster := cb.LoadOrBuildCluster(framework, clusterBuilder)
state.SetCluster(cluster)

// We'll use this to track if the BeforeSuite failed and if we should do extra debug logging
setupComplete := false
defer (func() {
if !setupComplete {
// If we fail to standup the cluster, lets grab the status of the cluster App to see if there's an error
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 1*time.Minute)
defer cancel()

cluster := state.GetCluster()

logger.Log("Attempting to get debug info for Cluster App")

clusterApp, err := framework.GetApp(ctx, cluster.ClusterApp.InstallName, cluster.ClusterApp.GetNamespace())
if err != nil {
logger.Log("Failed to get Cluster App: %v", err)
return
}

logger.Log(
"Cluster App status: AppVersion='%s', Version='%s', ReleaseStatus='%s', ReleaseReason='%s', LastDeployed='%v'",
clusterApp.Status.AppVersion,
clusterApp.Status.Version,
clusterApp.Status.Release.Status,
clusterApp.Status.Release.Reason,
clusterApp.Status.Release.LastDeployed,
)

logger.Log("Getting events for the Cluster App")
events, err := framework.MC().GetEventsForResource(ctx, clusterApp)
if err != nil {
logger.Log("Failed to get events for App: %v", err)
return
}
if len(events.Items) == 0 {
logger.Log("No events found for Cluster App")
}
for _, event := range events.Items {
logger.Log("Event: Reason='%s', Message='%s', Last Occurred='%v'", event.Reason, event.Message, event.LastTimestamp)
}
}
})()

cluster, err = standup.New(framework, isUpgrade, clusterReadyFns...).Standup(cluster)
Expect(err).NotTo(HaveOccurred())
state.SetCluster(cluster)

// Make sure this comes last
setupComplete = true
})

AfterSuite(func() {
Expand Down