vinted / chef-proxysql Goto Github PK
View Code? Open in Web Editor NEWChef ProxySQL cookbook with auto loading and comprehensive configuration
License: MIT License
Chef ProxySQL cookbook with auto loading and comprehensive configuration
License: MIT License
currently this cookbook appears to be hardcoded for proxysql 1.x. would you take a PR for allowing this cookbook to install both 1.x and 2.x?
Replacing systemd with poise_service abstraction will add init support.
I ran into this problem with having 1500 connections on one of my systems. Proxysql was throwing errors and bringing the load to a halt.
The proxysql user default open files limit is 1024 and that restricts the number of db connections proxysql can handle. The guys at Proxysql suggested this in the systemd unit file:
LimitNOFILE=102400
Is there a way we can add extra options to the unit file that is being created by the proxysql cookbook so that we can change this value as needed?
Thanks!
Me again. lol
I have had an issue when I set up multiple admin interfaces in the admin_variables section:
mysql_ifaces: '127.0.0.1:6032;/var/run/proxysql/proxysql.sock'
The code looks to see if there is a .sock in the string and then adds the string to the command that is used in the load-config command.
connection = if admin_mysql_ifaces =~ /\.sock/
"--socket #{admin_mysql_ifaces}"
else
host, port = admin_mysql_ifaces.split(':')
"--host #{host} --port #{port}"
end
And I get this error:
mysql --user=admin --password=admin --socket localhost:6032;/var/run/proxysql/proxysql.sock returned 2
I have fixed it with this code:
connection = if admin_mysql_ifaces =~ /.sock/
iface = admin_mysql_ifaces.split(";").select {|inf| inf =~ /.sock/}
"--socket #{iface.first}"
else
host, port = admin_mysql_ifaces.split(':')
"--host #{host} --port #{port}"
end
Thanks again for this cookbook!
While the multiple admin credential feature was added in #41, that update did not include fixes for the validation function to support multiple credentials in the admin_credential attribute.
Looking at:
chef-proxysql/libraries/proxysql_service.rb
Lines 156 to 163 in 6b11505
you can see the if statement doesn't check for multiple credentials
Maybe something like:
if admin_credentials.split(';').first.split(':').size != 2
Though the above seems a bit ugly. Any other ideas?
I was deploying a cookbook which included recipes from chef-proxysql and there were some issues, as you see in the stack trace and the logs below:
Compiling Cookbooks...
================================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/proxysql/libraries/base_service.rb
================================================================================
FrozenError
-----------
can't modify frozen Array
Cookbook Trace:
---------------
/var/chef/cache/cookbooks/poise/files/halite_gem/poise/helpers/subresources/container.rb:220:in `included'
/var/chef/cache/cookbooks/poise/files/halite_gem/poise/resource.rb:51:in `include'
/var/chef/cache/cookbooks/poise/files/halite_gem/poise/resource.rb:51:in `poise_subresource_container'
/var/chef/cache/cookbooks/poise/files/halite_gem/poise.rb:93:in `block in Poise'
/var/chef/cache/cookbooks/proxysql/libraries/base_service.rb:8:in `include'
/var/chef/cache/cookbooks/proxysql/libraries/base_service.rb:8:in `<class:ProxysqlBaseService>'
/var/chef/cache/cookbooks/proxysql/libraries/base_service.rb:7:in `<class:Resource>'
/var/chef/cache/cookbooks/proxysql/libraries/base_service.rb:6:in `<class:Chef>'
/var/chef/cache/cookbooks/proxysql/libraries/base_service.rb:5:in `<top (required)>'
Relevant File Content:
----------------------
/var/chef/cache/cookbooks/poise/files/halite_gem/poise/helpers/subresources/container.rb:
213: @container_default
214: end
215: end
216:
217: def included(klass)
218: super
219: klass.extend(ClassMethods)
220>> klass.const_get(:HIDDEN_IVARS) << :@subcontexts
221: klass.const_get(:FORBIDDEN_IVARS) << :@subcontexts
222: end
223: end
224:
225: extend ClassMethods
226: end
227: end
228: end
229: end
Additional information:
-----------------------
Ruby objects are often frozen to prevent further modifications
when they would negatively impact the process (e.g. values inside
Ruby's ENV class) or to prevent polluting other objects when default
values are passed by reference to many instances of an object (e.g.
the empty Array as a Chef resource default, passed by reference
to every instance of the resource).
Chef uses Object#freeze to ensure the default values of properties
inside Chef resources are not modified, so that when a new instance
of a Chef resource is created, and Object#dup copies values by
reference, the new resource is not receiving a default value that
has been by a previous instance of that resource.
Instead of modifying an object that contains a default value for all
instances of a Chef resource, create a new object and assign it to
the resource's parameter, e.g.:
fruit_basket = resource(:fruit_basket, 'default')
# BAD: modifies 'contents' object for all new fruit_basket instances
fruit_basket.contents << 'apple'
# GOOD: allocates new array only owned by this fruit_basket instance
fruit_basket.contents %w(apple)
System Info:
------------
chef_version=14.14.29
platform=ubuntu
platform_version=18.04
ruby=ruby 2.5.7p206 (2019-10-01 revision 67816) [x86_64-linux]
program_name=chef-client worker: ppid=974;start=08:36:34;
executable=/opt/chef/bin/chef-client
As I looked this issue up, it appears that this was an issue with Poise 2.8.1 which is a dependency of this cookbook, as somebody asked the Poise maintainer in this issue and that issue was fixed in this commit which is a part of Poise 2.8.2 Release, so long story short, I will make a PR to bump the poise version in this cookbook's requirements to 2.8.2
Thanks.
I have found the issue and have fixed it here: https://github.com/daveallen/chef-proxysql/blob/bf28b662378fae01686f14a3a08199a61157f200/libraries/proxysql_service.rb#L314-L325
The issue is that when an OS is using systemd it adds a systemd service when an init style service is added. So that when this is run: https://github.com/daveallen/chef-proxysql/blob/bf28b662378fae01686f14a3a08199a61157f200/libraries/proxysql_service.rb#L231-L242
systemctl is-active #{constructed_service_name} returns 'active' executing the load-config command before the service is in place and functioning.
The code I have added removes the initial systemd service that points to the init style service.
The proxysql cookbook is setting this in the repository.rb attributes file:
default['proxysql']['package_version'] = "#{node['proxysql']['version']}-1.1.#{lsb_release}"
So when any other cookbooks set the ['proxysql']['version'] attribute the ['proxysql']['package_version'] attribute has already set with what is in the proxysql cookbook ignoring what the wrapper cookbook set.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.