From 1ac510bdc5caf24dcdb8d81e62d944f41a95c405 Mon Sep 17 00:00:00 2001 From: Rob Cohen Date: Mon, 10 Sep 2018 15:18:20 -0400 Subject: [PATCH 01/12] [TSD-131] - Changed CI-NIX.md --- CI-NIX.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CI-NIX.md b/CI-NIX.md index b79f44a..35335a1 100644 --- a/CI-NIX.md +++ b/CI-NIX.md @@ -9,17 +9,16 @@ The pipeline that is executed is located in the .buildkite folder. | File | How to Make | Description | | --- | --- | --- | -| default.nix | Manually | Contains the primary nix expression used to build log-classifier. This is likely the only nix expression that a developer may need to modify. | -| cabal2nix.nix | `$ cabal2nix . > cabal2nix.nix` | The cabal2nix generated output from the log-classifier.cabal file. | | fetch-nixpkgs.nix | [cardano sl](https://github.com/input-output-hk/cardano-sl) | Used for pinning a specific version of nixpkgs. Reads nixpkgs-src.json. | | fetchNixpkgs.nix | [cardano sl](https://github.com/input-output-hk/cardano-sl) | Used for pinning a specific version of nixpkgs. Verifies and pulls nixpkgs. | -| lib.nix | [cardano sl](https://github.com/input-output-hk/cardano-sl) | Used for pinning a specific verison of nixpkgs. Checks for cardano sl pkgs and runs fetch-nixpkgs.nix otherwise. | | shell.nix | Manually | Used by nix-shell to set nix environment. | -| universum.nix | `$ cabal2nix cabal://universum-1.1.0 > universum.nix` | Created by cabal2nix, essentially overrides the Universum in nixpkgs. | +| release.nix | Manually | Used by Hydra | | nixpkgs-src.json | See Below | Where version of nixpkgs is defined. See below for instructions to update. | ## Developing / Building via Nix +Note: We are using stack for local builds again. Nix is being used via the CI, but only to run stack and weeder. + All the commands below are executed in the cloned log-classifier directory. Build with test output: From 436c50a4c81361c1ecc96b2f633305211886af19 Mon Sep 17 00:00:00 2001 From: Rob Cohen Date: Mon, 10 Sep 2018 15:59:50 -0400 Subject: [PATCH 02/12] [TSD-131] - knowledge csv update --- knowledgebase/knowledge.csv | 3 +++ 1 file changed, 3 insertions(+) diff --git a/knowledgebase/knowledge.csv b/knowledgebase/knowledge.csv index 3becc85..dafd58a 100644 --- a/knowledgebase/knowledge.csv +++ b/knowledgebase/knowledge.csv @@ -8,4 +8,7 @@ "Network.Socket.recvBuf: resource vanished","ResourceVanished","Daedalus Wallet Support Issue 8 Network error","To fix this issue, please try other ISP provider","234" "IO error: Failed to create dir","UserNameError","Daedalus Wallet Support Issue 9 User is using non-latin characters for username","To fix this issue, pleae change your PC's username using only latin-characters","235" "open.lock: Locked by","StaleLockFile","Daedalus Wallet Support Issue 10 open.lock file is corrupted due to improper shutdown","The issue is that the application was improperly shutdown. As a workaround, you'll need to delete open.lock file.","236" +"signalProcesssignalProcess:: permission denied","StaleLockFile","Daedalus Wallet Support Issue 10 open.lock file is corrupted due to improper shutdown","The issue is that the application was improperly shutdown. As a workaround, you'll need to delete open.lock file.","236" "Network.Socket.recvBuf: failed (No error)","ConnectionRefused","Daedalus Wallet Support Issue 11 Firewall is blocking the connection","To fix this issue, please try other ISP provider","234" +"Error: certificate signature failure","Error","Connect After Release 1.3.0 Error: certificate signature failure at TLSSocket.","To Fix the issue, reinstall Daedelus.","208" +"server.crt: openBinaryFile: does not exist","Error","Connect After Release 1.3.0 Error: certificate signature failure at TLSSocket.","To Fix the issue, reinstall Daedelus.","208" \ No newline at end of file From 8b4c42677925d2e5fa426b93dacc4f46ffed9467 Mon Sep 17 00:00:00 2001 From: Rob Cohen Date: Mon, 10 Sep 2018 16:29:47 -0400 Subject: [PATCH 03/12] [TSD-131] - knowledge csv update --- knowledgebase/knowledge.csv | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/knowledgebase/knowledge.csv b/knowledgebase/knowledge.csv index dafd58a..0fbec12 100644 --- a/knowledgebase/knowledge.csv +++ b/knowledgebase/knowledge.csv @@ -1,14 +1,15 @@ +"Network.Socket.bind: resource busy","NetworkError","Daedelus cannot use a required port","To fix the issue, terminate the process which is using the required port.","207" +"server.crt: openBinaryFile: does not exist","Error","Connect After Release 1.3.0 Error: certificate signature failure at TLSSocket.","To fix the issue, reinstall Daedelus.","208" +"Error: certificate signature failure","Error","Connect After Release 1.3.0 Error: certificate signature failure at TLSSocket.","To Fix the issue, reinstall Daedelus.","208" +"irrelevant to given wallet","BalanceError","Daedalus Wallet Support Issue 7 Daedalus shows wrong Ada amount","Delete the wallet and restore it with proper phrase","211" "useless for the following reason","TimeSync","Daedalus Wallet Support Issue 1 Your PC's time is out of sync","To fix this issue, user needs to synchronize your computer's time","227" "DBMalformed","DBError","Daedalus Wallet Support Issue 2 Local block data is corrupted","To fix this issue, please delete the content of the DB-1.0 folder","228" "signalProcess: permission denied (Operation not permitted","StaleLockFile","Daedalus Wallet Support Issue 3 Launching node without admin rights","Please make sure you launch the application with admin rights","229" "No such file or directory","FileNotFound","Daedalus Wallet Support Issue 4 File missing","to fix this issue, Please reinstall Daedalus and run the application","230" "resource exhausted (No space left on device)","ShortStorage","Daedalus Wallet Support Issue 5 Not enough space on hard drive to store block data","To fix this, please create more disk space on your computer","231" -"returned empty list","NetworkError","Daedalus Wallet Support Issue 6 Firewall is blocking the connection","To fix this issue, please try other ISP provider","237" -"irrelevant to given wallet","BalanceError","Daedalus Wallet Support Issue 7 Daedalus shows wrong Ada amount","Unfortunately, there's no workaround for this solution. Please report support@iohk.io immediately","211" "Network.Socket.recvBuf: resource vanished","ResourceVanished","Daedalus Wallet Support Issue 8 Network error","To fix this issue, please try other ISP provider","234" +"Network.Socket.recvBuf: failed (No error)","ConnectionRefused","Daedalus Wallet Support Issue 11 Firewall is blocking the connection","To fix this issue, please try other ISP provider","234" "IO error: Failed to create dir","UserNameError","Daedalus Wallet Support Issue 9 User is using non-latin characters for username","To fix this issue, pleae change your PC's username using only latin-characters","235" "open.lock: Locked by","StaleLockFile","Daedalus Wallet Support Issue 10 open.lock file is corrupted due to improper shutdown","The issue is that the application was improperly shutdown. As a workaround, you'll need to delete open.lock file.","236" "signalProcesssignalProcess:: permission denied","StaleLockFile","Daedalus Wallet Support Issue 10 open.lock file is corrupted due to improper shutdown","The issue is that the application was improperly shutdown. As a workaround, you'll need to delete open.lock file.","236" -"Network.Socket.recvBuf: failed (No error)","ConnectionRefused","Daedalus Wallet Support Issue 11 Firewall is blocking the connection","To fix this issue, please try other ISP provider","234" -"Error: certificate signature failure","Error","Connect After Release 1.3.0 Error: certificate signature failure at TLSSocket.","To Fix the issue, reinstall Daedelus.","208" -"server.crt: openBinaryFile: does not exist","Error","Connect After Release 1.3.0 Error: certificate signature failure at TLSSocket.","To Fix the issue, reinstall Daedelus.","208" \ No newline at end of file +"returned empty list","NetworkError","Daedalus Wallet Support Issue 6 Firewall is blocking the connection","To fix this issue, please try other ISP provider","237" \ No newline at end of file From ba00701da3f6bbb3d2d8df535ecf40c7fe90c500 Mon Sep 17 00:00:00 2001 From: Rob Cohen Date: Thu, 13 Sep 2018 12:26:50 -0400 Subject: [PATCH 04/12] [TSD-131] - Minor edits --- knowledgebase/knowledge.csv | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/knowledgebase/knowledge.csv b/knowledgebase/knowledge.csv index 0fbec12..0cb5ee6 100644 --- a/knowledgebase/knowledge.csv +++ b/knowledgebase/knowledge.csv @@ -1,11 +1,9 @@ -"Network.Socket.bind: resource busy","NetworkError","Daedelus cannot use a required port","To fix the issue, terminate the process which is using the required port.","207" +r"Network.Socket.bind: resource busy","NetworkError","Daedelus cannot use a required port","To fix the issue, terminate the process which is using the required port.","207" "server.crt: openBinaryFile: does not exist","Error","Connect After Release 1.3.0 Error: certificate signature failure at TLSSocket.","To fix the issue, reinstall Daedelus.","208" -"Error: certificate signature failure","Error","Connect After Release 1.3.0 Error: certificate signature failure at TLSSocket.","To Fix the issue, reinstall Daedelus.","208" "irrelevant to given wallet","BalanceError","Daedalus Wallet Support Issue 7 Daedalus shows wrong Ada amount","Delete the wallet and restore it with proper phrase","211" "useless for the following reason","TimeSync","Daedalus Wallet Support Issue 1 Your PC's time is out of sync","To fix this issue, user needs to synchronize your computer's time","227" "DBMalformed","DBError","Daedalus Wallet Support Issue 2 Local block data is corrupted","To fix this issue, please delete the content of the DB-1.0 folder","228" "signalProcess: permission denied (Operation not permitted","StaleLockFile","Daedalus Wallet Support Issue 3 Launching node without admin rights","Please make sure you launch the application with admin rights","229" -"No such file or directory","FileNotFound","Daedalus Wallet Support Issue 4 File missing","to fix this issue, Please reinstall Daedalus and run the application","230" "resource exhausted (No space left on device)","ShortStorage","Daedalus Wallet Support Issue 5 Not enough space on hard drive to store block data","To fix this, please create more disk space on your computer","231" "Network.Socket.recvBuf: resource vanished","ResourceVanished","Daedalus Wallet Support Issue 8 Network error","To fix this issue, please try other ISP provider","234" "Network.Socket.recvBuf: failed (No error)","ConnectionRefused","Daedalus Wallet Support Issue 11 Firewall is blocking the connection","To fix this issue, please try other ISP provider","234" From 9b3118d82648645a8324d1d21318dc697c6fc88b Mon Sep 17 00:00:00 2001 From: Rob Cohen Date: Tue, 18 Sep 2018 15:29:53 -0400 Subject: [PATCH 05/12] [TSD-131] - Remove CSV changes --- knowledgebase/knowledge.csv | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/knowledgebase/knowledge.csv b/knowledgebase/knowledge.csv index 0cb5ee6..3becc85 100644 --- a/knowledgebase/knowledge.csv +++ b/knowledgebase/knowledge.csv @@ -1,13 +1,11 @@ -r"Network.Socket.bind: resource busy","NetworkError","Daedelus cannot use a required port","To fix the issue, terminate the process which is using the required port.","207" -"server.crt: openBinaryFile: does not exist","Error","Connect After Release 1.3.0 Error: certificate signature failure at TLSSocket.","To fix the issue, reinstall Daedelus.","208" -"irrelevant to given wallet","BalanceError","Daedalus Wallet Support Issue 7 Daedalus shows wrong Ada amount","Delete the wallet and restore it with proper phrase","211" "useless for the following reason","TimeSync","Daedalus Wallet Support Issue 1 Your PC's time is out of sync","To fix this issue, user needs to synchronize your computer's time","227" "DBMalformed","DBError","Daedalus Wallet Support Issue 2 Local block data is corrupted","To fix this issue, please delete the content of the DB-1.0 folder","228" "signalProcess: permission denied (Operation not permitted","StaleLockFile","Daedalus Wallet Support Issue 3 Launching node without admin rights","Please make sure you launch the application with admin rights","229" +"No such file or directory","FileNotFound","Daedalus Wallet Support Issue 4 File missing","to fix this issue, Please reinstall Daedalus and run the application","230" "resource exhausted (No space left on device)","ShortStorage","Daedalus Wallet Support Issue 5 Not enough space on hard drive to store block data","To fix this, please create more disk space on your computer","231" +"returned empty list","NetworkError","Daedalus Wallet Support Issue 6 Firewall is blocking the connection","To fix this issue, please try other ISP provider","237" +"irrelevant to given wallet","BalanceError","Daedalus Wallet Support Issue 7 Daedalus shows wrong Ada amount","Unfortunately, there's no workaround for this solution. Please report support@iohk.io immediately","211" "Network.Socket.recvBuf: resource vanished","ResourceVanished","Daedalus Wallet Support Issue 8 Network error","To fix this issue, please try other ISP provider","234" -"Network.Socket.recvBuf: failed (No error)","ConnectionRefused","Daedalus Wallet Support Issue 11 Firewall is blocking the connection","To fix this issue, please try other ISP provider","234" "IO error: Failed to create dir","UserNameError","Daedalus Wallet Support Issue 9 User is using non-latin characters for username","To fix this issue, pleae change your PC's username using only latin-characters","235" "open.lock: Locked by","StaleLockFile","Daedalus Wallet Support Issue 10 open.lock file is corrupted due to improper shutdown","The issue is that the application was improperly shutdown. As a workaround, you'll need to delete open.lock file.","236" -"signalProcesssignalProcess:: permission denied","StaleLockFile","Daedalus Wallet Support Issue 10 open.lock file is corrupted due to improper shutdown","The issue is that the application was improperly shutdown. As a workaround, you'll need to delete open.lock file.","236" -"returned empty list","NetworkError","Daedalus Wallet Support Issue 6 Firewall is blocking the connection","To fix this issue, please try other ISP provider","237" \ No newline at end of file +"Network.Socket.recvBuf: failed (No error)","ConnectionRefused","Daedalus Wallet Support Issue 11 Firewall is blocking the connection","To fix this issue, please try other ISP provider","234" From 4773810708d70503ae21bf5b831417a0af63979f Mon Sep 17 00:00:00 2001 From: Rob Cohen Date: Wed, 19 Sep 2018 09:09:36 -0400 Subject: [PATCH 06/12] [TSD-131] - Reduction of Knowledge --- .gitignore | 2 + src/Lib.hs | 22 +++--- src/LogAnalysis/Classifier.hs | 8 +-- src/LogAnalysis/KnowledgeCSVParser.hs | 98 +++++++++++++++++++-------- src/LogAnalysis/Types.hs | 70 +++---------------- 5 files changed, 91 insertions(+), 109 deletions(-) diff --git a/.gitignore b/.gitignore index c5a0b71..1af3b92 100644 --- a/.gitignore +++ b/.gitignore @@ -56,6 +56,8 @@ out/ # Atom .haskell-ghc-mod.json +# +knowledgebase/issues.csv # Misc .DS_Store *.swp diff --git a/src/Lib.hs b/src/Lib.hs index 35ccea7..1e6c302 100644 --- a/src/Lib.hs +++ b/src/Lib.hs @@ -45,12 +45,12 @@ import DataSource (App, Attachment (..), AttachmentContent (..), Comme runApp, tokenPath) import Exceptions (ProcessTicketExceptions (..), ZipFileExceptions (..)) -import LogAnalysis.Classifier (extractErrorCodes, extractIssuesFromLogs, +import LogAnalysis.Classifier (extractIssuesFromLogs, prettyFormatAnalysis, prettyFormatLogReadError, prettyFormatNoIssues, prettyFormatNoLogs) import LogAnalysis.Exceptions (LogAnalysisException (..)) import LogAnalysis.KnowledgeCSVParser (parseKnowLedgeBase) -import LogAnalysis.Types (ErrorCode (..), Knowledge, renderErrorCode, setupAnalysis) +import LogAnalysis.Types (Knowledge, setupAnalysis) import Statistics (showStatistics) import Util (extractLogsFromZip) @@ -537,14 +537,8 @@ inspectLocalZipAttachment filePath = do case eitherAnalysisResult of Right analysisResult -> do - let errorCodes = extractErrorCodes analysisResult - printText "Analysis result:" void $ mapM (printText . show) analysisResult - - printText "Error codes:" - void $ mapM printText errorCodes - Left (e :: LogAnalysisException) -> do printText $ show e @@ -562,7 +556,7 @@ inspectAttachment Config{..} ticketInfo@TicketInfo{..} attachment = do pure $ ZendeskResponse { zrTicketId = tiId , zrComment = prettyFormatLogReadError ticketInfo - , zrTags = TicketTags [renderErrorCode SentLogCorrupted] + , zrTags = TicketTags []--renderErrorCode SentLogCorrupted] , zrIsPublic = cfgIsCommentPublic } @@ -573,13 +567,13 @@ inspectAttachment Config{..} ticketInfo@TicketInfo{..} attachment = do case tryAnalysisResult of Right analysisResult -> do -- Known issue was found - let errorCodes = extractErrorCodes analysisResult + --let errorCodes = extractErrorCodes analysisResult let commentRes = prettyFormatAnalysis analysisResult ticketInfo pure $ ZendeskResponse { zrTicketId = tiId , zrComment = commentRes - , zrTags = TicketTags errorCodes + , zrTags = TicketTags []--errorCodes , zrIsPublic = cfgIsCommentPublic } @@ -590,7 +584,7 @@ inspectAttachment Config{..} ticketInfo@TicketInfo{..} attachment = do pure $ ZendeskResponse { zrTicketId = tiId , zrComment = prettyFormatLogReadError ticketInfo - , zrTags = TicketTags [renderErrorCode DecompressionFailure] + , zrTags = TicketTags []--renderErrorCode DecompressionFailure] , zrIsPublic = cfgIsCommentPublic } -- No known issue was found @@ -598,7 +592,7 @@ inspectAttachment Config{..} ticketInfo@TicketInfo{..} attachment = do pure $ ZendeskResponse { zrTicketId = tiId , zrComment = prettyFormatNoIssues ticketInfo - , zrTags = TicketTags [renderTicketStatus NoKnownIssue] + , zrTags = TicketTags []--renderTicketStatus NoKnownIssue] , zrIsPublic = cfgIsCommentPublic } @@ -609,7 +603,7 @@ responseNoLogs TicketInfo{..} = do pure ZendeskResponse { zrTicketId = tiId , zrComment = prettyFormatNoLogs - , zrTags = TicketTags [renderTicketStatus NoLogAttached] + , zrTags = TicketTags []--renderTicketStatus NoLogAttached] , zrIsPublic = cfgIsCommentPublic } diff --git a/src/LogAnalysis/Classifier.hs b/src/LogAnalysis/Classifier.hs index 74abe55..5ad47bf 100644 --- a/src/LogAnalysis/Classifier.hs +++ b/src/LogAnalysis/Classifier.hs @@ -3,8 +3,7 @@ {-# LANGUAGE RecordWildCards #-} module LogAnalysis.Classifier - ( extractErrorCodes - , extractIssuesFromLogs + ( extractIssuesFromLogs , prettyFormatAnalysis , prettyFormatLogReadError , prettyFormatNoIssues @@ -19,7 +18,7 @@ import Data.Text.Encoding.Error (ignore) import DataSource.Types (TicketInfo (..), ZendeskAPIUrl (..), showURL) import LogAnalysis.Exceptions (LogAnalysisException (..)) -import LogAnalysis.Types (Analysis, Knowledge (..), renderErrorCode) +import LogAnalysis.Types (Analysis, Knowledge (..)) -- | Number of error texts it should show numberOfErrorText :: Int @@ -63,9 +62,6 @@ filterAnalysis as = do then throwM NoKnownIssueFound else pure $ Map.map (take numberOfErrorText) filteredAnalysis -extractErrorCodes :: Analysis -> [Text] -extractErrorCodes as = map (\(Knowledge{..}, _) -> renderErrorCode kErrorCode) $ Map.toList as - prettyHeader :: Text prettyHeader = "Dear user," <> diff --git a/src/LogAnalysis/KnowledgeCSVParser.hs b/src/LogAnalysis/KnowledgeCSVParser.hs index dc36021..3cac844 100644 --- a/src/LogAnalysis/KnowledgeCSVParser.hs +++ b/src/LogAnalysis/KnowledgeCSVParser.hs @@ -8,7 +8,7 @@ import Universum import Data.Attoparsec.Text (Parser, char, endOfLine, takeTill, string) -import LogAnalysis.Types (ErrorCode (..), Knowledge (..)) +import LogAnalysis.Types (Knowledge (..)) {- @@ -27,44 +27,82 @@ quotedText = do _ <- char '"' pure result ---- | Parse ErrorCode -parseErrorCode :: Parser ErrorCode -parseErrorCode = - (string "ShortStorage" >> return ShortStorage) - <|> (string "UserNameError" >> return UserNameError) - <|> (string "TimeSync" >> return TimeSync) - <|> (string "FileNotFound" >> return FileNotFound) - <|> (string "StaleLockFile" >> return StaleLockFile) - <|> (string "DBPath" >> return DBPath) - <|> (string "CannotGetDBSize" >> return CannotGetDBSize) - <|> (string "DBError" >> return DBError) - <|> (string "BalanceError" >> return BalanceError) - <|> (string "NetworkError" >> return NetworkError) - <|> (string "ConnectionRefused" >> return ConnectionRefused) - <|> (string "ResourceVanished" >> return ResourceVanished) - <|> (string "Unknown" >> return Unknown) - <|> (string "Error" >> return Error) -- | Parse each csv records -parseKnowledge :: Parser Knowledge -- not really clean code.. +{-parseCSVHeader :: Parser CSVHeader +parseCSVHeader = do + return $ iterateHeader <* endOfLine + where + iterateHeader :: a -> [Text] + iterateHeader (x : xs) = do + x' <- quotedText x + _ <- char ',' + return $ [x' : parseCSVHeader xs] +-} +parseKnowledge :: Parser Knowledge parseKnowledge = do - e <- quotedText - _ <- char ',' _ <- char '"' - c <- parseErrorCode + issueProj <- takeTill (=='-') + _ <- char '-' + issueID <- takeTill (=='"') _ <- char '"' _ <- char ',' - p <- quotedText + project <- quotedText + _ <- char ',' + tags <- quotedText + _ <- char ',' + summary <- quotedText + _ <- char ',' + reporter <- quotedText + _ <- char ',' + created <- quotedText + _ <- char ',' + updated <- quotedText + _ <- char ',' + resolved <- quotedText + _ <- char ',' + priority <- quotedText + _ <- char ',' + typeCat <- quotedText + _ <- char ',' + state <- quotedText + _ <- char ',' + assignee <- quotedText + _ <- char ',' + subsystem <- quotedText _ <- char ',' - s <- quotedText + fixVer <- quotedText _ <- char ',' - f <- quotedText + affVer <- quotedText + _ <- char ',' + tarVer <- quotedText + _ <- char ',' + group <- quotedText + _ <- char ',' + resolution <- quotedText + _ <- char ',' + platform <- quotedText + _ <- char ',' + numUserAff <- quotedText + _ <- char ',' + zenDebugger <- quotedText + _ <- char ',' + zenTicketStat <- quotedText + _ <- char ',' + zenFAQNum <- quotedText + _ <- char ',' + zenIdentText <- quotedText + _ <- char ',' + zenProbURL <- quotedText + _ <- char ',' + zenDebSol <- quotedText + _ <- char ',' + zenDebStatus <- quotedText + return $ Knowledge - { kErrorText = e - , kErrorCode = c - , kProblem = p - , kSolution = s - , kFAQNumber = f + { kErrorText = zenIdentText + , kIssueID = IssueID issueProj issueID + , kFAQNumber = zenFAQNum } -- | Parse CSV file and create knowledgebase diff --git a/src/LogAnalysis/Types.hs b/src/LogAnalysis/Types.hs index 3577719..4c856fc 100644 --- a/src/LogAnalysis/Types.hs +++ b/src/LogAnalysis/Types.hs @@ -2,11 +2,8 @@ module LogAnalysis.Types ( Analysis - , ErrorCode (..) , Knowledge (..) , setupAnalysis - , renderErrorCode - , toComment ) where import Universum @@ -14,73 +11,28 @@ import Prelude (Show (..)) import qualified Data.Map.Strict as Map --- | Identifier for each error -data ErrorCode - = ShortStorage -- ^ Not enough space on hard drive to store block data - | UserNameError -- ^ User is using non-latin characters for username - | TimeSync -- ^ User's PC's time is out of sync - | FileNotFound -- ^ Some of the files were not installed properly - | StaleLockFile -- ^ Open.lock file is corrupted - | SentLogCorrupted -- ^ Log file sent to the Zendesk is corrupted - | DBError -- ^ Local block data is corrupted - | DBPath -- ^ Daedalus cannot find certain files - | CannotGetDBSize -- ^ Error message of Couidn't pack log files shows up - | BalanceError -- ^ Daedalus shows wrong Ada amount - | NetworkError -- ^ Firewall is blocking the connection - | ConnectionRefused -- ^ Firewall is blocking the connection - | ResourceVanished -- ^ Network error - | DecompressionFailure -- ^ The classifier failed to decompress the log file - | Unknown -- ^ Unknown error (currently not used) - | Error -- ^ Error (currently not used) - deriving (Eq, Ord, Show) -- | Record identifying the issue +data IssueID = IssueID Text Int + data Knowledge = Knowledge { kErrorText :: !Text -- ^ Text used for matching error lines - , kErrorCode :: !ErrorCode - -- ^ Identity for error code - , kProblem :: !Text - -- ^ Text describing what is the problem - , kSolution :: !Text - -- ^ Text describing how to solve the issue - , kFAQNumber :: !Text - -- ^ The FAQ number that will be displayed on the official Cardano FAQ page + , kIssueID :: !IssueID + -- ^ IssueID } +--type CSVHeader = [Text] +instance Show IssueID where + show (IssueID proj issueID) = Prelude.show proj ++ "-" ++ Prelude.show issueID + instance Show Knowledge where show Knowledge{..} = "{ errorText = " <> Prelude.show kErrorText <> - ", errorCode = " <> Prelude.show kErrorCode <> - ", problem = " <> Prelude.show kProblem <> - ", solution = " <> Prelude.show kSolution <> - ", FAQNumber = " <> Prelude.show kFAQNumber <> + ", issueID = " <> Prelude.show kIssueID <> "}" -- | Sorted accoring to knowledgebase. --- Tag needs to be in lowercase since Zendesk automatically convert any uppercase --- lowercase -renderErrorCode :: ErrorCode -> Text -renderErrorCode DBError = "db-corrupted" -renderErrorCode StaleLockFile = "stale-lock-file" -renderErrorCode FileNotFound = "directory-not-found" -renderErrorCode ShortStorage = "short-storage" -renderErrorCode NetworkError = "network-error" -renderErrorCode BalanceError = "incorrect-balance" -renderErrorCode ResourceVanished = "resource-vanished" -renderErrorCode UserNameError = "user-name-error" -renderErrorCode ConnectionRefused = "connection-refused" -renderErrorCode TimeSync = "time-out-of-sync" -renderErrorCode SentLogCorrupted = "sent-log-corrupted" -renderErrorCode DBPath = "db-path-error" -renderErrorCode CannotGetDBSize = "cannot-get-db-size" -renderErrorCode DecompressionFailure = "decompression-failure" -renderErrorCode Unknown = "unknown" -renderErrorCode Error = "error" - -toComment :: ErrorCode -> Text -toComment SentLogCorrupted = "Log file is corrupted" -toComment _ = "Error" -- | Map used to collect error lines type Analysis = Map Knowledge [Text] @@ -90,7 +42,7 @@ setupAnalysis :: [Knowledge] -> Analysis setupAnalysis kbase = Map.fromList $ map (\kn -> (kn, [])) kbase instance Eq Knowledge where - e1 == e2 = kErrorCode e1 == kErrorCode e2 + e1 == e2 = (kIssueID proj issueID) e1 == (kIssueID proj' issueID') e2 instance Ord Knowledge where - e1 <= e2 = kErrorCode e1 <= kErrorCode e2 + (kIssueID proj issueID) e1 <= (kIssueID proj' issueID') e2 = (proj == proj') && (issueID <= issueID') From 7a30fa7385d567076897a06089855183deee3d82 Mon Sep 17 00:00:00 2001 From: Rob Cohen Date: Wed, 19 Sep 2018 09:46:05 -0400 Subject: [PATCH 07/12] [TSD-131] - Free test --- .buildkite/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 0927a9b..3771be1 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -1,5 +1,5 @@ steps: - label: 'stack nix' - command: 'nix-shell --run "stack install weeder && /var/lib/buildkite-agent/.local/bin/weeder . --build --test && stack test"' + command: 'free; nix-shell --run "stack install weeder && /var/lib/buildkite-agent/.local/bin/weeder . --build --test && stack test"' agents: system: x86_64-linux From cb8eb9571ffd5ce35ee2e4903858387b599dce18 Mon Sep 17 00:00:00 2001 From: Rob Cohen Date: Wed, 19 Sep 2018 09:47:22 -0400 Subject: [PATCH 08/12] [TSD-131] - Free test --- .buildkite/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 3771be1..9f625d0 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -1,5 +1,5 @@ steps: - label: 'stack nix' - command: 'free; nix-shell --run "stack install weeder && /var/lib/buildkite-agent/.local/bin/weeder . --build --test && stack test"' + command: 'free -h; nix-shell --run "stack install weeder && /var/lib/buildkite-agent/.local/bin/weeder . --build --test && stack test"' agents: system: x86_64-linux From 97e8cbd9327af3006959f29cbf3843072d9bb5c5 Mon Sep 17 00:00:00 2001 From: Rob Cohen Date: Wed, 19 Sep 2018 09:55:04 -0400 Subject: [PATCH 09/12] [TSD-131] - Types edit --- src/LogAnalysis/Types.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/LogAnalysis/Types.hs b/src/LogAnalysis/Types.hs index 4c856fc..2ba1c48 100644 --- a/src/LogAnalysis/Types.hs +++ b/src/LogAnalysis/Types.hs @@ -45,4 +45,10 @@ instance Eq Knowledge where e1 == e2 = (kIssueID proj issueID) e1 == (kIssueID proj' issueID') e2 instance Ord Knowledge where - (kIssueID proj issueID) e1 <= (kIssueID proj' issueID') e2 = (proj == proj') && (issueID <= issueID') + compare e1 e2 = compare (kIssueID) (kIssueID) + +instance Ord IssueID where + compare (IssueID p1 n1) (IssueID p2 n2) + | (p1 == p2) & (n1 == n2) = EQ + | (p1 == p2) & (n1 > n2) = GT + | otherwise = LT From ebd6129d777e0cf51ba284d27a97687de1c4ee6f Mon Sep 17 00:00:00 2001 From: Rob Cohen Date: Wed, 19 Sep 2018 09:55:54 -0400 Subject: [PATCH 10/12] [TSD-131] - Free test --- .buildkite/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 9f625d0..0927a9b 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -1,5 +1,5 @@ steps: - label: 'stack nix' - command: 'free -h; nix-shell --run "stack install weeder && /var/lib/buildkite-agent/.local/bin/weeder . --build --test && stack test"' + command: 'nix-shell --run "stack install weeder && /var/lib/buildkite-agent/.local/bin/weeder . --build --test && stack test"' agents: system: x86_64-linux From 95b64cb0739d5066323839120f8d02d996095271 Mon Sep 17 00:00:00 2001 From: Rob Cohen Date: Wed, 19 Sep 2018 10:07:38 -0400 Subject: [PATCH 11/12] [TSD-131] - Reduction of Knowledge --- src/LogAnalysis/KnowledgeCSVParser.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/LogAnalysis/KnowledgeCSVParser.hs b/src/LogAnalysis/KnowledgeCSVParser.hs index 3cac844..f5a0ba7 100644 --- a/src/LogAnalysis/KnowledgeCSVParser.hs +++ b/src/LogAnalysis/KnowledgeCSVParser.hs @@ -29,7 +29,8 @@ quotedText = do -- | Parse each csv records -{-parseCSVHeader :: Parser CSVHeader +{- +parseCSVHeader :: Parser CSVHeader parseCSVHeader = do return $ iterateHeader <* endOfLine where @@ -39,6 +40,7 @@ parseCSVHeader = do _ <- char ',' return $ [x' : parseCSVHeader xs] -} + parseKnowledge :: Parser Knowledge parseKnowledge = do _ <- char '"' @@ -102,7 +104,6 @@ parseKnowledge = do return $ Knowledge { kErrorText = zenIdentText , kIssueID = IssueID issueProj issueID - , kFAQNumber = zenFAQNum } -- | Parse CSV file and create knowledgebase From e7fc6adebe6cdc49cc9b3d2ef48d0115c207547f Mon Sep 17 00:00:00 2001 From: Rob Cohen Date: Wed, 19 Sep 2018 10:48:01 -0400 Subject: [PATCH 12/12] [TSD-131] - Additional edits of types --- src/LogAnalysis/KnowledgeCSVParser.hs | 13 +------------ src/LogAnalysis/Types.hs | 15 ++------------- 2 files changed, 3 insertions(+), 25 deletions(-) diff --git a/src/LogAnalysis/KnowledgeCSVParser.hs b/src/LogAnalysis/KnowledgeCSVParser.hs index f5a0ba7..f6753be 100644 --- a/src/LogAnalysis/KnowledgeCSVParser.hs +++ b/src/LogAnalysis/KnowledgeCSVParser.hs @@ -29,17 +29,6 @@ quotedText = do -- | Parse each csv records -{- -parseCSVHeader :: Parser CSVHeader -parseCSVHeader = do - return $ iterateHeader <* endOfLine - where - iterateHeader :: a -> [Text] - iterateHeader (x : xs) = do - x' <- quotedText x - _ <- char ',' - return $ [x' : parseCSVHeader xs] --} parseKnowledge :: Parser Knowledge parseKnowledge = do @@ -103,7 +92,7 @@ parseKnowledge = do return $ Knowledge { kErrorText = zenIdentText - , kIssueID = IssueID issueProj issueID + , kIssueID = (IssueID issueProj issueID) } -- | Parse CSV file and create knowledgebase diff --git a/src/LogAnalysis/Types.hs b/src/LogAnalysis/Types.hs index 2ba1c48..94106a1 100644 --- a/src/LogAnalysis/Types.hs +++ b/src/LogAnalysis/Types.hs @@ -13,14 +13,14 @@ import qualified Data.Map.Strict as Map -- | Record identifying the issue -data IssueID = IssueID Text Int +data IssueID = IssueID Text Int deriving (Eq, Ord) data Knowledge = Knowledge { kErrorText :: !Text -- ^ Text used for matching error lines , kIssueID :: !IssueID -- ^ IssueID - } + } deriving (Eq, Ord) --type CSVHeader = [Text] instance Show IssueID where @@ -41,14 +41,3 @@ type Analysis = Map Knowledge [Text] setupAnalysis :: [Knowledge] -> Analysis setupAnalysis kbase = Map.fromList $ map (\kn -> (kn, [])) kbase -instance Eq Knowledge where - e1 == e2 = (kIssueID proj issueID) e1 == (kIssueID proj' issueID') e2 - -instance Ord Knowledge where - compare e1 e2 = compare (kIssueID) (kIssueID) - -instance Ord IssueID where - compare (IssueID p1 n1) (IssueID p2 n2) - | (p1 == p2) & (n1 == n2) = EQ - | (p1 == p2) & (n1 > n2) = GT - | otherwise = LT