Uploaded image for project: 'Percona Monitoring and Management'
  1. Percona Monitoring and Management
  2. PMM-4879

Ability to read connection details from MySQL config file passed by --defaults-file flag

Details

    • 3
    • Platform Sprint 15, Platform Sprint 16
    • Yes
    • Yes
    • Yes
    • No
    • Implex

    Description

      The following have not been implemented:

      • --defaults-file

      The absence of the ability to use a Mysql Config (my.cnf) file for connection config is bad for automation:

      • it forces a password to be set in the command line
      • it leads to the possibility that the password appears in logs and is shipped off somewhere
      • it removes the ability to check if a password should change by detecting a change in the cnf file

      Use case

      As PMM user I need to be able to specify  --defaults-file flag as a path to .cnf file so that I can skip passing --user-name and --password  options while adding DB and they will be extracted from config file 

       

      Acceptance criteria:

      • User able to specify a path to defaults file
      • If username and password is passed along with defaults path, the flags have highest priority and values (username and password) from file are ignored
      • Parsing defaults file should be done by pmm-agent****

      UI: 

      pmm-admin add mysql --defaults-file=~/my.sandbox.cnf  MyDB 127.0.0.1 
      

       Also, Feature should be available by API (for future UI  improvements) and follow common logic - implement logic in pmm-agent, not  pmm-admin 

      Note:

      • this is username and password related. We are not adding support of other fields from config file
      • If password changed  - user need to re-add Service to the system, as it goes with usual --password/–username  flags 

      Out of scope:

      • Handling encrypted credentials.

      Suggested solution:

      • Add --defaults-file flag to pmm-admin add mysql command
      • Add new field `defaults_file` to management API for MySQL
      • Add new action to extract credentials from defaults file
      • Extract username and password on pmm-agent side
        • Use ini parser for it.
      • Return Username and password from the action
      • Save returned username and password to agent model
      • Check connection

       

      How to test:

      1. Run PMM server.
      2. Run MySQL.
      3. Run PMM agent and prepare defaults file. e.g.:

      [client] 
      host=127.0.0.1 
      port=12345 
      user=root123 
      password=root-password123  

      Please remember to change credentials for proper one for MySQL database.
      4. Use pmm-admin with --defaults-file parameter and path to file 

      pmm-admin add mysql --defaults-file=~/.my.cnf 

      5. You can replace username/password just to check if have highest priority:

      pmm-admin add mysql --defaults-file=~/.my.cnf --username=bad 
      pmm-admin add mysql --defaults-file=~/.my.cnf --password=wrong

      6. It should throws credentials error during connection test

      Attachments

        Issue Links

          Activity

            People

              przemyslaw.kadej Przemyslaw Kadej
              ceri.williams Ceri Williams
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - Not Specified
                  Not Specified
                  Logged:
                  Time Spent - 20 minutes
                  20m

                  Smart Checklist