X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/8da2f73faeeecd81f52949451fe07a674ba47df6..44aa688953d658a23c32581a2bad01342007a191:/lib/costanalyzer/costanalyzer.go diff --git a/lib/costanalyzer/costanalyzer.go b/lib/costanalyzer/costanalyzer.go index e8dd186050..402e0ec81a 100644 --- a/lib/costanalyzer/costanalyzer.go +++ b/lib/costanalyzer/costanalyzer.go @@ -35,6 +35,7 @@ type nodeInfo struct { // Modern ProviderType string Price float64 + Preemptible bool } type arrayFlags []string @@ -56,7 +57,7 @@ func parseFlags(prog string, args []string, loader *config.Loader, logger *logru flags.Usage = func() { fmt.Fprintf(flags.Output(), ` Usage: - %s [options ...] ... + %s [options ...] uuid [uuid ...] This program analyzes the cost of Arvados container requests. For each uuid supplied, it creates a CSV report that lists all the containers used to @@ -77,19 +78,26 @@ Usage: container was reused between several container requests, its cost will only be counted once. - To get the node costs, the progam queries the Arvados API for current cost - data for each node type used. This means that the reported cost always - reflects the cost data as currently defined in the Arvados API configuration - file. - Caveats: - - the Arvados API configuration cost data may be out of sync with the cloud - provider. - - when generating reports for older container requests, the cost data in the - Arvados API configuration file may have changed since the container request - was fulfilled. This program uses the cost data stored at the time of the + + - This program uses the cost data from config.yml at the time of the execution of the container, stored in the 'node.json' file in its log - collection. + collection. If the cost data was not correctly configured at the time the + container was executed, the output from this program will be incorrect. + + - If a container was run on a preemptible ("spot") instance, the cost data + reported by this program may be wildly inaccurate, because it does not have + access to the spot pricing in effect for the node then the container ran. The + UUID report file that is generated when the '-output' option is specified has + a column that indicates the preemptible state of the instance that ran the + container. + + - This program does not take into account overhead costs like the time spent + starting and stopping compute nodes that run containers, the cost of the + permanent cloud nodes that provide the Arvados services, the cost of data + stored in Arvados, etc. + + - When provided with a project uuid, subprojects will not be considered. In order to get the data for the uuids supplied, the ARVADOS_API_HOST and ARVADOS_API_TOKEN environment variables must be set. @@ -181,7 +189,7 @@ func addContainerLine(logger *logrus.Logger, node nodeInfo, cr arvados.Container size = node.ProviderType } cost = delta.Seconds() / 3600 * price - csv += size + "," + strconv.FormatFloat(price, 'f', 8, 64) + "," + strconv.FormatFloat(cost, 'f', 8, 64) + "\n" + csv += size + "," + fmt.Sprintf("%+v", node.Preemptible) + "," + strconv.FormatFloat(price, 'f', 8, 64) + "," + strconv.FormatFloat(cost, 'f', 8, 64) + "\n" return } @@ -369,7 +377,7 @@ func generateCrCsv(logger *logrus.Logger, uuid string, arv *arvadosclient.Arvado cost = make(map[string]float64) - csv := "CR UUID,CR name,Container UUID,State,Started At,Finished At,Duration in seconds,Compute node type,Hourly node cost,Total cost\n" + csv := "CR UUID,CR name,Container UUID,State,Started At,Finished At,Duration in seconds,Compute node type,Preemptible,Hourly node cost,Total cost\n" var tmpCsv string var tmpTotalCost float64 var totalCost float64