-
Notifications
You must be signed in to change notification settings - Fork 19
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
Uncaught Error: Call to a member function setTimezone() on bool in /usr/share/icingaweb2/modules/icingadb/library/Icingadb/Common/ObjectInspectionDetail.php:240 #462
Comments
Which version of Icinga 2 are you using? |
I'm not entirely sure what the best way to report that would be. Icinga itself reports at
Does that help? |
The executed in the container looks the same as the code I linked, changing it to this at least allow me to see the service details: private function formatTimestamp($ts)
{
if (empty($ts)) {
return new EmptyState(t('n. a.'));
}
if (is_float($ts)) {
$dt = DateTime::createFromFormat('U.u', $ts);
} else {
$dt = (new DateTime())->setTimestamp($ts);
}
return 'fnord';;
return $dt->setTimezone(new DateTimeZone('UTC'))
->format('Y-m-d\TH:i:s.vP');
} |
I meant the Icinga 2 (not Web) version. |
Is this helpful?
|
Inspecting the code further, the timestamps are stuff like |
No, Icinga DB requires Icinga 2.13.2. |
Icinga DB (RC2) should not run at all in your setup. |
Not quite sure what I'm doing wrong here - AFAIK I'm on the current docker containers as of today |
One
later, with this configuration https://github.com/dwt/docker-compose-icinga (derived from your docker compose file) I'm still getting icinga version r2.13.0-1. Still investigating |
Can you try this? lippserd/docker-compose-icinga#16 |
I would do the following in order to recreate the setup:
|
After re-checking, I'm now fairly sure I'm running this image: https://hub.docker.com/layers/icinga/icinga2/master/images/sha256-fce8b596d0554de8397cbdb37b0c986848a6f9fb76222116c7e865072622733e?context=explore - which AFAIK is the current master image of icinga. Is that representing an old version? If I get you correct, icinga2:master is too old to work correctly with icingadb-web? I will have time tomorrow to look into the pull request you provided and get that working. |
Correct
|
My PR uses the latest tag (default) instead of master so that the latest release versions are used. If you continue to have problems, please head over to the forums. |
Well, I was switching to master, to check out features implemented after bug reports I raised. Then everything kind of deteriorated. I will try switching back to :latest for further experiments if possible. |
I understand but your master image is not really the master image 😆 |
Well, I do find that kind of confusing. I would have guessed that an image called :master kind of represents the master branch... Is there some documentation you guys maintain which images to use to get what from the repos? |
I don' think that this is our problem. Your image reports 2.13.0. But a fresh pull reports the following: #462 (comment) |
I think I'm starting to see ghosts. This is the latest image I can see linked from docker hub When I pull that with this command:
It tells me it succeeded. When I then run this with:
I get this ridiculously (?) old version. How am I not running the latest published image from docker hub? Am I completely misunderstanding how docker works here? |
Well, seems I am running the latest code, even if it doesn't look it. So maybe the PHP code to do the date formatting does actually have a bug? |
Sorry, I was not aware of this version display bug. What versions of Icinga DB and Icinga DB Web are you using? |
I am on the current :master images of each of them from today on docker hub. Specifically I am on these images:
They self-identify as:
I have no clue how to get the version out of icingadb. :-( Does that help? |
There was a similar bug in the past and it has already been fixed #242. Can you please |
@dwt Did you start with fresh Volumes for Redis and MySQL? |
That would be unsurprising - and mean missing error handling.
Yes, yesterday - not today. I'll try it again after I have reported the output of @yhabteab asked for. |
@yhabteab I have modified the code to this: private function formatTimestamp($ts)
{
if (empty($ts)) {
return new EmptyState(t('n. a.'));
}
if (is_float($ts)) {
$dt = DateTime::createFromFormat('U.u', $ts);
if ( ! $dt ) {
var_dump($ts); var_dump($dt); die;
}
} else {
$dt = (new DateTime())->setTimestamp($ts);
}
return $dt->setTimezone(new DateTimeZone('UTC'))
->format('Y-m-d\TH:i:s.vP');
} For me this creates this output:
Which is surprising, as it looks completely benign? |
Might there be some kind of localization issue at play and php represents the float with a ',' instead of a '.' as is expected by the formatting function? |
@lippserd yes, starting with fresh volumes, the issue is still reproducible. |
That could be true but I don't know how 😆 Which language are you using for Web 2? Could you try the following fix pls:
Note the |
@lippserd that |
Nah. It's
That's weird. Maybe |
But that clearly shows that it has to do with localization. Edit: Default is 6 digits for |
Hey, if you have any other ideas for experiments, I'll gladly run them for you. Other than that: It seems that |
Sorry, but for such small unexpected things error handling is just code smell. We'll fix the bug and no error handling is needed. The exception isn't bad, it's only just this single view that is affected. So unless the bug won't crash the webserver and lock out every user on the instance, I choose less code smell. 😉 |
@lippserd sorry, missed your question: 'Which language are you using for Web 2?' English I believe, nothing changed from the default config on the image. In my understanding Docker does not inherit any environment variable from the starting shell - especially using Checking the environment inside the container doesn't seem to expose anything |
Environment in the container:
|
I am pretty confident that this is caused by an input from the request. Switching the browser languages around, i.e. 'Accept-Language: en-US,en;q=0.7,de;q=0.3' doesn't trigger the issue, while 'Accept-Language: de,en-US;q=0.7,en;q=0.3' does. |
Well, I'm not a PHP expert of course, but I have to say that I'm a bit confused by your perspective. Ignoring error codes is never a good thing, and a complex API like this that takes hidden inputs (it seems Localization plays a role here) - I am a bit lost why you would think of error checking as a code smell. I mean, every error is unexpected - but to build robust software we still handle them because thats what it means to build robust software. That's why we have unit tests that check that we actually handle them, because otherwise it's just impossible to test that stuff by hand. /rant over - of course this is your software, so you can do as you please. But collectively this missing check / bug has now cost us several hours of work time. (I don't even want to try to convert that into currency). I would like to make the argument that this is a pretty solid case that error checking (and then handling them!) complex and surprising functions from the PHP core library is a good idea. |
Testing is the way to go. If I have a good/robust test, I'll find bugs and fix them, no need for error handling then. Granted, we don't unit test this part of the code. We did however ran many manual tests in the past and this issue never appeared. Some things just slip through. And it's still a release candidate, so you're also testing. 😉 Any error handling isn't code smell of course, only in this instance. What should we do instead here? Ignore the faulty value? Would you have opened this issue then? I guess not. Sometimes it's better that the user get's an exception, it's also easier for us to fix the issue then instead of having to ask for more and more details. |
Well, if I had to code error handling in this case, several things come to mind:
I would prefer option 1. as the old directive - if I can't handle an error, raise a good error message instead is always a good fallback. |
Dude this is a bug. There won’t be any error handling. Please stop this now. |
Hi there, I was expecting to be able to test this bug fix in the latest image at some point - so far I'm still seeing this issue. Anything I'm doing wrong? Shouldn't this be auto released? |
If you're talking about our docker images, |
@nilmerg that is what I'm trying - my understanding is that this image should contain the fix? |
Unfortunately, no, the image also just uses the RC2, not the current master. (Icinga/docker-icingaweb2#62) |
Hi there,
on the current docker containers (that is from 2021-11-22) when clicking on a failed check and trying to check out 'Source' - this stack trace occurs:
This code seems faulty (though it looks good).
Any idea what is happening? Do I have a missing configuration or is that code wrong?
The text was updated successfully, but these errors were encountered: