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

Baikal does not migrate mysql details on upgrade #946

Closed
kovarto opened this issue Jun 19, 2020 · 13 comments
Closed

Baikal does not migrate mysql details on upgrade #946

kovarto opened this issue Jun 19, 2020 · 13 comments

Comments

@kovarto
Copy link

kovarto commented Jun 19, 2020

Baikal version: 0.6.1-> 0.7.1

  • [x ] I have searched open and closed issues for duplicates
  • [x ] I have installed the release zip, not the source code zip
  • [x ] I have moved the whole, untouched Specific and config folders to the new installation

Problem:
The upgrade throws a php exception -
Error: Call to a member function getPDO() on null in /var/www/html/baikal/Core/Frameworks/BaikalAdmin/Controller/Install/VersionUpgrade.php:98
Stack trace:
#0 /var/www/html/baikal/Core/Frameworks/BaikalAdmin/Controller/Install/VersionUpgrade.php(68): BaikalAdmin\Controller\Install\VersionUpgrade->upgrade('0.6.1', '0.7.1')
#1 /var/www/html/baikal/Core/Frameworks/Flake/Core/Render/Container.php(69): BaikalAdmin\Controller\Install\VersionUpgrade->render()
#2 /var/www/html/baikal/Core/Frameworks/Flake/Controller/Page.php(90): Flake\Core\Render\Container->renderBlocks()
#3 /var/www/html/baikal/html/admin/install/index.php(100): Flake\Controller\Page->render()
#4 {main}

@kovarto
Copy link
Author

kovarto commented Jun 20, 2020

Solved... First upgrading to 0.7.0 and then to 0.7.1 worked.
Just fyi - running on linux 5.3.7 (fedora 31 on x86_64), using MariaDB 10.3.22

@kovarto kovarto closed this as completed Jun 20, 2020
@kovarto kovarto reopened this Jun 22, 2020
@kovarto
Copy link
Author

kovarto commented Jun 22, 2020

... closing the issue was not the best idea, as it would be great if the upgrade directly to 0.7.1 were working...

@gruenie
Copy link

gruenie commented Jul 4, 2020

I had exactly the same problem and the same error-messages like kovarto when I tried to update from 0.6.1 to 0.7.1.
Updating: 0.6.1 -> 0.7.0 -> 0.7.1 worked.
(Running on windows server 2008 R2, mysql 5.5.5)

@beowulf222
Copy link

I would like to echo what @gruenie wrote. If you want to upgrade from 0.6.1 to 0.7.1 you have to first upgrade to 0.7.0. Else, I received an error pertaining to the database hostname.

@ByteHamster ByteHamster changed the title Upgrading from 0.6.1 to 0.7.1 Baikal does not migrate mysql details on upgrade Jul 26, 2020
@fbett fbett mentioned this issue Jul 30, 2020
3 tasks
@tlahn
Copy link

tlahn commented Aug 2, 2020

I experience the same issue. Unfortunately, updating to 0.7.0 first is not an option as I am using baikal on my NAS where I can not select another intermediate version. Manually fixing config file worked as a fix for me.

@ncartron
Copy link

same problem here - upgraded the ports on my FreeBSD server, which jumped directly to Baikal 0.7.1, and hit the very same issue.
Had to manually edit baikal.yaml to have the MySQL DB details which were empty.

@MichaIng
Copy link

MichaIng commented Sep 26, 2020

Lol, all the investigation and just now I recognise the PR that contains the fix already 😄: https://github.com/sabre-io/Baikal/pull/979/files#diff-4363d89c829cff197338e61e600822c7L49-L54

Obsolete investigation, already solved above

We experience the same issue: MichaIng/DietPi#3789 (comment)
I wonder what is done differently between a migrated and a fresh install when hitting the "Save changes" button. In both cases I'd assume the baikal.yaml being written to/altered the same way, but obviously not since the outcome is different.


If 0.6.1 => 0.7.0 => 0.7.1 works, then probably this "fix" for upgrades from pre-0.6.1 broke it for upgrades from 0.6.1? I'm bad in reading PHP code 🤔: d87f028

Did someone try 0.6.0 (or earlier) => 0.7.1?


