[ARVADOS] updated: 3cdc055b90fd859cbd0e101becb4abd78f4d467f

git at public.curoverse.com git at public.curoverse.com
Tue Sep 30 14:37:48 EDT 2014


Summary of changes:
 .../app/controllers/collections_controller.rb      |  9 +++++---
 apps/workbench/app/views/jobs/_show_log.html.erb   | 25 ++++++++++++++--------
 2 files changed, 22 insertions(+), 12 deletions(-)

       via  3cdc055b90fd859cbd0e101becb4abd78f4d467f (commit)
      from  521df5cd1e19a671a4f940128c5c61930df9c8bb (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 3cdc055b90fd859cbd0e101becb4abd78f4d467f
Author: Tim Pierce <twp at curoverse.com>
Date:   Mon Sep 29 18:25:36 2014 -0400

    3782: check for Content-Range header in response
    
    Change the logic for detecting whether the log has been truncated to:
    * response status code is 206
    * a Content-Range header is present with 'bytes 0-x/y'
    * x + 1 < y
    
    Add a "download full log" link that is present when the full log is
    available to be viewed.

diff --git a/apps/workbench/app/controllers/collections_controller.rb b/apps/workbench/app/controllers/collections_controller.rb
index baa7661..cc0b3ff 100644
--- a/apps/workbench/app/controllers/collections_controller.rb
+++ b/apps/workbench/app/controllers/collections_controller.rb
@@ -150,12 +150,17 @@ class CollectionsController < ApplicationController
     end
 
     opts = params.merge(arvados_api_token: usable_token)
+
+    # Handle Range requests. Currently we support only 'bytes=0-....'
     if request.headers.include? 'HTTP_RANGE'
-      # Currently only 'bytes=0-....' is supported.
       if m = /^bytes=0-(\d+)/.match(request.headers['HTTP_RANGE'])
         opts[:maxbytes] = m[1]
+        size = params[:size] || '*'
+        self.response.status = 206
+        self.response.headers['Content-Range'] = "bytes 0-#{m[1]}/#{size}"
       end
     end
+
     ext = File.extname(params[:file])
     self.response.headers['Content-Type'] =
       Rack::Mime::MIME_TYPES[ext] || 'application/octet-stream'
@@ -311,7 +316,6 @@ class CollectionsController < ApplicationController
       env['ARVADOS_API_HOST_INSECURE'] = "true" if Rails.configuration.arvados_insecure_https
 
       bytesleft = @opts[:maxbytes].andand.to_i || 2**16
-      Rails.logger.warn "@opts[:maxbytes] = #{@opts[:maxbytes]}, bytesleft = #{bytesleft}"
       IO.popen([env, 'arv-get', "#{@opts[:uuid]}/#{@opts[:file]}"],
                'rb') do |io|
         bytecount = 0
@@ -320,7 +324,6 @@ class CollectionsController < ApplicationController
           # maximum byte count to read
           if @opts.include? :maxbytes
             bytesleft = bytesleft - buf.length
-            Rails.logger.warn "bytesleft now #{bytesleft}"
           end
           yield buf
         end
diff --git a/apps/workbench/app/views/jobs/_show_log.html.erb b/apps/workbench/app/views/jobs/_show_log.html.erb
index aaae89a..01d5b18 100644
--- a/apps/workbench/app/views/jobs/_show_log.html.erb
+++ b/apps/workbench/app/views/jobs/_show_log.html.erb
@@ -53,8 +53,11 @@ var makeFilter = function() {
 <% if @object.log %>
   <% logcollection = Collection.find @object.log %>
   <% if logcollection %>
-    var log_maxbytes = <%= Rails.configuration.log_viewer_max_bytes %>
-    $.ajax('<%=j url_for logcollection %>/<%=j logcollection.files[0][1] %>',
+    var log_maxbytes = <%= Rails.configuration.log_viewer_max_bytes %>;
+    logcollection_url = '<%=j url_for logcollection %>/<%=j logcollection.files[0][1] %>';
+    $("#log-viewer-download-url").attr('href', logcollection_url);
+    $("#log-viewer-download-pane").css('display', 'inline');
+    $.ajax(logcollection_url,
 	   {
 	     headers: {'Range': 'bytes=0-' + log_maxbytes}
 	   }).
@@ -62,14 +65,14 @@ var makeFilter = function() {
 	    logViewer.filter();
 	    addToLogViewer(logViewer, data.split("\n"), taskState);
 	    logViewer.filter(makeFilter());
-	    if (data.length == log_maxbytes) {
+	    var v = jqxhr.getResponseHeader('Content-Range')
+	      .match(/bytes \d+-(\d+)\/(.+)/);
+            short_log = v && (v[2] == '*' || parseInt(v[1]) + 1 < v[2]);
+	    if (jqxhr.status == 206 && short_log) {
 	      $("#log-viewer-overview").html(
-		'<p>The log was truncated after ' + log_maxbytes +
-		' bytes. To view the entire log, run this command' +
-		' from an Arvados shell VM:</p>' +
-		' <p><span style="font-family:monospace">arv-get' +
-		' <%=j logcollection.uuid %>/<%=j logcollection.files[0][1] %>' +
-		'</p>'
+		'<p>Showing only ' + data.length + ' bytes of this log.' +
+		' Timing information is unavailable since' +
+		' the full log was not retrieved.</p>'
 	      );
             } else {
 	      generateJobOverview("#log-viewer-overview", logViewer, taskState);
@@ -134,6 +137,10 @@ $("#set-show-failed-only").on("click", function() {
     <% end %>
   </p>
 
+  <p id="log-viewer-download-pane" style="display:none">
+    <a id="log-viewer-download-url" href="">Download the full log</a>
+  </p>
+
   <div class="h3">Log
 
     <span class="pull-right">

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list