Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Owners et editors dont get imported from config files while upgrading to 6.2.36 #459

Closed
salaun-urennes1 opened this issue Oct 30, 2018 · 6 comments
Labels

Comments

@salaun-urennes1
Copy link
Collaborator

Version

Moving from Sympa 6.2.16 to 6.2.36

Installation method

Installation from sources

Expected behavior

As stated in the changelog : Owners and moderators are no longer stored in list config file: They are stored only in database #49. However I would expect that the upgrade process to 6.2.36 would take a last look at list config files to import owners/editors in database.

Actual behavior

While running sympa.pl --upgrade I noticed a couple of these errors :

err main::#842 > Sympa::Upgrade::upgrade#137 > Sympa::List::get_lists#7932 > Sympa::List::new#420 The list "m36895_1819" has got no owner defined
err main::#842 > Sympa::Upgrade::upgrade#137 > Sympa::List::get_lists#7932 > Sympa::List::new#422 > Sympa::List::set_status_error_config#464 The list Sympa::List <m36895_1819@listes.etudiant.univ-rennes1.fr> is set in status error_config: no_owner_defined()

I checked and found out that:

  • owners are defined for this list in the config file
  • owners are not in the DB admin_table

I don't know why owners definition were not in sync between config file and database. It might be related to #11020.

The problem is that I don't have any easy way to force the update of admin_table, now that Sympa::List::_load_list_admin_from_config() subroutine has been removed.

I ended up writing this script to fix things:

#!/bin/bash
for config in `find /data/sympa/list_data -name config`
do 
  dir=$(dirname "$config")
  cd $dir 
  IFS=/ 
  path=($PWD)
  list=$(printf "%s@%s" ${path[-1]} ${path[-2]})
  echo "processing $list..."
  cat config| perl -n000e 'while (<STDIN>) {print if /^owner$/mg}' > owner.dump
  cat config| perl -n000e 'while (<STDIN>) {print if /^editor$/mg}' > editor.dump
  /usr/local/sympa/bin/sympa.pl --restore_users --list=$list --role=owner,editor  
done

It would make sense that the upgrade process does reload owners+editors from config files a last time; don't you think so?

@ikedas
Copy link
Member

ikedas commented Oct 31, 2018

Possiblly related issue: #1.

@ikedas
Copy link
Member

ikedas commented Oct 31, 2018

At least looking the source, owner/editor in config files are migrated during sympa.pl --upgrade (since 6.2.33b.1):

sympa/src/lib/Sympa/Upgrade.pm

Lines 1794 to 1810 in 4e01624

my $fh;
next unless open $fh, '<', $dir . '/config';
my $config = do { local $RS; <$fh> };
close $fh;
# Write out initial permanent owners/editors in <role>.dump files.
$config =~ s/(\A|\n)[\t ]+(?=\n)/$1/g; # normalize empty lines
open my $ifh, '<', \$config; # open "in memory" file
my @config = do { local $RS = ''; <$ifh> };
close $ifh;
foreach my $role (qw(owner editor)) {
my $file = $dir . '/' . $role . '.dump';
if (!-e $file and open my $ofh, '>', $file) {
my $admins = join '', grep {/\A\s*$role\b/} @config;
print $ofh $admins;
close $ofh;
}
}

@ikedas ikedas added the bug label Oct 31, 2018
@salaun-urennes1 salaun-urennes1 changed the title Onwers et editors dont get imported from config files while upgrading to 6.2.36 Owners et editors dont get imported from config files while upgrading to 6.2.36 Oct 31, 2018
@salaun-urennes1
Copy link
Collaborator Author

The code you mention does not help much because

  1. it is run for closed lists only
  2. it creates a dump of owners/editors, based on the config file, but does not import them in the admin_table

I suggest changing the upgrade code to

  1. create owner.dump and editor.dump for all lists
  2. import these admins in admin_table

@ikedas
Copy link
Member

ikedas commented Oct 31, 2018

Your suggestion looks right. However, I wonder why some lists won’t sync owners/editors with db despite they were open. I’ll investigate for a while.

@ikedas
Copy link
Member

ikedas commented Nov 3, 2018

I'll merge pr above into the next beta today. Please check if it will work.

ikedas added a commit that referenced this issue Nov 3, 2018
@salaun-urennes1
Copy link
Collaborator Author

I did a quick test: it seems to do the job.
Thank you Soji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants