Rails 5.2.0 images.attach results in InvalidSignature error - rails-activestorage

I am upgrading to Rails 5.2.0 and attempting to use ActiveStorage to save images from a data feed. In development.rb I have config.active_storage.service = :local and the model has has_many_attached :images and storage.yml has the default :local settings and the controller action has
def listing_params
params.require(:listing).permit(:beds, :baths, :price, :parking, :description, :active, :prop_type, :latitude, :longitude, :address, :city, :city_id, :state, :state_id, :zip, :lo_name, :la_fname, :la_lname, :la_phone, :la_email, :mlsid, :cp, :st_number, :st_suffix, :baths_full, :baths_half, :status, :modtime, :st_name, :featured, :school_id, :picture_count, :parking_type, images: [])
end
My code is getting hung up on this line
listing.images.attach(pics) with this error: ActiveSupport::MessageVerifier::InvalidSignature: ActiveSupport::MessageVerifier::InvalidSignature
My code:
def perform
require 'aws-sdk-s3'
require 'rets'
client = Rets::Client.new({
login_url: LOGIN_URL,
username: LOGIN,
password: PASSWORD,
version: VERSION
})
begin
client.login
rescue => e
puts 'Error: ' + e.message
exit!
end
p "Logged in"
Listing.find_each do |listing|
mlsid = listing.mlsid
photos = client.objects '*', {
resource: 'Property',
object_type: 'Photo',
resource_id: mlsid
}
p "about to attempt to attach #{photos.count} images to listing#{listing.id}"
pics = []
photos.each do |data|
pics << data.body
end
listing.images.attach(pics)
puts "#{photos.count} images attached to listing##{listing.id}"
end
end
And the full error after running with --trace:
tomb$ rake update:listing_images --trace
** Invoke update:listing_images (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute update:listing_images
Cookie#domain returns dot-less domain name now. Use Cookie#dot_domain if you need "." at the beginning.
"Logged in"
"about to attempt to attach 16 images to listing2873"
rake aborted!
ActiveSupport::MessageVerifier::InvalidSignature: ActiveSupport::MessageVerifier::InvalidSignature
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/activesupport-5.2.0/lib/active_support/message_verifier.rb:176:in `verify'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/activestorage-5.2.0/app/models/active_storage/blob.rb:43:in `find_signed'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/activestorage-5.2.0/lib/active_storage/attached.rb:30:in `create_blob_from'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/activestorage-5.2.0/lib/active_storage/attached/many.rb:26:in `block in attach'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/activestorage-5.2.0/lib/active_storage/attached/many.rb:22:in `collect'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/activestorage-5.2.0/lib/active_storage/attached/many.rb:22:in `attach'
/Users/tomb/Projects/schoolsparrow/app/jobs/listing_image_job.rb:43:in `block in perform'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/activerecord-5.2.0/lib/active_record/relation/batches.rb:70:in `block (2 levels) in find_each'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/activerecord-5.2.0/lib/active_record/relation/batches.rb:70:in `each'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/activerecord-5.2.0/lib/active_record/relation/batches.rb:70:in `block in find_each'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/activerecord-5.2.0/lib/active_record/relation/batches.rb:136:in `block in find_in_batches'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/activerecord-5.2.0/lib/active_record/relation/batches.rb:238:in `block in in_batches'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/activerecord-5.2.0/lib/active_record/relation/batches.rb:222:in `loop'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/activerecord-5.2.0/lib/active_record/relation/batches.rb:222:in `in_batches'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/activerecord-5.2.0/lib/active_record/relation/batches.rb:135:in `find_in_batches'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/activerecord-5.2.0/lib/active_record/relation/batches.rb:69:in `find_each'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/activerecord-5.2.0/lib/active_record/querying.rb:11:in `find_each'
/Users/tomb/Projects/schoolsparrow/app/jobs/listing_image_job.rb:31:in `perform'
/Users/tomb/Projects/schoolsparrow/lib/tasks/update.rake:21:in `block (2 levels) in <top (required)>'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:271:in `block in execute'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:271:in `each'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:271:in `execute'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:213:in `block in invoke_with_call_chain'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:193:in `invoke_with_call_chain'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/task.rb:182:in `invoke'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:160:in `invoke_task'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `each'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:116:in `block in top_level'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:125:in `run_with_threads'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:110:in `top_level'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:83:in `block in run'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/rake-12.3.1/lib/rake/application.rb:80:in `run'
/Users/tomb/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/rake-12.3.1/exe/rake:27:in `<top (required)>'
/Users/tomb/.rbenv/versions/2.3.7/bin/rake:22:in `load'
/Users/tomb/.rbenv/versions/2.3.7/bin/rake:22:in `<main>'
Tasks: TOP => update:listing_images

You’re passing an array of Rets::Parser::Multipart::Part objects to ActiveStorage::Attached::Many#attach. It doesn’t know how to handle them.
For each photo, call #attach with an IO and a filename:
photos.each_with_index do |photo, index|
listing.images.attach(io: StringIO.new(photo.body), filename: "photo-#{index + 1}.png")
end

Related

Error in reactor loop escaped: closed stream (IOError)

I am trying to setup logstash in my system, below are the steps I followed
Downloaded the zip file logstash-7.12.0-windows-x86_64.zip from the official website Download Logstash free
Unzipped and executed this command bin/logstash.bat -f logstash-sample.conf --log.level debug
Logstash started the API successfully, but it got shutdown and showing the below error
Error in reactor loop escaped: closed stream (IOError)
logstash-sample.conf file
input { stdin { } }
output {
elasticsearch { hosts => ["localhost:9200"] }
stdout { codec => rubydebug }
}
see the log
[2022-07-21T10:10:24,558][INFO ][logstash.runner ] Logstash shut down.
[2022-07-21T10:10:24,576][DEBUG][logstash.agent ] Error in reactor loop escaped: closed stream (IOError)
[2022-07-21T10:10:24,579][DEBUG][logstash.agent ] 2022-07-21 10:10:24 +0530: Listen loop error: #<IOError: closed stream>
org/jruby/RubyIO.java:3552:in `select'
C:/Development_Avecto/dev_tools/logstash-7.12.0/vendor/bundle/jruby/2.5.0/gems/puma-4.3.7-java/lib/puma/server.rb:383:in `handle_servers'
C:/Development_Avecto/dev_tools/logstash-7.12.0/vendor/bundle/jruby/2.5.0/gems/puma-4.3.7-java/lib/puma/server.rb:356:in `block in run'
[2022-07-21T10:10:24,580][DEBUG][logstash.agent ] ["org/jruby/RubyIO.java:3067:in `read'", "org/jruby/RubyIO.java:3049:in `read'", "C:/Development_Avecto/dev_tools/logstash-7.12.0/vendor/bundle/jruby/2.5.0/gems/puma-4.3.7-java/lib/puma/reactor.rb:160:in `block in run_internal'", "org/jruby/ext/thread/Mutex.java:164:in `synchronize'", "C:/Development_Avecto/dev_tools/logstash-7.12.0/vendor/bundle/jruby/2.5.0/gems/puma-4.3.7-java/lib/puma/reactor.rb:159:in `block in run_internal'", "org/jruby/RubyArray.java:1809:in `each'", "C:/Development_Avecto/dev_tools/logstash-7.12.0/vendor/bundle/jruby/2.5.0/gems/puma-4.3.7-java/lib/puma/reactor.rb:157:in `run_internal'", "C:/Development_Avecto/dev_tools/logstash-7.12.0/vendor/bundle/jruby/2.5.0/gems/puma-4.3.7-java/lib/puma/reactor.rb:313:in `block in run_in_thread'"]
[2022-07-21T10:10:24,568][FATAL][org.logstash.Logstash ] Logstash stopped processing because of an error: (SystemExit) exit
org.jruby.exceptions.SystemExit: (SystemExit) exit
at org.jruby.RubyKernel.exit(org/jruby/RubyKernel.java:747) ~[jruby-complete-9.2.13.0.jar:?]
at org.jruby.RubyKernel.exit(org/jruby/RubyKernel.java:710) ~[jruby-complete-9.2.13.0.jar:?]
at C_3a_.Development_Avecto.dev_tools.logstash_minus_7_dot_12_dot_0.lib.bootstrap.environment.<main>(C:\Development_Avecto\dev_tools\logstash-7.12.0\lib\bootstrap\environment.rb:89) ~[?:?]
[2022-07-21T10:10:24,581][DEBUG][logstash.agent ] 2022-07-21 10:10:24 +0530: Listen loop error: #<IOError: closed stream>
org/jruby/RubyIO.java:3552:in `select'
C:/Development_Avecto/dev_tools/logstash-7.12.0/vendor/bundle/jruby/2.5.0/gems/puma-4.3.7-java/lib/puma/server.rb:383:in `handle_servers'
C:/Development_Avecto/dev_tools/logstash-7.12.0/vendor/bundle/jruby/2.5.0/gems/puma-4.3.7-java/lib/puma/server.rb:356:in `block in run'
[2022-07-21T10:10:24,584][DEBUG][logstash.agent ] 2022-07-21 10:10:24 +0530: Listen loop error: #<IOError: closed stream>
org/jruby/RubyIO.java:3552:in `select'
C:/Development_Avecto/dev_tools/logstash-7.12.0/vendor/bundle/jruby/2.5.0/gems/puma-4.3.7-java/lib/puma/server.rb:383:in `handle_servers'
C:/Development_Avecto/dev_tools/logstash-7.12.0/vendor/bundle/jruby/2.5.0/gems/puma-4.3.7-java/lib/puma/server.rb:356:in `block in run'
This error usually occurs when the conf file specified is not a valid file or path. Check the entire log to see if there is an error "No configuration found in the configured sources". If the file is under the logstash conf folder then execute the following command from the root folder in windows
bin\logstash -f config\logstash-sample.conf

GitLab upgrade from 9.5.10 to 10.8.7 unsuccessful

After installing the package for 10.8.7, which is the next supported upgrade path per https://docs.gitlab.com/ee/update/#upgrade-paths, gitlab-ctl reconfigure fails with:
================================================================================
Recipe Compile Error in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab-ee/recipes/default.rb
================================================================================
NoMethodError
-------------
undefined method `[]' for nil:NilClass
Cookbook Trace:
---------------
/opt/gitlab/embedded/cookbooks/cache/cookbooks/package/libraries/helpers/secrets_helper.rb:81:in `write_to_gitlab_secrets'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/gitlab.rb:186:in `generate_secrets'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/gitlab.rb:259:in `generate_config'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/config.rb:26:in `from_file'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/default.rb:26:in `from_file'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab-ee/recipes/default.rb:20:in `from_file'
Relevant File Content:
----------------------
/opt/gitlab/embedded/cookbooks/cache/cookbooks/package/libraries/helpers/secrets_helper.rb:
74: },
75: 'registry' => {
76: 'http_secret' => Gitlab['registry']['http_secret'],
77: 'internal_certificate' => Gitlab['registry']['internal_certificate'],
78: 'internal_key' => Gitlab['registry']['internal_key']
79: },
80: 'letsencrypt' => {
81>> 'auto_enabled' => Gitlab['letsencrypt']['auto_enabled']
82: },
83: 'mattermost' => {
84: 'email_invite_salt' => Gitlab['mattermost']['email_invite_salt'],
85: 'file_public_link_salt' => Gitlab['mattermost']['file_public_link_salt'],
86: 'sql_at_rest_encrypt_key' => Gitlab['mattermost']['sql_at_rest_encrypt_key']
87: },
88: 'postgresql' => {
89: 'internal_certificate' => Gitlab['postgresql']['internal_certificate'],
90: 'internal_key' => Gitlab['postgresql']['internal_key']
Seeing the error, I attempted to add the following to /etc/gitlab/gitlab-secrets.json:
"letsencrypt": {
"auto_enabled": false
},
Now I see a warning along with the error:
Ignoring section letsencrypt in /etc/gitlab/gitlab-secrets.json, does not exist in gitlab.rb
So I added the following to /etc/gitlab/gitlab.rb:
letsencrypt['auto_enabled'] = false
But now I get a different error when running gitlab-ctl reconfigure:
*ERROR*: Encountered unsupported config key 'letsencrypt' in /etc/gitlab/gitlab.rb.
================================================================================
ERROR: Encountered unsupported config key 'letsencrypt' in /etc/gitlab/gitlab.rb.
================================================================================
================================================================================
Recipe Compile Error in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab-ee/recipes/default.rb
================================================================================
NoMethodError
-------------
undefined method `[]=' for nil:NilClass
Cookbook Trace:
---------------
/opt/gitlab/embedded/cookbooks/cache/cookbooks/package/libraries/helpers/settings_helper.rb:100:in `block in from_file'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/package/libraries/config_mash.rb:28:in `auto_vivify'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/package/libraries/helpers/settings_helper.rb:100:in `from_file'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/gitlab.rb:125:in `block in from_file'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/package/libraries/config_mash.rb:28:in `auto_vivify'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/libraries/gitlab.rb:125:in `from_file'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/config.rb:23:in `from_file'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/recipes/default.rb:26:in `from_file'
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab-ee/recipes/default.rb:20:in `from_file'
Relevant File Content:
----------------------
/opt/gitlab/embedded/cookbooks/cache/cookbooks/package/libraries/helpers/settings_helper.rb:
93: def ee_attribute(name, **config)
94: config = { ee: true }.merge(config)
95: attribute(name, **config)
96: end
97:
98: def from_file(_file_path)
99: # Allow auto mash creation during from_file call
100>> Gitlab::ConfigMash.auto_vivify { super }
101: end
102:
103: def method_missing(method_name, *arguments) # rubocop:disable Style/MethodMissing
104: # Give better message for NilClass errors
105: # If there are no arguments passed, this is a 'GET' call, and if
106: # there is no matching key in the configuration, then it has not been set (not even to nil)
107: # and we will output a nicer error above the exception
108: if arguments.length.zero? && !configuration.key?(method_name)
109: breaktxt = '=' * 80
Additionally, I get the following errors if I try to run gitlab-rake cache:clear:
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/elastic.rake:61: warning: already initialized constant INDEXABLE_CLASSES
/opt/gitlab/embedded/service/gitlab-rails/ee/lib/tasks/gitlab/elastic.rake:61: warning: previous definition of INDEXABLE_CLASSES was here
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab.rb:31: warning: already initialized constant Gitlab::VERSION
/opt/gitlab/embedded/service/gitlab-rails/config/initializers/2_app.rb:6: warning: previous definition of VERSION was here
WARNING: Unable to check/update clone_url_prefix for Geo: undefined method `connected?' for Gitlab::Geo:Module
Did you mean? concern
rake aborted!
NameError: uninitialized constant API::Entities::ProjectPushRule
/opt/gitlab/embedded/service/gitlab-rails/lib/api/project_push_rule.rb:28:in `block (2 levels) in <class:ProjectPushRule>'
/opt/gitlab/embedded/service/gitlab-rails/lib/api/project_push_rule.rb:27:in `block in <class:ProjectPushRule>'
/opt/gitlab/embedded/service/gitlab-rails/lib/api/project_push_rule.rb:10:in `<class:ProjectPushRule>'
/opt/gitlab/embedded/service/gitlab-rails/lib/api/project_push_rule.rb:2:in `<module:API>'
/opt/gitlab/embedded/service/gitlab-rails/lib/api/project_push_rule.rb:1:in `<top (required)>'
/opt/gitlab/embedded/service/gitlab-rails/lib/api/v3/project_git_hook.rb:23:in `block (2 levels) in <class:ProjectGitHook>'
/opt/gitlab/embedded/service/gitlab-rails/lib/api/v3/project_git_hook.rb:22:in `block in <class:ProjectGitHook>'
/opt/gitlab/embedded/service/gitlab-rails/lib/api/v3/project_git_hook.rb:13:in `<class:ProjectGitHook>'
/opt/gitlab/embedded/service/gitlab-rails/lib/api/v3/project_git_hook.rb:3:in `<module:V3>'
/opt/gitlab/embedded/service/gitlab-rails/lib/api/v3/project_git_hook.rb:2:in `<module:API>'
/opt/gitlab/embedded/service/gitlab-rails/lib/api/v3/project_git_hook.rb:1:in `<top (required)>'
/opt/gitlab/embedded/service/gitlab-rails/lib/api/api.rb:66:in `block in <class:API>'
/opt/gitlab/embedded/service/gitlab-rails/lib/api/api.rb:25:in `<class:API>'
/opt/gitlab/embedded/service/gitlab-rails/lib/api/api.rb:2:in `<module:API>'
/opt/gitlab/embedded/service/gitlab-rails/lib/api/api.rb:1:in `<top (required)>'
/opt/gitlab/embedded/service/gitlab-rails/config/initializers/rack_attack.rb:12:in `<top (required)>'
/opt/gitlab/embedded/service/gitlab-rails/config/environment.rb:11:in `<top (required)>'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'
Tasks: TOP => cache:clear => cache:clear:redis => environment
(See full trace by running task with --trace)
In my case, I was able to successfully upgrade to 10.8.7 by selecting an arbitrary intermediate version (in my case, 10.5.8). Not sure why directly upgrading as per the upgrade path did not work. I will continue my journey to GitLab 14 now!

Gitlab Enterprise Edition HTTPS

I'm setting up gitlab-ee with out a liscense. I want to to have https but its giving me this error
Recipe: letsencrypt::http_authorization
* letsencrypt_certificate[gitlab.example.com] action create
* acme_certificate[staging] action create
* file[gitlab.example.com SSL key] action create_if_missing (up to date)
================================================================================
Error executing action `create` on resource 'acme_certificate[staging]'
================================================================================
Acme::Client::Error::Malformed
------------------------------
Method not allowed
Cookbook Trace:
---------------
/opt/gitlab/embedded/cookbooks/cache/cookbooks/acme/resources/certificate.rb:77:in `block in class_from_file'
Resource Declaration:
---------------------
suppressed sensitive resource output
Compiled Resource:
------------------
suppressed sensitive resource output
System Info:
------------
chef_version=14.13.11
platform=ubuntu
platform_version=18.04
ruby=ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
program_name=/opt/gitlab/embedded/bin/chef-client
executable=/opt/gitlab/embedded/bin/chef-client
================================================================================
Error executing action `create` on resource 'letsencrypt_certificate[gitlab.example.com]'
================================================================================
Acme::Client::Error::Malformed
------------------------------
acme_certificate[staging] (/opt/gitlab/embedded/cookbooks/cache/cookbooks/letsencrypt/resources/certificate.rb line 25) had an error: Acme::Client::Error::Malformed: Method not allowed
Cookbook Trace:
---------------
/opt/gitlab/embedded/cookbooks/cache/cookbooks/acme/resources/certificate.rb:77:in `block in class_from_file'
Resource Declaration:
---------------------
# In /opt/gitlab/embedded/cookbooks/cache/cookbooks/letsencrypt/recipes/http_authorization.rb
5: letsencrypt_certificate site do
6: crt node['gitlab']['nginx']['ssl_certificate']
7: key node['gitlab']['nginx']['ssl_certificate_key']
8: notifies :run, "execute[reload nginx]", :immediate
9: notifies :run, 'ruby_block[display_le_message]'
10: only_if { omnibus_helper.service_up?('nginx') }
11: end
Compiled Resource:
------------------
# Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/letsencrypt/recipes/http_authorization.rb:5:in `from_file'
letsencrypt_certificate("gitlab.example.com") do
action [:create]
default_guard_interpreter :default
declared_type :letsencrypt_certificate
cookbook_name "letsencrypt"
recipe_name "http_authorization"
crt "/etc/gitlab/ssl/gitlab.example.com.crt"
key "/etc/gitlab/ssl/gitlab.example.com.key"
alt_names []
cn "gitlab.example.com"
only_if { #code block }
end
System Info:
------------
chef_version=14.13.11
platform=ubuntu
platform_version=18.04
ruby=ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
program_name=/opt/gitlab/embedded/bin/chef-client
executable=/opt/gitlab/embedded/bin/chef-client
Running handlers:
There was an error running gitlab-ctl reconfigure:
letsencrypt_certificate[gitlab.example.com] (letsencrypt::http_authorization line 5) had an error: Acme::Client::Error::Malformed: acme_certificate[staging] (/opt/gitlab/embedded/cookbooks/cache/cookbooks/letsencrypt/resources/certificate.rb line 25) had an error: Acme::Client::Error::Malformed: Method not allowed
I dont see why its making it fail the creation of certifications. Its creating them and storing them in /etc/gitlab/sslanyone able to help?
Just for posterity, to complete #Rafael Pardini's answer, the mentioned solution boils down to simply commenting the acme_certificate 'staging' block (from do to end) inside the /opt/gitlab/embedded/cookbooks/letsencrypt/resources/certificate.rb file.

Internal Server Error 500 while accessing $GITLAB/admin/runners

I have restored Gitlab from a backup, now every time I try to access the runners webpage, I get a Internal Server error.
I have tried uninstalling all configured gitlab-runners and accessing it, the problem persists. Here is a trace from the gitlab-rails/production.log:
Started GET "/admin/runners" for 127.0.0.1 at 2019-01-16 07:17:12 -0500
Processing by Admin::RunnersController#index as HTML
Completed 500 Internal Server Error in 66ms (ActiveRecord: 5.7ms)
ActionView::Template::Error ():
37:
38: .col-sm-6
39: .bs-callout
40: = render partial: 'ci/runner/how_to_setup_runner',
41: locals: { registration_token: Gitlab::CurrentSettings.runners_registration_token,
42: type: 'shared',
43: reset_token_url: reset_registration_token_admin_application_settings_path }
lib/gitlab/crypto_helper.rb:27:in `aes256_gcm_decrypt'
app/models/concerns/token_authenticatable_strategies/encrypted.rb:55:in `get_token'
app/models/concerns/token_authenticatable_strategies/base.rb:33:in `ensure_token!'
app/models/concerns/token_authenticatable.rb:43:in `block in add_authentication_token_field'
app/models/application_setting.rb:409:in `runners_registration_token'
lib/gitlab/current_settings.rb:19:in `method_missing'
app/views/admin/runners/index.html.haml:40:in `_app_views_admin_runners_index_html_haml___977288809002382166_69944849285200'
app/controllers/application_controller.rb:116:in `render'
lib/gitlab/i18n.rb:55:in `with_locale'
lib/gitlab/i18n.rb:61:in `with_user_locale'
app/controllers/application_controller.rb:420:in `set_locale'
lib/gitlab/middleware/multipart.rb:103:in `call'
lib/gitlab/request_profiler/middleware.rb:16:in `call'
lib/gitlab/middleware/go.rb:19:in `call'
lib/gitlab/etag_caching/middleware.rb:13:in `call'
lib/gitlab/middleware/correlation_id.rb:16:in `block in call'
lib/gitlab/correlation_id.rb:15:in `use_id'
lib/gitlab/middleware/correlation_id.rb:15:in `call'
lib/gitlab/middleware/read_only/controller.rb:40:in `call'
lib/gitlab/middleware/read_only.rb:18:in `call'
lib/gitlab/middleware/basic_health_check.rb:25:in `call'
lib/gitlab/request_context.rb:20:in `call'
lib/gitlab/metrics/requests_rack_middleware.rb:29:in `call'
lib/gitlab/middleware/release_env.rb:13:in `call'
Started GET "/-/metrics" for 127.0.0.1 at 2019-01-16 07:17:24 -0500
Processing by MetricsController#index as HTML
Completed 200 OK in 1ms (Views: 0.4ms | ActiveRecord: 0.0ms)
I could resolve the issue by following official gitlab documentation:
gitlab-rails dbconsole
-- Clear project tokens
UPDATE projects SET runners_token = null, runners_token_encrypted = null;
-- Clear group tokens
UPDATE namespaces SET runners_token = null, runners_token_encrypted = null;
-- Clear instance tokens
UPDATE application_settings SET runners_registration_token_encrypted = null;
-- Clear runner tokens
UPDATE ci_runners SET token = null, token_encrypted = null;
https://docs.gitlab.com/ee/raketasks/backup_restore.html#reset-runner-registration-tokens
Edit:
After clearing existing pipeline jobs (see above), I could still not open the ci settings page for some migrated projects where I had set environment variables. In this case try to remove them:
gitlab-rails dbconsole
SELECT * FROM ci_variables;
DELETE FROM ci_variables WHERE project_id='XX';
Hope that helps.
You did a restore, but probably did not restore the secrets store (/etc/gitlab/gitlab-secrets.json or $GITLAB_HOME/config/secrets.json). Same issue as gitlab 500 errors in the admin area
You can reset it like this from the rails console on the gitlab server:
root#gitlab:/# gitlab-rails console
-------------------------------------------------------------------------------------
GitLab: 11.5.1 (c90ae59)
GitLab Shell: 8.4.1
postgresql: 9.6.8
-------------------------------------------------------------------------------------
Both Deployment and its :status machine have defined a different default for "status". Use only one or the other for defining defaults to avoid unexpected behaviors.
Loading production environment (Rails 4.2.10)
irb(main):001:0> ApplicationSetting.current.reset_runners_registration_token!
=> true
i've solved this,maybe it is usefal
a. Reset CI/CD variables
gitlab-rails dbconsole
SELECT * FROM public."ci_group_variables";
SELECT * FROM public."ci_variables";
DELETE FROM ci_group_variables;
DELETE FROM ci_variables;
b. Reset runner registration tokens
gitlab-rails dbconsole
-- Clear project tokens
UPDATE projects SET runners_token = null, runners_token_encrypted = null;
-- Clear group tokens
UPDATE namespaces SET runners_token = null, runners_token_encrypted = null;
-- Clear instance tokens
UPDATE application_settings SET runners_registration_token_encrypted = null;
UPDATE application_settings SET encrypted_ci_jwt_signing_key = null;
-- Clear runner tokens
UPDATE ci_runners SET token = null, token_encrypted = null;
c. Reset pending pipeline jobs
sudo gitlab-rails dbconsole
-- Clear build tokens
UPDATE ci_builds SET token = null, token_encrypted = null;
d. Fix project integrations
gitlab-rails dbconsole
-- truncate web_hooks table
TRUNCATE web_hooks CASCADE;
from gitlab

GitLab (6.6.5) Omnibus configuration for PostgreSQL

ls -la /etc/gitlab/
-rwxrwxrwx 1 git git gitlab.rb
cat /etc/gitlab/gitlab.rb
# Disable the built-in Postgres
postgresql['enable'] = false
# Fill in the values for database.yml
gitlab_rails['db_adapter'] = 'postgresql'
gitlab_rails['db_encoding'] = 'unicode'
gitlab_rails['db_database'] = 'gitlab_db_name'
gitlab_rails['db_pool'] = 10
gitlab_rails['db_host'] = 'aws-RDShost.us-east-1.rds.amazonaws.com'
gitlab_rails['db_port'] = 5432
gitlab_rails['db_username'] = "gitlab_user"
gitlab_rails['db_password'] = 'mypass'
Now the problem is that 6.6.5 gitlab is not overwriting the database.rb file sitting at /var/opt/gitlab/gitlab-rails/etc/database.rb
Full error stack:
Compiling Cookbooks...
Recipe: gitlab::default
* directory[/etc/gitlab] action create
- change owner from 'git' to 'root'
- change group from 'git' to 'root'
[2015-04-16T20:32:04+00:00] WARN: Cloning resource attributes for directory[/var/opt/gitlab/gitlab-rails/etc] from prior resource (CHEF-3694)
[2015-04-16T20:32:04+00:00] WARN: Previous directory[/var/opt/gitlab/gitlab-rails/etc]: /opt/gitlab/embedded/cookbooks/gitlab/recipes/gitlab-rails.rb:36:in `block in from_file'
[2015-04-16T20:32:04+00:00] WARN: Current directory[/var/opt/gitlab/gitlab-rails/etc]: /opt/gitlab/embedded/cookbooks/gitlab/definitions/unicorn_config.rb:21:in `block in from_file'
[2015-04-16T20:32:04+00:00] WARN: Cloning resource attributes for service[unicorn] from prior resource (CHEF-3694)
[2015-04-16T20:32:04+00:00] WARN: Previous service[unicorn]: /opt/gitlab/embedded/cookbooks/gitlab/recipes/default.rb:58:in `block in from_file'
[2015-04-16T20:32:04+00:00] WARN: Current service[unicorn]: /opt/gitlab/embedded/cookbooks/runit/definitions/runit_service.rb:173:in `block in from_file'
[2015-04-16T20:32:04+00:00] WARN: Cloning resource attributes for service[sidekiq] from prior resource (CHEF-3694)
[2015-04-16T20:32:04+00:00] WARN: Previous service[sidekiq]: /opt/gitlab/embedded/cookbooks/gitlab/recipes/default.rb:58:in `block in from_file'
[2015-04-16T20:32:04+00:00] WARN: Current service[sidekiq]: /opt/gitlab/embedded/cookbooks/runit/definitions/runit_service.rb:173:in `block in from_file'
Recipe: gitlab::postgresql_disable
* link[/opt/gitlab/service/postgresql] action delete (up to date)
Recipe: gitlab::database_migrations
* execute[initialize database] action nothing (skipped due to action :nothing)
* execute[chown git:git /opt/gitlab/embedded/service/gitlab-rails/db/schema.rb] action run
- execute chown git:git /opt/gitlab/embedded/service/gitlab-rails/db/schema.rb
* execute[migrate database] action run
Error executing action `run` on resource 'execute[migrate database]'
Mixlib::ShellOut::ShellCommandFailed
Expected process to exit with [0], but received '1'
Begin output of /opt/gitlab/bin/gitlab-rake db:migrate
STDOUT:
STDERR: rake aborted!
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?

Resources