Skip to content

Commit

Permalink
Log cluster App status on failure to standup cluster (#449)
Browse files Browse the repository at this point in the history
Signed-off-by: Marcus Noble <[email protected]>
  • Loading branch information
AverageMarcus authored Aug 23, 2024
1 parent c711961 commit db4c8e6
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
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

0 comments on commit db4c8e6

Please sign in to comment.