-
Notifications
You must be signed in to change notification settings - Fork 21
(FM-2577) - Change from sqlcmd.exe to win32ole connector #99
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
Conversation
cyberious
commented
May 4, 2015
- remove dependency to sqlcmd.exe and temp files, gives us more control and ability to get error messages back
- Login contains GO in sql query which breaks with new method
- Removes GO and adds the TRY and CATCH used throughout
- Move config to $::vardir/cache/sqlserver instead of in C:/Program Files/Microsoft SQL Server/.puppet
@@ -1,17 +1,61 @@ | |||
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'sqlserver')) | |||
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'puppet_x/sqlserver/sql_connection')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wheeeeee. I've never understood when and why things go in puppet_x
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a convention I believe that came out of moving non puppet related code out. @hunner maybe you could give a better history of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds great! I would like to understand the history of this.
A couple of minor requests:
|
end | ||
|
||
def has_errors | ||
return @exception_caught != nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return
is not necessary here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to have it? I prefer the explicit for readability but I have not strong opinion either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used to prefer the explicit return
as well, but it's not idiomatic Ruby.... and we tend to not use it in any of the newer Puppet core code unless it's for a short-circuit return
. It's also nice to be consistent given the file has a mix of both styles.
See some of the newer Windows code in Puppet core - you'll see we only have short-circuit returns.
https://github.com/puppetlabs/puppet/blob/master/lib/puppet/util/windows/file.rb
https://github.com/puppetlabs/puppet/blob/master/lib/puppet/util/windows/com.rb
https://github.com/puppetlabs/puppet/blob/master/lib/puppet/util/windows/api_types.rb
https://github.com/puppetlabs/puppet/blob/master/lib/puppet/util/windows/security.rb
https://github.com/puppetlabs/puppet/blob/master/lib/puppet/util/windows/sid.rb
https://github.com/puppetlabs/puppet/blob/master/lib/puppet/util/windows/taskscheduler.rb
@Iristyle Moved into separate commit for config change |
@Iristyle previously we were parsing the JSON in PowerShell which doesn't care about the quotes, however Ruby wants the quotes to always be double quotes instead. |
@@ -2,6 +2,5 @@ fixtures: | |||
forge_modules: | |||
acl: "puppetlabs/acl" | |||
stdlib: "puppetlabs/stdlib" | |||
acl: "puppetlabs/acl" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting... duplicate eh?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think this came from a merge conflict.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right on.
connection_string << "Data Source=localhost\\#{config['instance']};" | ||
else | ||
connection_string << "Data Source=localhost;" | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this? As in why am I seeing localhost here on either side of the config?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Data source should not always be localhost unless I'm missing something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So for example we have a named instance on the localhost you have to have \Instance name, if it is however the default instance of MSSQLSERVER and you add localhost\MSSQLSERVER it will fail the connection.
bundle exec rake validate was fine until ruby -c spec/functions/sqlserver_upcase_spec.rb
spec/functions/sqlserver_upcase_spec.rb:1:in `require': cannot load such file -- spec (LoadError)
rake aborted!
Command failed with status (1): [ruby -c spec/functions/sqlserver_upcase_sp...]
/Users/rob/code/puppetlabs/MODULES/puppetlabs-sqlserver/Rakefile:13:in `block (2 levels) in <top (required)>'
/Users/rob/code/puppetlabs/MODULES/puppetlabs-sqlserver/Rakefile:12:in `each'
/Users/rob/code/puppetlabs/MODULES/puppetlabs-sqlserver/Rakefile:12:in `block in <top (required)>' I'm guessing it is this line: #! /usr/bin/env ruby -S rspec |
I also got a duplicate constant warning when running specs: rob@skylight:~/code/puppetlabs/modules/puppetlabs-sqlserver [(fd38dfd...)] 10:40:03 $ bundle exec rake spec
/opt/boxen/rbenv/versions/2.1.5/bin/ruby -I/opt/boxen/rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.3/lib:/opt/boxen/rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rspec-support-3.2.2/lib /opt/boxen/rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/rspec-core-3.2.3/exe/rspec --pattern spec/\{classes,defines,unit,functions,hosts,integration\}/\*\*/\*_spec.rb --color
/Users/rob/code/puppetlabs/MODULES/puppetlabs-sqlserver/spec/fixtures/modules/sqlserver/lib/puppet_x/sqlserver/sql_connection.rb:6: warning: already initialized constant PuppetX::Sqlserver::SqlConnection::CONNECTION_CLOSED
/Users/rob/code/puppetlabs/MODULES/puppetlabs-sqlserver/lib/puppet_x/sqlserver/sql_connection.rb:6: warning: previous definition of CONNECTION_CLOSED was here
Uninstalling all features for instance MYSQLSERVER because an empty array was passed, please use ensure absent instead.==========> | ETA: 00:00:01
Uninstalling all sql server features not tied into an instance because an empty array was passed, please use ensure absent instead.====> | ETA: 00:00:01
263/263 |========================================================================= 100 =========================================================================>| Time: 00:00:05
Finished in 5.03 seconds (files took 0.98677 seconds to load)
263 examples, 0 failures
All the specs that could run on OSX passed though. I think it's likely it just loaded the file twice for specs. As long as it isn't there for normal runs, I have no issues with this. |
Clean up the validate issue though, please. |
- remove dependency to sqlcmd.exe and temp files, gives us more control and ability to get error messages back - Login contains GO in sql query which breaks with new method - Removes GO and adds the TRY and CATCH used throughout - Change config to double quotes, Ruby does not parse JSON with single quotes
@ferventcoder resolved |
@@ -1,4 +1,3 @@ | |||
#! /usr/bin/env ruby -S rspec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
(FM-2577) - Change from sqlcmd.exe to win32ole connector
So what happened with attribution? |
@Iristyle yeah, that still needs to be added. @cyberious would you follow up with that? |
@Iristyle not a blocker to merge but I agree it should be added. |
Any code remnants have been completely rewritten, so attribution is no longer necessary. |