Bug 2057615
| Summary: | [RFE] - Ability to use Metric role "metrics_from_mssql" option and the SQL Server roles together | |||
|---|---|---|---|---|
| Product: | Red Hat Enterprise Linux 8 | Reporter: | Brian Smith <briasmit> | |
| Component: | pcp | Assignee: | Nathan Scott <nathans> | |
| Status: | CLOSED ERRATA | QA Contact: | Jan Kurik <jkurik> | |
| Severity: | unspecified | Docs Contact: | Jacob Taylor Valdez <jvaldez> | |
| Priority: | unspecified | |||
| Version: | 8.5 | CC: | agerstmayr, jkurik, limershe, nathans, nhosoi, rmeggins, spetrosi | |
| Target Milestone: | rc | Keywords: | FutureFeature, Triaged | |
| Target Release: | 8.7 | Flags: | pm-rhel:
mirror+
|
|
| Hardware: | Unspecified | |||
| OS: | Unspecified | |||
| Whiteboard: | ||||
| Fixed In Version: | pcp-5.3.7-1.el8 | Doc Type: | No Doc Update | |
| Doc Text: | Story Points: | --- | ||
| Clone Of: | ||||
| : | 2058778 (view as bug list) | Environment: | ||
| Last Closed: | 2022-11-08 09:21:23 UTC | Type: | Bug | |
| Regression: | --- | Mount Type: | --- | |
| Documentation: | --- | CRM: | ||
| Verified Versions: | Category: | --- | ||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | ||
| Cloudforms Team: | --- | Target Upstream Version: | ||
| Embargoed: | ||||
| Bug Depends On: | ||||
| Bug Blocks: | 2058778 | |||
|
Description
Brian Smith
2022-02-23 17:46:20 UTC
Hmm, these should be able to work together. This snippet is from the metrics role README.md ... | metrics_from_mssql: no | | Boolean flag allowing metrics from SQL Server to be made available. | Enabling this flag requires a 'trusted' connection to SQL Server. Is the SQL Server role setting things up to allow trusted connections or does it setup older-style username/password style connections? There may be more diagnostic details in your /var/log/pcp/pmcd/mssql.log file for us here, Brian. The underlying ansible-pcp and pmdamssql(1) code supports both modes, so if its the latter we'll need to tweak the metrics role. I believe the SQL Server role is setting up username/password connections.
[root@rhel8-server2 ~]# cat /var/log/pcp/pmcd/mssql.log
Log for pmdamssql on rhel8-server2.example.com started Thu Feb 24 10:02:02 2022
[Thu Feb 24 10:02:02] pmdamssql(61267) Info: Connecting to tcp:localhost as user sa
[Thu Feb 24 10:02:02] pmdamssql(61267) Error: mssql_connect: connecting using trusted connection: ('HY000', '[HY000] [Microsoft][ODBC Driver 17 for SQL Server]SSPI Provider: No Kerberos credentials available (default cache: KCM:) (851968) (SQLDriverConnect)')
[Thu Feb 24 10:02:03] pmdamssql(61267) Error: mssql_connect: connecting using trusted connection: ('HY000', '[HY000] [Microsoft][ODBC Driver 17 for SQL Server]SSPI Provider: No Kerberos credentials available (default cache: KCM:) (851968) (SQLDriverConnect)')
[Thu Feb 24 10:02:04] pmdamssql(61267) Error: mssql_connect: connecting using trusted connection: ('HY000', '[HY000] [Microsoft][ODBC Driver 17 for SQL Server]SSPI Provider: No Kerberos credentials available (default cache: KCM:) (851968) (SQLDriverConnect)')
[Thu Feb 24 10:02:05] pmdamssql(61267) Error: mssql_connect: connecting using trusted connection: ('HY000', '[HY000] [Microsoft][ODBC Driver 17 for SQL Server]SSPI Provider: No Kerberos credentials available (default cache: KCM:) (851968) (SQLDriverConnect)')
[Thu Feb 24 10:02:07] pmdamssql(61267) Error: mssql_connect: connecting using trusted connection: ('HY000', '[HY000] [Microsoft][ODBC Driver 17 for SQL Server]SSPI Provider: No Kerberos credentials available (default cache: KCM:) (851968) (SQLDriverConnect)')
[Thu Feb 24 10:02:08] pmdamssql(61267) Error: mssql_connect: connecting using trusted connection: ('HY000', '[HY000] [Microsoft][ODBC Driver 17 for SQL Server]SSPI Provider: No Kerberos credentials available (default cache: KCM:) (851968) (SQLDriverConnect)')
[Thu Feb 24 10:02:09] pmdamssql(61267) Info: FATAL: failed to connect after 5 retries
Log finished Thu Feb 24 10:02:09 2022
[root@rhel8-server2 ~]# cat /var/lib/pcp/pmdas/mssql/mssql.conf
[connection]
driver={ODBC Driver 17 for SQL Server}
server=tcp:localhost
timeout=2
[authentication]
## General reference on authentication options:
#https://docs.microsoft.com/en-us/sql/relational-databases/security/choose-an-authentication-mode
# Option 1: Mixed mode authentication
username=sa
password=<sa account password>
# Option 2: Windows authentication
trusted=False
[root@rhel8-server2 ~]# pminfo mssql
mssql
[root@rhel8-server2 ~]#
If I edit /var/lib/pcp/pmdas/mssql/mssql.conf, and comment out the "trusted=" line, I can then: [root@rhel8-server2 ~]# systemctl restart pmcd [root@rhel8-server2 ~]# pminfo mssql | wc -l 168 [root@rhel8-server2 ~]# cat /var/log/pcp/pmcd/mssql.log Log for pmdamssql on rhel8-server2.example.com started Thu Feb 24 10:05:10 2022 [Thu Feb 24 10:05:10] pmdamssql(61798) Info: Connecting to tcp:localhost as user sa [Thu Feb 24 10:05:10] pmdamssql(61798) Info: Microsoft SQL Server 2019 (RTM-CU15) (KB5008996) - 15.0.4198.2 (X64) ; Jan 12 2022 22:30:08 ; Copyright (C) 2019 Microsoft Corporation; Enterprise Evaluation Edition (64-bit) on Linux (Red Hat Enterprise Linux 8.5 (Ootpa)) <X64> [Thu Feb 24 10:05:10] pmdamssql(61798) Info: Setup complete So it appears that with the "trusted=" line commented out it is able to connect. I understand the root cause and have a fix now (in the PCP mssql agent python code).
In the meantime, Louis has found the following workaround requiring no code changes:
- hosts: localhost
roles:
- role: rhel-system-roles.metrics
vars:
metrics_from_mssql: yes
mssql_agent_trusted:
mssql_agent_username: sa
mssql_agent_password: RedHat123!
Overriding the 'mssql_agent_trusted' to have an empty value, and passing in the username/password (I did not realize we could pass settings through like that - neat!). Based on my earlier discussions with SQL Server folks I suspect that strongly preferring to use 'trusted' connections as the metrics role currently does is still the right thing to do. So I'm a little hesitant to change the docs to describe this approach.
Anyway, the code is fixed - problem was to do with python strings being cast to boolean type via bool() and this kind of behavior:
$ python3
Python 3.10.2 (main, Jan 17 2022, 00:00:00) [GCC 11.2.1 20211203 (Red Hat 11.2.1-7)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> foo = 'False'
>>> print(bool(foo))
True
>>>
Ultimately, the PCP mssql agent needed to take more care with its input. In the code fix I've kept things such that Louis' workaround (with empty mssql_agent_trusted setting) will continue to work, for both new and old versions of PCP being used by the role.
I'll leave this BZ as-is for now to give folks a chance to comment. However, in time I think this BZ will need to move to the 'pcp' component, and we'll deliver the code fix in 8.7 and 9.1 (as reflected in BZ state already).
We ran into something similar and use distutils.util.strtobool for situations like this: https://pagure.io/fork/rmeggins/standard-test-roles/blob/linux-system-roles/f/inventory/standard-inventory-qcow2#_735 bool(distutils.util.strtobool(os.environ.get("TEST_USE_BASENAME", "False"))) https://docs.python.org/3/distutils/apiref.html#distutils.util.strtobool and - in yaml
somevalue:
is equivalent to
{"somevalue": None}
in python
(In reply to Rich Megginson from comment #7) > We ran into something similar and use distutils.util.strtobool for > situations like this: Yep, found that too. I initially used it but found it has recently been marked deprecated (gives a runtime warning on f35) - https://www.python.org/dev/peps/pep-0632/ (In reply to Nathan Scott from comment #9) > (In reply to Rich Megginson from comment #7) > > We ran into something similar and use distutils.util.strtobool for > > situations like this: > > Yep, found that too. I initially used it but found it has recently been > marked deprecated (gives a runtime warning on f35) - > https://www.python.org/dev/peps/pep-0632/ Hmm - there are several suggestions for "roll your own" implementations - https://stackoverflow.com/questions/715417/converting-from-a-string-to-boolean-in-python And the pep explicit says "you are on your own": "For these functions, and any others not mentioned here, you will need to reimplement the functionality yourself. The legacy documentation can be found at https://docs.python.org/3.9/distutils/apiref.html: distutils.util.strtobool " so I guess we'll add that to the pile of tech debt @briasmit is the workaround listed in https://bugzilla.redhat.com/show_bug.cgi?id=2057615#c6 acceptable, or do we need to get an exception/blocker for 8.6/9.0? (In reply to Rich Megginson from comment #11) > @briasmit is the workaround listed in > https://bugzilla.redhat.com/show_bug.cgi?id=2057615#c6 acceptable, or do we > need to get an exception/blocker for 8.6/9.0? Acceptable until 8.7/9.1 that is (In reply to Rich Megginson from comment #12) > (In reply to Rich Megginson from comment #11) > > @briasmit is the workaround listed in > > https://bugzilla.redhat.com/show_bug.cgi?id=2057615#c6 acceptable, or do we > > need to get an exception/blocker for 8.6/9.0? > > Acceptable until 8.7/9.1 that is Yes, if we have a workaround for 8.6/9.0, lets target this BZ for 8.7/9.1. Also discussed this with Louis and he agrees. Thanks! Thanks all. Switching component to 'pcp' as that's where the code change is, hence this is the package needing update. Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (pcp bug fix and enhancement update), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2022:7474 |