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

Director background daemon: Call to a member function getBranch() on null (v1.10) #2633

Closed
Yoda-BZH opened this issue Oct 11, 2022 · 6 comments
Assignees
Labels
Milestone

Comments

@Yoda-BZH
Copy link

Since the configuration-branch update on director, the background daemon (icinga-director) stopped working.

Expected Behavior

The icinga-director service should run every automation job declared (url: /director/jobs).

Current Behavior

The service generate some errors :

icingadirector@servername:~$ /usr/bin/icingacli director daemon run 
UNEXPECTED: Got invalid NetString data: 
Fatal error: Uncaught Error: Call to a member function getBranch() on null in /usr/share/icingaweb2/modules/director/library/Director/Import/Sync.php:900
Stack trace:
#0 /usr/share/icingaweb2/modules/director/library/Director/Objects/SyncRule.php(158): Icinga\Module\Director\Import\Sync->apply()
#1 /usr/share/icingaweb2/modules/director/library/Director/Objects/SyncRule.php(198): Icinga\Module\Director\Objects\SyncRule->checkForChanges(true)
#2 /usr/share/icingaweb2/modules/director/library/Director/Job/SyncJob.php(56): Icinga\Module\Director\Objects\SyncRule->applyChanges()
#3 /usr/share/icingaweb2/modules/director/library/Director/Job/SyncJob.php(27): Icinga\Module\Director\Job\SyncJob->runForRule(Object(Icinga\Module\Director\Objects\SyncRule))
#4 /usr/share/icingaweb2/modules/director/library/Director/Objects/DirectorJob.php(90): Icinga\Module\Director\Job\SyncJob->run()
#5 /usr/share/icingaweb2/modules/director/application/clicommands/JobsCommand.php(36): Icinga\Module\Director\Objects\DirectorJob->run()
#6 /usr/shar in /usr/share/icingaweb2/modules/director/library/Director/Import/Sync.php on line 900
Job (JOBNAME) failed: Process exited with exit code 255

Possible Solution

quick&dirty fix:

library/Director/Import/Sync.php
@@ -883,9 +883,11 @@ class Sync
             }
 
             $this->run->setProperties($runProperties);
+            if($this->store) {
             if (!$this->store->getBranch()->isBranch()) {
                 $this->run->store();
             }
+            }
             $this->notifyResolvers();
             if (! $this->store) {
                 $dba->commit();
@@ -895,9 +897,10 @@ class Sync
             $this->run->set('duration_ms', (int) round(
                 (microtime(true) - $this->runStartTime) * 1000
             ));
+            if($this->store) {
             if (!$this->store->getBranch()->isBranch()) {
                 $this->run->store();
-            }
+            }}
 
             Benchmark::measure('Done applying objects');
         } catch (Exception $e) {

Steps to Reproduce (for bugs)

Update to v1.10 and use the background daemon.

Your Environment

  • Director version (System - About): v1.10 (support branch)
  • Icinga Web 2 version and modules (System - About): 2.11.1
  • Icinga 2 version (icinga2 --version): 2.13.5-1.bullseye
  • Operating System and version: Debian 11
  • Webserver, PHP versions: nginx, 7.4.30-1+deb11u1
@Yoda-BZH
Copy link
Author

Yoda-BZH commented Oct 11, 2022

note: I don't have the configuration branch feature enabled.

(edit: sentencing)

@Thomas-Gelf Thomas-Gelf self-assigned this Oct 11, 2022
@Thomas-Gelf Thomas-Gelf added this to the v1.10.2 milestone Oct 11, 2022
@Thomas-Gelf
Copy link
Contributor

Thanks for reporting this, will be fixed

@Thomas-Gelf
Copy link
Contributor

Hint: the proposed workaround avoids errors, but seems to stop job execution

@Thomas-Gelf
Copy link
Contributor

Update: job execution continues with that fix, but it's outcome isn't going to be stored. This has an impact on "Purge" and other cleanup mechanisms

@Thomas-Gelf
Copy link
Contributor

@Yoda-BZH: please try the patch in 21bb6c5, I'll cherry-pick it to support/1.10 and release it with v1.10.2

Thomas-Gelf added a commit that referenced this issue Nov 3, 2022
@Yoda-BZH
Copy link
Author

Yoda-BZH commented Nov 3, 2022

seem good :)

Thanks !

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