OpenMediaVault-Plugin-Developers / openmediavault-docker-gui

Docker plugin for OpenMediaVault
32 stars 17 forks source link

Docker GUI plugin breaks configuration saving #67

Closed artiomn closed 6 years ago

artiomn commented 6 years ago

I can't save configuration at the first attempt, if the docker gui plugin was installed (I have an error message about empty file in /tmp/). After removing plugin, configuration saving run correctly.

artiomn commented 6 years ago
Ошибка #0:
OMV\Exception: Failed to read file '/tmp/bgstatus3Sq0Bj' (size=0). in /usr/share/php/openmediavault/json/file.inc:199
Stack trace:
#0 /usr/share/php/openmediavault/json/file.inc(214): OMV\Json\File->getContents()
#1 /usr/share/php/openmediavault/rpc/serviceabstract.inc(342): OMV\Json\File->read()
#2 /usr/share/php/openmediavault/rpc/serviceabstract.inc(533): OMV\Rpc\ServiceAbstract->updateBgProcStatus('/tmp/bgstatus3S...', 'outputfilename', '/tmp/bgoutputB3...')
#3 /usr/share/php/openmediavault/rpc/serviceabstract.inc(154): OMV\Rpc\ServiceAbstract->execBgProc(Object(Closure))
#4 /usr/share/openmediavault/engined/rpc/config.inc(213): OMV\Rpc\ServiceAbstract->callMethodBg('applyChanges', Array, Array)
#5 [internal function]: OMVRpcServiceConfig->applyChangesBg(Array, Array)
#6 /usr/share/php/openmediavault/rpc/serviceabstract.inc(123): call_user_func_array(Array, Array)
#7 /usr/share/php/openmediavault/rpc/rpc.inc(86): OMV\Rpc\ServiceAbstract->callMethod('applyChangesBg', Array, Array)
#8 /usr/sbin/omv-engined(536): OMV\Rpc\Rpc::call('Config', 'applyChangesBg', Array, Array, 1)
#9 {main}
ryecoaaron commented 6 years ago

This is a known error (probably a php bug) that has been discussed in the forum many times. Definitely nothing the plugin can do to fix it.

votdev commented 6 years ago

I think the problem is writing the file, not reading. But as @ryecoaaron mentioned this problem may be caused by PHP.

artiomn commented 6 years ago

It's very similar to the race condition.

artiomn commented 6 years ago

I.e.:

        // Create a background process. 
        $bgStatusFilename = $this->createBgProcStatus(); 
        $pid = $this->fork(); 
        if ($pid > 0) { 
            $this->initializeBgProcStatus($bgStatusFilename, $pid); 
            return $bgStatusFilename; 
        } 

        // Child process. 
        try { 
            $bgOutputFilename = $this->createBgProcOutput(); 
            $this->updateBgProcStatus( 
                $bgStatusFilename, 
                "outputfilename", 
                $bgOutputFilename 
            );
artiomn commented 6 years ago

I don't know your code, but as I can understand, in this fragment you create a file and write data in the parent process and, then immediately update this file inside child process. Maybe need guards?

votdev commented 6 years ago

The file is exclusive locked on access and blocks until the file is unlocked, so this doesn't seem to be the problem.

artiomn commented 6 years ago

Well, I understood you. I don't know what I did, but the bug doesn't repeat. All works fine.