Skip to content
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

Error when creating User with mariadb_user method #198

Closed
sinfomicien opened this issue Apr 23, 2018 · 4 comments
Closed

Error when creating User with mariadb_user method #198

sinfomicien opened this issue Apr 23, 2018 · 4 comments
Milestone

Comments

@sinfomicien
Copy link
Contributor

sinfomicien commented Apr 23, 2018

On the first run, it successfully create the user. During the second run, and all others, got this error:
` * mariadb_user[stagingReachApi] action create

================================================================================
Error executing action `create` on resource 'mariadb_user[stagingFakeUser]'
================================================================================

RuntimeError
------------
Mysql query error: Operation CREATE USER failed for 'stagingFakeUser'@'%'

Cookbook Trace:
---------------
/var/chef/cache/cookbooks/mariadb/libraries/mariadb_conn_helper.rb:51:in `rescue in query'
/var/chef/cache/cookbooks/mariadb/libraries/mariadb_conn_helper.rb:47:in `query'
/var/chef/cache/cookbooks/mariadb/resources/user.rb:35:in `run_query'
/var/chef/cache/cookbooks/mariadb/resources/user.rb:198:in `block (2 levels) in class_from_file'
/var/chef/cache/cookbooks/mariadb/resources/user.rb:188:in `block in class_from_file'

Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/r_mariadb_reach/recipes/staging.rb

  5: mariadb_user 'stagingFakeUser' do
  6:   password 'xxx1Always1xxx'
  7:   grant_option true
  8:   database_name 'staging_fake_db'
  9:   host '%'
 10:   privileges [:all]
 11: end

Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/r_mariadb_reach/recipes/staging.rb:5:in `from_file'

mariadb_user("stagingFakeUser") do
  action [:create]
  default_guard_interpreter :default
  declared_type :mariadb_user
  cookbook_name "r_mariadb_fake"
  recipe_name "staging"
  password "*sensitive value suppressed*"
  grant_option true
  database_name "staging_fake_db"
  host "%"
  privileges [:all]
  username "stagingFakeUser"
end

`

@sinfomicien
Copy link
Contributor Author

Don't know why the current_resource is not loaded by the load_current_value method... But to circumvent the problem, we can perhaps add 'CREATE USER IF NOT EXISTS' instead of just 'CREATE USER' . What do you think ?

@jmadureira
Copy link

Can you please check if the problem you're having is related with #191 ?

@sinfomicien
Copy link
Contributor Author

It was partially the problem 😀

You identified the first problem i hit. But there's a second one. My ctrl_host is really localhost, while host is != localhost. It this case, when i use Mysql2, it does not try to connect to localhost/3306, but rather try to use the default socket (/tmp/mysql.sock).

So i also had to replace host by ctrl_host on line 178, plus your patch, and it correct this bug. Could you modify your PR to do so ? So it will correct y bug as well as yours.

@sinfomicien sinfomicien added this to the 1.5.4 milestone May 21, 2018
@lock
Copy link

lock bot commented May 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators May 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants