Skip to content

dird: director tries to connect to client when connection is disabled#1099

Merged
pstorz merged 4 commits intobareos:masterfrom
alaaeddineelamri:dev/alaaeddineelamri/master/director-connect-to-client-when-connection-no
Apr 7, 2022
Merged

dird: director tries to connect to client when connection is disabled#1099
pstorz merged 4 commits intobareos:masterfrom
alaaeddineelamri:dev/alaaeddineelamri/master/director-connect-to-client-when-connection-no

Conversation

@alaaeddineelamri
Copy link
Contributor

Description

When Connection From Director To Client = no, the director tries anyway to connect but fails. Connection should not be even tried in the first place. This PR fixes the issue.

Please check

  • Short description and the purpose of this PR is present above this paragraph
  • Your name is present in the AUTHORS file (optional)

If you have any questions or problems, please give a comment in the PR.

Helpful documentation and best practices

Checklist for the reviewer of the PR (will be processed by the Bareos team)

General
  • PR name is meaningful
  • Purpose of the PR is understood
  • Separate commit for this PR in the CHANGELOG.md, PR number referenced is same
  • Commit descriptions are understandable and well formatted
  • If backport: add original PR number and target branch at top of this file: Backport of PR#000 to bareos-2x
Source code quality
  • Source code changes are understandable
  • Variable and function names are meaningful
  • Code comments are correct (logically and spelling)
  • Required documentation changes are present and part of the PR
  • bareos-check-sources --since-merge does not report any problems
  • git status should not report modifications in the source tree after building and testing
Tests
  • Decision taken that a system- or unittest is required (if not, then remove this paragraph)
  • The decision towards a systemtest is reasonable compared to a unittest
  • Testname matches exactly what is being tested
  • Output of the test leads quickly to the origin of the fault

@alaaeddineelamri alaaeddineelamri requested a review from arogge March 3, 2022 16:00
@alaaeddineelamri alaaeddineelamri changed the title Dev/alaaeddineelamri/master/director connect to client when connection no dird: director tries to connects to client when connection is disabled Mar 4, 2022
@alaaeddineelamri alaaeddineelamri changed the title dird: director tries to connects to client when connection is disabled dird: director tries to connect to client when connection is disabled Mar 4, 2022
@alaaeddineelamri alaaeddineelamri force-pushed the dev/alaaeddineelamri/master/director-connect-to-client-when-connection-no branch from 45ab2ab to b148169 Compare March 4, 2022 13:31
Copy link
Member

@pstorz pstorz left a comment

Choose a reason for hiding this comment

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

I think it would make sense to create a gtest instead of a system test.
We only need to check if the connection request is denied when the configuration is configured correctly.


if (!IsConnectingToClientAllowed(jcr)) {
Dmsg1(120, "connecting to client \"%s\" is not allowed.\n",
Dmsg1(120, "Connection from director to client \"%s\" is not allowed.\n",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Dmsg1(120, "Connection from director to client \"%s\" is not allowed.\n",
Dmsg1(120, "Connecting to client \"%s\" is not allowed.\n",

Copy link
Member

Choose a reason for hiding this comment

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

I would suggest to keep the wording unified (You added "Connecting to %s is not allowed" in line 231, so I would suggest to call it like this here also. Or we would need to update all other occurrences to contain the word "director" also.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's the only occurrence of IsConnectingToClientAllowed(jcr) where there is a message returned. Adding a from director to client makes sense in my opinion to specify the exact reason on that occasion. But IsConnectFromClientAllowed(jcr) has a few occurrences that I can easily update.

For line 231, I did not add a from since both types of connection would be closed. If the check is verified, there is no way to connect to the client at all.

Copy link
Member

Choose a reason for hiding this comment

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

The "from director" is not needed as dmesg log entries are prefixed witht he daemon name that logs.

@pstorz pstorz self-assigned this Mar 9, 2022
@alaaeddineelamri alaaeddineelamri force-pushed the dev/alaaeddineelamri/master/director-connect-to-client-when-connection-no branch from b148169 to 0b64ae5 Compare March 9, 2022 10:13
@alaaeddineelamri alaaeddineelamri requested a review from pstorz March 9, 2022 10:14
@alaaeddineelamri alaaeddineelamri force-pushed the dev/alaaeddineelamri/master/director-connect-to-client-when-connection-no branch 3 times, most recently from 6fe30c5 to 6d8698c Compare March 24, 2022 09:05
@alaaeddineelamri alaaeddineelamri force-pushed the dev/alaaeddineelamri/master/director-connect-to-client-when-connection-no branch from 6d8698c to 2d912cf Compare March 24, 2022 14:07

if (!IsConnectingToClientAllowed(jcr)) {
Dmsg1(120, "connecting to client \"%s\" is not allowed.\n",
Dmsg1(120, "Connection from director to client \"%s\" is not allowed.\n",
Copy link
Member

Choose a reason for hiding this comment

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

The "from director" is not needed as dmesg log entries are prefixed witht he daemon name that logs.

@alaaeddineelamri alaaeddineelamri force-pushed the dev/alaaeddineelamri/master/director-connect-to-client-when-connection-no branch from 2d912cf to 68a9290 Compare March 25, 2022 09:27
@alaaeddineelamri alaaeddineelamri requested a review from pstorz March 25, 2022 09:28
@alaaeddineelamri alaaeddineelamri force-pushed the dev/alaaeddineelamri/master/director-connect-to-client-when-connection-no branch 2 times, most recently from 452bb90 to 8c8bea6 Compare April 4, 2022 08:30
Copy link
Member

@pstorz pstorz left a comment

Choose a reason for hiding this comment

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

I think printing out the logfiles in case of error when running inside of jenkins will help us to find problems faster.

@alaaeddineelamri alaaeddineelamri force-pushed the dev/alaaeddineelamri/master/director-connect-to-client-when-connection-no branch 2 times, most recently from 8fc55f3 to 1bbb2fc Compare April 5, 2022 15:48
Alaa Eddine Elamri added 4 commits April 6, 2022 15:17
Test crashes in case the checks do not work properly
introduced testing function that uses grep
to check expected strings in log files
@alaaeddineelamri alaaeddineelamri force-pushed the dev/alaaeddineelamri/master/director-connect-to-client-when-connection-no branch from 1bbb2fc to f4d68c7 Compare April 6, 2022 13:17
@arogge arogge requested a review from pstorz April 7, 2022 09:26
@pstorz pstorz merged commit 61b4f7d into bareos:master Apr 7, 2022
@pstorz pstorz deleted the dev/alaaeddineelamri/master/director-connect-to-client-when-connection-no branch April 7, 2022 10:40
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

Successfully merging this pull request may close these issues.

2 participants