Skip to content

icinga2: address comment loading where host reference is not found#9861

Merged
julianbrost merged 2 commits intoIcinga:masterfrom
ymartin-ovh:issue-9752
Jan 7, 2025
Merged

icinga2: address comment loading where host reference is not found#9861
julianbrost merged 2 commits intoIcinga:masterfrom
ymartin-ovh:issue-9752

Conversation

@ymartin-ovh
Copy link
Contributor

address #9752: check if host reference is valid

@cla-bot
Copy link

cla-bot bot commented Sep 11, 2023

Thank you for your pull request. Before we can look at it, you'll need to sign a Contributor License Agreement (CLA).

Please follow instructions at https://icinga.com/company/contributor-agreement to sign the CLA.

After that, please reply here with a comment and we'll verify.

Contributors that have not signed yet: @ymartin-ovh

Details
  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Please contact us if you think this is the case.

  • If you signed the CLA as a corporation, your GitHub username may not have been submitted to us. Please reach out to the responsible person in your organization.

@cla-bot
Copy link

cla-bot bot commented Sep 12, 2023

Thank you for your pull request. Before we can look at it, you'll need to sign a Contributor License Agreement (CLA).

Please follow instructions at https://icinga.com/company/contributor-agreement to sign the CLA.

After that, please reply here with a comment and we'll verify.

Contributors that have not signed yet: @ymartin-ovh

Details
  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Please contact us if you think this is the case.

  • If you signed the CLA as a corporation, your GitHub username may not have been submitted to us. Please reach out to the responsible person in your organization.

@bobapple
Copy link
Member

@cla-bot check

@cla-bot cla-bot bot added the cla/signed label Sep 15, 2023
@julianbrost
Copy link
Member

@Al2Klimov Please explain what #7786 has to do with this/what exactly this is supposed to fix here.

Anyways, Comment::OnAllConfigLoaded() even states in the validation error it can throw that it's supposed to handle non-existent hosts ("Comment '...' references a host/service which doesn't exist."), but apparently has a bug there, so that null check there should definitely by done.

@ymartin-ovh
Copy link
Contributor Author

Hello @julianbrost / @Al2Klimov

Should I rebase my diff with just null check in comment.cpp ?

Regards

Copy link
Member

@Al2Klimov Al2Klimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a27c6cf is exactly what I wanted, but as a PR on its own into #7786. I.e. your new PR's spec:

  • Base branch: bugfix/api-runtime-object-sync-order (not master)
  • Commits: a27c6cf
  • Also mention me there once done

@ymartin-ovh
Copy link
Contributor Author

Hello @Al2Klimov

I can do that but the commit you want does not address the bug I submitted.
We have to deal with the null reference use.

Regards

@ymartin-ovh
Copy link
Contributor Author

I rollback to my original contribution about null reference check.

Al2Klimov
Al2Klimov previously approved these changes Oct 9, 2023
Copy link
Member

@Al2Klimov Al2Klimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that null check there should definitely by done

#9861 (comment)

I agree.

@Al2Klimov Al2Klimov removed their assignment Oct 9, 2023
@Al2Klimov Al2Klimov requested a review from julianbrost October 9, 2023 15:33
@Al2Klimov Al2Klimov added this to the 2.15.0 milestone Oct 9, 2023
@Al2Klimov Al2Klimov added the bug Something isn't working label Oct 9, 2023
@ymartin-ovh
Copy link
Contributor Author

Hello

Do you plan to integrate this fix in 2.14.x branch too ? We have this issue in 2.14, I maintain my own build because of this.

Regards

if (GetServiceName().IsEmpty() || ! host)
m_Checkable = host;
else
m_Checkable = host->GetServiceByShortName(GetServiceName());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#9861 (comment):

I maintain my own build because of this.

Sounds like it should already be tested?

Copy link
Member

@julianbrost julianbrost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that there's error handling for m_Checkable being nullptr following, it looks it host (which is a possible value for m_Checkable is expected to possibly be nullptr:

if (!m_Checkable)
BOOST_THROW_EXCEPTION(ScriptError("Comment '" + GetName() + "' references a host/service which doesn't exist.", GetDebugInfo()));

So that check looks like a good idea indeed.

Side note: while quickly reading over the related issue, I noticed the following comment (#9752 (comment)):

I'm trying to understand why master does not send hostgroups configuration first.

Actually, the config object send order was tweaked by the just merged #10000, so that could also have an effect here. Though, as per what I wrote earlier in this comment, having a nullptr check here is a good idea nonetheless.

@julianbrost julianbrost merged commit 880632b into Icinga:master Jan 7, 2025
@Al2Klimov
Copy link
Member

@Al2Klimov Al2Klimov added the backported Fix was included in a bugfix release label Feb 4, 2025
@ymartin-ovh ymartin-ovh deleted the issue-9752 branch January 16, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backported Fix was included in a bugfix release bug Something isn't working cla/signed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants