
jbrandt at bestpractical
Aug 9, 2013, 7:17 AM
Post #1 of 1
(10 views)
Permalink
|
|
rt branch, 4.2/fixup-version-history, created. rt-4.1.17-5-g1426745
|
|
The branch, 4.2/fixup-version-history has been created at 1426745f80e4dd663a53b3422c71bce46c85d469 (commit) - Log ----------------------------------------------------------------- commit 884b1538125b17fb8a42380f8d42b29b4a1c2260 Author: Jim Brandt <jbrandt [at] bestpractical> Date: Fri Jul 5 10:58:45 2013 -0400 Hide upgrade history from global attributes on config page Skipped the entry in code since applying a Limit removed the upgrade history when calling the attribute methods in the Upgrade history section later on the page. diff --git a/share/html/Admin/Tools/Configuration.html b/share/html/Admin/Tools/Configuration.html index 71d1702..0802938 100644 --- a/share/html/Admin/Tools/Configuration.html +++ b/share/html/Admin/Tools/Configuration.html @@ -216,6 +216,7 @@ for my $type (qw/Tickets Queues Transactions Groups PrivilegedUsers Unprivileged % my $attrs = $RT::System->Attributes; % my $index_size = 0; % while ( my $attr = $attrs->Next ) { +% next if $attr->Name eq 'UpgradeHistory'; <tr class="<% $index_size%2 ? 'oddline' : 'evenline'%>"> % if ($attr->Name eq 'UserLogo') { % my $content = $attr->Content; commit 689e66a9b331c0e3bb2847c1b17213791e360b3c Author: Jim Brandt <jbrandt [at] bestpractical> Date: Fri Aug 9 09:29:03 2013 -0400 Add ids to recorded upgrade entries to track success/failure Installations and upgrades can run into issues that cause the upgrade scripts to die. Add ids to track this history and aid in future troubleshooting. full_id: An id for multi-step upgrades from 'make upgrade-database' The full_id tags each individual upgrade step as part of the larger upgrade to unambiguously show that individual upgrades were run as part of a full upgrade. individual_id: An id to bookend the start and end of an upgrade step and identify if a step failed to complete. Adds Data::GUID as a guid generator. diff --git a/sbin/rt-setup-database.in b/sbin/rt-setup-database.in old mode 100644 new mode 100755 index 05d0364..6f20b61 --- a/sbin/rt-setup-database.in +++ b/sbin/rt-setup-database.in @@ -70,6 +70,7 @@ BEGIN { # BEGIN RT CMD BOILERPLATE use Term::ReadKey; use Getopt::Long; +use Data::GUID; $| = 1; # unbuffer all output. @@ -189,6 +190,7 @@ print "Working with:\n" my $package = $args{'package'} || 'RT'; my $ext_version = $args{'ext-version'}; +my $full_id = Data::GUID->new->as_string; foreach my $action ( @actions ) { no strict 'refs'; @@ -271,6 +273,7 @@ sub action_insert { $file = $RT::EtcPath . "/initialdata" if $init && !$file; $file ||= $args{'datadir'}."/content"; + my $individual_id = Data::GUID->new->as_string(); my @ret; my $upgrade = sub { @ret = $RT::Handle->InsertData( $file, $root_password ) }; @@ -305,7 +308,10 @@ sub action_insert { action => 'insert', filename => Cwd::abs_path($file), content => $content, - stage => 'after',); + stage => 'after', + type => 'process initialdata', + full_id => $full_id, + individual_id => $individual_id ); $upgrade_data{'ext_version'} = $ext_version if $ext_version; @@ -410,12 +416,16 @@ sub action_upgrade { from => $upgrading_from, to => $upgrading_to, versions => [@versions], + full_id => $full_id, + individual_id => $full_id }); my $previous = $upgrading_from; my ( $ret, $msg ); foreach my $n ( 0..$#versions ) { my $v = $versions[$n]; + my $individual_id = Data::GUID->new->as_string(); + my @back = grep {-e $_} map {"$base_dir/$versions[$_]/backcompat"} $n+1..$#versions; print "Processing $v\n"; @@ -425,6 +435,8 @@ sub action_upgrade { stage => 'before', from => $previous, to => $v, + full_id => $full_id, + individual_id => $individual_id, }); my %tmp = (%args, datadir => "$base_dir/$v", datafile => undef, backcompat => \@back); @@ -453,6 +465,8 @@ sub action_upgrade { stage => 'after', from => $previous, to => $v, + full_id => $full_id, + individual_id => $individual_id, }); $previous = $v; @@ -465,6 +479,8 @@ sub action_upgrade { from => $upgrading_from, to => $upgrading_to, versions => [@versions], + full_id => $full_id, + individual_id => $full_id, }); return 1; diff --git a/sbin/rt-test-dependencies.in b/sbin/rt-test-dependencies.in index f5376ee..b29fe1e 100644 --- a/sbin/rt-test-dependencies.in +++ b/sbin/rt-test-dependencies.in @@ -180,6 +180,7 @@ CGI::Emulate::PSGI CGI::PSGI 0.12 Class::Accessor 0.34 CSS::Squish 0.06 +Data::GUID Date::Extract 0.02 Date::Manip DateTime 0.44 commit ce353dc5dfe677e2b683a5d63edb76d238c37029 Author: Jim Brandt <jbrandt [at] bestpractical> Date: Fri Aug 9 10:03:59 2013 -0400 Add before entry to insert actions Add a before to the upgrade history to track progress on possible failures and match the other before/after upgrade history pairs. Capture the return code in the after entry. diff --git a/sbin/rt-setup-database.in b/sbin/rt-setup-database.in index 6f20b61..4392ed0 100755 --- a/sbin/rt-setup-database.in +++ b/sbin/rt-setup-database.in @@ -274,6 +274,19 @@ sub action_insert { $file ||= $args{'datadir'}."/content"; my $individual_id = Data::GUID->new->as_string(); + + my %upgrade_data = ( + action => 'insert', + filename => Cwd::abs_path($file), + stage => 'before', + type => 'process initialdata', + full_id => $full_id, + individual_id => $individual_id ); + + $upgrade_data{'ext_version'} = $ext_version if $ext_version; + + RT->System->AddUpgradeHistory($package => \%upgrade_data); + my @ret; my $upgrade = sub { @ret = $RT::Handle->InsertData( $file, $root_password ) }; @@ -304,12 +317,13 @@ sub action_insert { RT->ConnectToDatabase(); - my %upgrade_data = ( + %upgrade_data = ( action => 'insert', filename => Cwd::abs_path($file), content => $content, stage => 'after', type => 'process initialdata', + return_value => join (', ', @ret), full_id => $full_id, individual_id => $individual_id ); commit 1426745f80e4dd663a53b3422c71bce46c85d469 Author: Jim Brandt <jbrandt [at] bestpractical> Date: Fri Aug 9 10:08:35 2013 -0400 Updates to initial display of RT upgrade history The initial upgrade history section on the Configuration page wasn't fully polished. Make full upgrades and their child upgrade entries clearer and show current version of RT and installed extensions for convenience. Also show upgrades that didn't appear to finish. diff --git a/share/html/Admin/Tools/Configuration.html b/share/html/Admin/Tools/Configuration.html index 0802938..ef903c0 100644 --- a/share/html/Admin/Tools/Configuration.html +++ b/share/html/Admin/Tools/Configuration.html @@ -268,46 +268,142 @@ if ($item =~ /^\s*(.*?)\s*v(\S+);/) { </&> <&|/Widgets/TitleBox, title => loc("RT upgrade history")&> +<%perl> +my $upgrade_history = RT->System->UpgradeHistory; +my @packages = ('RT', sort grep { $_ ne 'RT' } keys %$upgrade_history); + +if ( not $upgrade_history->{'RT'} ){ + $upgrade_history->{'RT'} = [. + { stage => 'before', + action => 'No upgrade history found', + type => 'individual upgrade', + timestamp => '', + from => 'N/A', + to => 'N/A', + rt_version => '', + individual_id => '1', + }, + { stage => 'after', + individual_id => '1', + }]; +} + +for my $package (@packages) { + my $version_status = "Current version: "; + if ( $package eq 'RT' ){ + $version_status .= $RT::VERSION; + } + elsif ( grep {/$package/} @{RT->Config->Get('Plugins')} ) { + { + no strict 'refs'; + $version_status .= ${ $package . '::VERSION' }; + } + } + else { + $version_status = "Not currently loaded"; + } +</%perl> -% my $upgrade_history = RT->System->UpgradeHistory; -% my @packages = ('RT', sort grep { $_ ne 'RT' } keys %$upgrade_history); -% for my $package (@packages) { -<h4><% $package %></h4> +<h4><% $package . ' (' . $version_status . ')' %></h4> <table border="0" cellspacing="0" cellpadding="5" width="100%" class="collection"> <tr class="collection-as-table"> +<th class="collection-as-table"> </th> <th class="collection-as-table"><&|/l&>Action</&></th> +<th class="collection-as-table"><&|/l&>Date</&></th> <th class="collection-as-table"><&|/l&>Using RT Version</&></th> -<th class="collection-as-table"><&|/l&>Time</&></th> -<th class="collection-as-table"><&|/l&>Extra</&></th> <%perl> - my $i = 0; - for my $upgrade (@{ $upgrade_history->{$package} }) { - # only list completed upgrades - next unless $upgrade->{stage} eq 'after'; + my @upgrades; + my @failed; +UPGRADE: foreach my $upgrade ( @{$upgrade_history->{$package}} ){ + my $i = 0; + if ( $upgrade->{'stage'} + and $upgrade->{'stage'} eq 'before' ){ + push @upgrades, $upgrade->{'individual_id'}; + } + elsif ( $upgrade->{'stage'} + and $upgrade->{'stage'} eq 'after' ){ + + while ( my $before_id = pop @upgrades ){ + # It's the matching after for the last before + next UPGRADE if $before_id = $upgrade->{'individual_id'}; + + # Didn't match, so we didn't see an after for this id + push @failed, $before_id; + } + } + + my $tr_class = 'oddline'; + if ( $package eq 'RT' ){ + if ( $upgrade->{'type'} ne 'full upgrade' ) { + $tr_class = 'evenline'; + $tr_class .= ' upgrade-history-' . $upgrade->{'full_id'} + if $upgrade->{'full_id'}; + } + } + else { + $tr_class = $i++ %2 ? 'oddline' : 'evenline'; + } + if ( $upgrade->{'type'} eq 'full upgrade' ){ + my $parent_id = $upgrade->{'full_id'}; </%perl> -<tr class="<% $i++ %2 ? 'oddline' : 'evenline'%>"> - <td class="collection-as-table"> -% if ($upgrade->{action} eq 'upgrade') { # type is more specific for upgrades - <% $upgrade->{type} %> -% } else { - <% $upgrade->{action} %> -% } - </td> - <td class="collection-as-table"> - <% $upgrade->{rt_version} %> - </td> - <td class="collection-as-table"> + <tr class="oddline"> + <td class="upgrade-history-parent" id="parent-upgrade-history-<% $parent_id %>"> + <span class="widget"><a href="#" onclick="return toggleClassElement('<% 'upgrade-history-' . $parent_id %>');"></a></span></td> +% } else { +<tr class="<% $tr_class %>"> +<td class="collection-as-table"></td> +% } +% if ( $upgrade->{'type'} ne 'full upgrade' ){ +%# and $full_upgrade ){ +<td class="collection-as-table" style="padding-left:15px"> +% } else { +<td class="collection-as-table"> +% } +% if ($upgrade->{'action'} eq 'upgrade') { # type is more specific for upgrades +<% $upgrade->{'type'} eq 'full upgrade' ? "Upgrade" : "Individual upgrade" %> +<&|/l, $upgrade->{'from'}, $upgrade->{'to'} &>from [_1] to [_2]</&> +% } elsif ( $upgrade->{'action'} eq 'insert' ) { +<% "Insert from " . $upgrade->{'filename'} %> +% } else { +<% ucfirst($upgrade->{action}) %> +% } +</td> +<td class="collection-as-table"> % my $timestamp = RT::Date->new($session{CurrentUser}); % $timestamp->Set(Value => $upgrade->{timestamp}); <% $timestamp->AsString %> </td> <td class="collection-as-table"> -% if ($upgrade->{action} eq 'upgrade') { - <&|/l, $upgrade->{from}, $upgrade->{to} &>from [_1] to [_2]</&> -% } + <% $upgrade->{rt_version} %> </td> </tr> +<%perl> +} +# Ids remaining on @upgrades also failed as they didn't have an +# after entry to pop them off +foreach my $id ( @failed, @upgrades ){ + my ($entry) = grep { $_->{'individual_id'} eq $id } @{$upgrade_history->{$package}}; + my $message; + my $timestamp = RT::Date->new($session{CurrentUser}); + $timestamp->Set(Value => $entry->{timestamp}); + + if ( $entry->{'action'} eq 'upgrade' ){ + $message = 'Upgrade attempt from ' . $entry->{'from'} + . ' to ' . $entry->{'to'} . ' on ' . $timestamp->AsString + . ' did not finish.'; + } + elsif ( $entry->{'action'} eq 'insert' ){ + $message = 'Insert attempt with filename ' . $entry->{'filename'} + . ' on ' . $timestamp->AsString + . ' did not finish.'; + } + else { + $message = 'An upgrade step on ' . $timestamp->AsString + . ' did not finish.'; + } +</%perl> +<tr class="oddline"><td class="collection-as-table" colspan=4><% $message %></td></tr> % } </table> % } diff --git a/share/static/css/base/collection.css b/share/static/css/base/collection.css index d690192..f82ec2c 100644 --- a/share/static/css/base/collection.css +++ b/share/static/css/base/collection.css @@ -14,3 +14,16 @@ table.collection td:first-child, table.collection th:first-child { .collection-as-table .user a:visited { color: inherit; } + +.upgrade-history-parent .widget a { + display: inline-block; + margin: 0; + width: 20px; + background-image: url('../../../static/images/css/rollup-arrow.gif'); + background-repeat: no-repeat; + background-position: center 0; + position: static; + top: 0.5em; + left: 1.2em; + padding: 7px 0 0 0; +} diff --git a/share/static/js/util.js b/share/static/js/util.js index 8b91092..40c4b37 100644 --- a/share/static/js/util.js +++ b/share/static/js/util.js @@ -30,6 +30,19 @@ function switchVisibility(id1, id2) { return false; } +/* Show/hide with class */ + +function toggleClassElement(className) { + jQuery("." + className).toggle(); + if ( jQuery("." + className).is(":hidden") ){ + jQuery("#parent-" + className).find("a").css("background-image", "url('../../../static/images/css/rolldown-arrow.gif')"); + } + else{ + jQuery("#parent-" + className).find("a").css("background-image", "url('../../../static/images/css/rollup-arrow.gif')"); + } + return false; +} + /* Classes */ function jQueryWrap( id ) { return typeof id == 'object' ? jQuery(id) : jQuery('#'+id); ----------------------------------------------------------------------- _______________________________________________ Rt-commit mailing list Rt-commit [at] lists http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-commit
|