I try to derive what is done when accessing the web UI after upgrade:

  • The new config file does not exist, hence this call is done:
    $oPage->zone("Payload")->addBlock(new \BaikalAdmin\Controller\Install\Initialize());
  • Now 100% sure if this is called, but looks like which means that the old config.php and install flag file are removed and a new system config is created:
    // If we come from pre-0.7.0, we need to remove the INSTALL_DISABLED file so we go to the next step
    if (file_exists(PROJECT_PATH_SPECIFIC . '/INSTALL_DISABLED')) {
    @unlink(PROJECT_PATH_SPECIFIC . '/INSTALL_DISABLED');
    }
    if (file_exists(PROJECT_PATH_SPECIFIC . "config.php")) {
    @unlink(PROJECT_PATH_SPECIFIC . "config.php");
    }
    # Creating system config, and initializing BAIKAL_ENCRYPTION_KEY
    $oSystemConfig = new \Baikal\Model\Config\System();
    • Do I understand correctly that config.php did not contain the database settings, but config.system.php did?
  • New system config creation: https://github.com/sabre-io/Baikal/blob/master/Core/Frameworks/Baikal/Model/Config/System.php#L66-L76
    • Encryption key and MySQL flags are added during init above after this has been loaded.
  • Next step is the database upgrades: https://github.com/sabre-io/Baikal/blob/d87f0288f3b87daf80462069df1476189e9d8634/Core/Frameworks/BaikalAdmin/Controller/Install/VersionUpgrade.php
    • What I do not understand here is that neither the old database info from config.system.php have been parsed, nor new input has been done so far, so how can this migration work now? However, there is no migration for >=0.5.1 anyway.
  • Next step is, as the install flag has been removed before, the database init, which includes parsing/migrating and removal of the old config.system.php:
    if (file_exists(PROJECT_PATH_SPECIFIC . "config.system.php")) {
    require_once PROJECT_PATH_SPECIFIC . "config.system.php";
    $this->oModel->set('sqlite_file', PROJECT_SQLITE_FILE);
    $this->oModel->set('mysql', PROJECT_DB_MYSQL);
    $this->oModel->set('mysql_host', PROJECT_DB_MYSQL_HOST);
    $this->oModel->set('mysql_dbname', PROJECT_DB_MYSQL_DBNAME);
    $this->oModel->set('mysql_username', PROJECT_DB_MYSQL_USERNAME);
    $this->oModel->set('mysql_password', PROJECT_DB_MYSQL_PASSWORD);
    $this->oModel->set('encryption_key', BAIKAL_ENCRYPTION_KEY);
    if (defined("BAIKAL_CONFIGURED_VERSION")) {
    $oStandardConfig = new \Baikal\Model\Config\Standard();
    $oStandardConfig->set("configured_version", BAIKAL_CONFIGURED_VERSION);
    $oStandardConfig->persist();
    }
    }
    $this->oForm = $this->oModel->formForThisModelInstance([
    "close" => false,
    "hook.validation" => [$this, "validateConnection"],
    "hook.morphology" => [$this, "hideMySQLFieldWhenNeeded"],
    ]);
    if ($this->oForm->submitted()) {
    $this->oForm->execute();
    if ($this->oForm->persisted()) {
    if (file_exists(PROJECT_PATH_SPECIFIC . "config.system.php")) {
    @unlink(PROJECT_PATH_SPECIFIC . "config.system.php");
    }
    touch(PROJECT_PATH_SPECIFIC . '/INSTALL_DISABLED');
    }
    }

@omavoss
Copy link

omavoss commented Oct 12, 2020

Hello,
please follow the thread on https://dietpi.com/phpbb/viewtopic.php?f=12&t=8109.

To update Baikal from 0.6.1 to 0.7.1, a fix of the Baikal update procedure is necessary.
Please post a message if the problem is in progress or what you can do alternatively.

Best regards, and thanks.

@MichaIng
Copy link

To update Baikal from 0.6.1 to 0.7.1, a fix of the Baikal update procedure is necessary.

Or updating in two stages 0.6.1 => 0.7.0 => 0.7.1 as described 😉.

@omavoss
Copy link

omavoss commented Oct 12, 2020

Sorry;
where is this procedure described?

@MichaIng
Copy link

Above? Read this issue from the beginning 😉. But probably you mean a step-by-step instruction. You need to download and place each version manually from here: https://github.com/sabre-io/Baikal/releases
Then access Baikal web UI after each step and go through the update procedure before installing the next version archive.

@ghost
Copy link

ghost commented Oct 19, 2020

Had the same issue. baikal.yaml was not updated correctly so I edited manually and it worked.

@ByteHamster
Copy link
Member

Should be fixed in #979

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

No branches or pull requests

8 participants