Skip to content

Commit

Permalink
sandwich-contexts-kubernetes: clearer error messages in MinikubeClust…
Browse files Browse the repository at this point in the history
…er/Images.hs
  • Loading branch information
thomasjm committed Aug 9, 2024
1 parent 0f04f0b commit 069b217
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,16 @@ loadImage minikubeBinary clusterName minikubeFlags imageLoadSpec = do
>>= waitForProcess >>= (`shouldBe` ExitSuccess)

stderrOutput <- fromLogStr <$> readIORef stderrOutputVar
when (or [f stderrOutput | f <- badOutputChecks]) $
expectationFailure [i|minikube image load failed; error output detected|]

let ef (details :: Text) = expectationFailure [i|minikube image load failed; error output detected (#{details})|]

when (check1 stderrOutput) $ ef "Contained 'Failed to load cached images for profile' message"
when (check2 stderrOutput) $ ef "Contained 'ctr: failed to ingest' message"
when (check3 stderrOutput) $ ef "Contained 'failed pushing to' message"

-- This is crazy, but minikube image load sometimes fails silently.
-- One example: https://github.com/kubernetes/minikube/issues/16032
-- As a result, we add a few checks to detect the cases we've seen that represent a failed load.
badOutputChecks :: [ByteString -> Bool]
badOutputChecks = [check1, check2, check3]

check1 bytes = "Failed to load cached images for profile" `B.isInfixOf` bytes
&& "make sure the profile is running." `B.isInfixOf` bytes
Expand Down

0 comments on commit 069b217

Please sign in to comment.