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

user creation killed gitlab admin #21

Open
glensc opened this issue Apr 21, 2017 · 4 comments
Open

user creation killed gitlab admin #21

glensc opened this issue Apr 21, 2017 · 4 comments

Comments

@glensc
Copy link
Member

glensc commented Apr 21, 2017

https://gitlab.example.net/admin

==> /var/log/gitlab/gitlab-rails/production.log <==
Started GET "/admin" for 10.1.2.66 at 2017-04-21 23:56:29 +0300
Processing by Admin::DashboardController#index as HTML
Completed 500 Internal Server Error in 127ms (ActiveRecord: 11.6ms)

ActionView::Template::Error (undefined method `strftime' for nil:NilClass):
    155:             = link_to [:admin, user], class: 'str-truncated-60' do
    156:               = user.name
    157:             %span.light.pull-right
    158:               #{time_ago_with_tooltip(user.created_at)}
    159:
    160:       .col-md-4   
    161:         %h4 Latest groups
  app/helpers/application_helper.rb:170:in `time_ago_with_tooltip'
  app/views/admin/dashboard/index.html.haml:158:in `block in _app_views_admin_dashboard_index_html_haml__3452472750118434001_69913778079960' 
  app/views/admin/dashboard/index.html.haml:153:in `_app_views_admin_dashboard_index_html_haml__3452472750118434001_69913778079960' 
  lib/gitlab/middleware/multipart.rb:93:in `call'
  lib/gitlab/request_profiler/middleware.rb:14:in `call'
  lib/gitlab/middleware/go.rb:16:in `call'
  lib/gitlab/etag_caching/middleware.rb:14:in `call'
  lib/gitlab/request_context.rb:18:in `call'

https://gitlab.example.net/admin/users?filter=wop

==> /var/log/gitlab/gitlab-rails/production.log <==
Started GET "/admin/users?filter=wop" for 10.1.2.66 at 2017-04-21 23:55:00 +0300
Processing by Admin::UsersController#index as HTML
  Parameters: {"filter"=>"wop"}
Completed 500 Internal Server Error in 179ms (ActiveRecord: 11.0ms)

ActionView::Template::Error (nil is not a known state value):
    4:   .row-main-content
    5:     .user-name.row-title.str-truncated-100
    6:       = link_to user.name, [:admin, user]
    7:     - if user.blocked?
    8:       %span.label.label-danger blocked
    9:     - if user.admin?
   10:       %span.label.label-success Admin
  app/views/admin/users/_user.html.haml:7:in `_app_views_admin_users__user_html_haml__2653120606476374577_69913714381860'
  app/views/admin/users/index.html.haml:76:in `_app_views_admin_users_index_html_haml___3881772783949202085_69913709853260'
  lib/gitlab/middleware/multipart.rb:93:in `call'
  lib/gitlab/request_profiler/middleware.rb:14:in `call'
  lib/gitlab/middleware/go.rb:16:in `call'
  lib/gitlab/etag_caching/middleware.rb:14:in `call'
  lib/gitlab/request_context.rb:18:in `call'

this happened after i finally managed to run this tool for the first time into actual database (using gitlab direct):

# time sudo -u gitlab-psql ./VENV/bin/tracboat --config-file=comment.toml migrate

i think the problem was that it created user with invalid email, as my user map was:

[tracboat.usermap]
    glen = "glen"

why the mapping is login -> email, not login -> login? can it be both?

@glensc
Copy link
Member Author

glensc commented Apr 21, 2017

yup,

(VENV)root@soa:~/tracboat# gitlab-rails console

irb(main):005:0> user = User.find_by(email: "glen")
=> #<User id: 26,
 email: "glen",
 created_at: nil,
 updated_at: nil,
 name: nil,
 admin: false,
 projects_limit: 10,
 skype: "",
 linkedin: "",
 twitter: "",
 authentication_token: nil,
 bio: nil,
 username: "glen",
 can_create_group: true,
 can_create_team: true,
 state: nil,
 color_scheme_id: 0,
 password_expires_at: nil,
 created_by_id: nil,
 last_credential_check_at: nil,
 avatar: nil,
 hide_no_ssh_key: false,
 website_url: "",
 notification_email: nil,
 hide_no_password: false,
 password_automatically_set: false,
 location: nil,
 encrypted_otp_secret: nil,
 encrypted_otp_secret_iv: nil,
 encrypted_otp_secret_salt: nil,
 otp_required_for_login: false,
 otp_backup_codes: nil,
 public_email: "glen",
 dashboard: 0,
 project_view: 0,
 consumed_timestep: nil,
 layout: 0,
 hide_project_limit: false,
 otp_grace_period_started_at: nil,
 ldap_email: false,
 external: false,
 organization: nil,
 incoming_email_token: nil,
 authorized_projects_populated: nil,
 ghost: nil>
irb(main):006:0> user.email
=> "glen"

@glensc
Copy link
Member Author

glensc commented Apr 21, 2017

perhaps it's better to create users over api, then gitlab can fill some defaults and do input validation.

@nazavode nazavode added the bug label Jul 13, 2017
@glensc
Copy link
Member Author

glensc commented Jul 25, 2017

damn. got hit this bug again. and i forgot to disable user creation in local codebase.


==> /var/log/gitlab/gitlab-rails/production.log <==
Completed 500 Internal Server Error in 256ms (ActiveRecord: 11.0ms)

ActionView::Template::Error (nil is not a known state value):
    4:   .row-main-content
    5:     .user-name.row-title.str-truncated-100
    6:       = link_to user.name, [:admin, user]
    7:     - if user.blocked?
    8:       %span.label.label-danger blocked
    9:     - if user.admin?
   10:       %span.label.label-success Admin
  app/views/admin/users/_user.html.haml:7:in `_app_views_admin_users__user_html_haml___1634756990002175514_69812433530880'
  app/views/admin/users/index.html.haml:77:in `_app_views_admin_users_index_html_haml___512301990751938281_69812424694720'
  lib/gitlab/i18n.rb:45:in `with_locale'
  lib/gitlab/i18n.rb:51:in `with_user_locale'
  app/controllers/application_controller.rb:294:in `set_locale'
  lib/gitlab/performance_bar/peek_performance_bar_with_rack_body.rb:16:in `call'
  lib/gitlab/middleware/multipart.rb:93:in `call'
  lib/gitlab/request_profiler/middleware.rb:14:in `call'
  lib/gitlab/middleware/go.rb:16:in `call'
  lib/gitlab/etag_caching/middleware.rb:11:in `call'
  lib/gitlab/request_context.rb:18:in `call'
  lib/gitlab/metrics/connection_rack_middleware.rb:31:in `call'

@glensc
Copy link
Member Author

glensc commented Jul 25, 2017

using gitlab-rails console to fix this again.

finding broken users:

irb(main):028:0> User.find_each { |u| u.blocked? rescue puts u.id }
Scoped order and limit are ignored, it's forced to be batch order and batch size
30
=> nil
irb(main):029:0>

deleting it:

irb(main):037:0> User.find_each { |u| u.blocked? rescue puts u.delete }
Scoped order and limit are ignored, it's forced to be batch order and batch size
#<User:0x007fbc9ca40a78>
=> nil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
First usable release
Awaiting triage
Development

No branches or pull requests

2 participants