Skip to content

Commit

Permalink
shackles was renamed to guardrail
Browse files Browse the repository at this point in the history
closes FOO-989, FOO-990

Change-Id: I49dfa130cb74c34dd0eb25952790176ae4951058
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/249365
Tested-by: Service Cloud Jenkins <[email protected]>
Reviewed-by: Simon Williams <[email protected]>
QA-Review: Cody Cutrer <[email protected]>
Product-Review: Cody Cutrer <[email protected]>
  • Loading branch information
ccutrer committed Oct 6, 2020
1 parent aade936 commit c5227d3
Show file tree
Hide file tree
Showing 126 changed files with 293 additions and 277 deletions.
6 changes: 3 additions & 3 deletions Gemfile.d/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@
gem 'nokogiri-xmlsec-instructure', '0.9.7', require: false
gem 'sanitize', '2.1.1', require: false
gem 'sentry-raven', '2.13.0', require: false
gem 'shackles', '1.4.2'
gem 'guardrail', '2.0.0'
gem 'simple_oauth', '0.3.1', require: false
gem 'switchman', '1.15.2'
gem 'switchman', '2.0.0'
gem 'open4', '1.3.4', require: false
gem 'switchman-inst-jobs', '1.5.2'
gem 'switchman-inst-jobs', '2.0.0'
gem 'twilio-ruby', '5.36.0', require: false
gem 'tzinfo', '1.2.7'
gem 'vault', '0.13.0', require: false
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ def courses_api
page_opts[:total_entries] = nil if params[:search_term] # doesn't calculate a total count

all_precalculated_permissions = nil
Shackles.activate(:slave) do
GuardRail.activate(:secondary) do
@courses = Api.paginate(@courses, self, api_v1_account_courses_url, page_opts)

ActiveRecord::Associations::Preloader.new.preload(@courses, [:account, :root_account, course_account_associations: :account])
Expand Down Expand Up @@ -1375,7 +1375,7 @@ def users
return unless authorized_action(@context, @current_user, :read_roster)
@root_account = @context.root_account
@query = params[:term]
Shackles.activate(:slave) do
GuardRail.activate(:secondary) do
@users = @context.users_name_like(@query)
@users = @users.paginate(:page => params[:page])

Expand Down
8 changes: 4 additions & 4 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def external_tools_display_hashes(type, context=@context, custom_settings=[], to
return [] if context.is_a?(Group)

context = context.account if context.is_a?(User)
tools = Shackles.activate(:slave) do
tools = GuardRail.activate(:secondary) do
ContextExternalTool.all_tools_for(context, {:placements => type,
:root_account => @domain_root_account, :current_user => @current_user,
:tool_ids => tool_ids}).to_a
Expand Down Expand Up @@ -872,7 +872,7 @@ def require_context_type(klass)
# Also assigns @context_membership to the membership type of @current_user
# if @current_user is a member of the context.
def get_context
Shackles.activate(:slave) do
GuardRail.activate(:secondary) do
unless @context
if params[:course_id]
@context = api_find(Course.active, params[:course_id])
Expand Down Expand Up @@ -1076,7 +1076,7 @@ def badge_counts_for(context, user, enrollment=nil)
end

def content_participation_count(context, type, user)
Shackles.activate(:master) do
GuardRail.activate(:primary) do
ContentParticipationCount.create_or_update({context: context, user: user, content_type: type})
end
end
Expand Down Expand Up @@ -1676,7 +1676,7 @@ def verified_file_request?
# Retrieving wiki pages needs to search either using the id or
# the page title.
def get_wiki_page
Shackles.activate(params[:action] == "edit" ? :master : :slave) do
GuardRail.activate(params[:action] == "edit" ? :primary : :secondary) do
@wiki = @context.wiki

@page_name = params[:wiki_page_id] || params[:id] || (params[:wiki_page] && params[:wiki_page][:title])
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/assignment_groups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class AssignmentGroupsController < ApplicationController
#
# @returns [AssignmentGroup]
def index
Shackles.activate(:slave) do
GuardRail.activate(:secondary) do
if authorized_action(@context.assignment_groups.temp_record, @current_user, :read)
groups = Api.paginate(@context.assignment_groups.active, self, api_v1_course_assignment_groups_url(@context))

Expand Down
8 changes: 4 additions & 4 deletions app/controllers/assignments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class AssignmentsController < ApplicationController
before_action :normalize_title_param, :only => [:new, :edit]

def index
Shackles.activate(:slave) do
GuardRail.activate(:secondary) do
return redirect_to(dashboard_url) if @context == @current_user

if authorized_action(@context, @current_user, :read)
Expand Down Expand Up @@ -126,7 +126,7 @@ def render_a2_student_view
end

def show
Shackles.activate(:slave) do
GuardRail.activate(:secondary) do
@assignment ||= @context.assignments.find(params[:id])

if @assignment.deleted?
Expand All @@ -149,7 +149,7 @@ def show
@unlocked = !@locked || @assignment.grants_right?(@current_user, session, :update)

unless @assignment.new_record? || (@locked && !@locked[:can_view])
Shackles.activate(:master) do
GuardRail.activate(:primary) do
@assignment.context_module_action(@current_user, :read)
end
end
Expand All @@ -161,7 +161,7 @@ def show
!@current_user_submission.graded? &&
!@current_user_submission.submission_type
if @current_user_submission
Shackles.activate(:master) do
GuardRail.activate(:primary) do
@current_user_submission.send_later(:context_module_action)
end
end
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/calendar_events_api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def user_index
end

def render_events_for_user(user, route_url)
Shackles.activate(:slave) do
GuardRail.activate(:secondary) do
scope = if @type == :assignment
assignment_scope(
user,
Expand Down Expand Up @@ -722,7 +722,7 @@ def public_feed

get_options(nil)

Shackles.activate(:slave) do
GuardRail.activate(:secondary) do
@events.concat assignment_scope(@current_user).paginate(per_page: 1000, max: 1000)
@events = apply_assignment_overrides(@events, @current_user)
@events.concat calendar_event_scope(@current_user) { |relation| relation.events_without_child_events }.paginate(per_page: 1000, max: 1000)
Expand Down Expand Up @@ -763,7 +763,7 @@ def public_feed
# if the feed url doesn't give us the requesting user,
# we have to just display the generic course feed
get_all_pertinent_contexts
Shackles.activate(:slave) do
GuardRail.activate(:secondary) do
@contexts.each do |context|
@assignments = context.assignments.active.to_a if context.respond_to?("assignments")
# no overrides to apply without a current user
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/conferences_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def web_index(conferences)
}
log_asset_access([ "conferences", @context ], "conferences", "other")

Shackles.activate(:slave) do
GuardRail.activate(:secondary) do
@render_alternatives = WebConference.conference_types(@context).all? { |ct| ct[:replace_with_alternatives] }
case @context
when Course
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/context_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def roster_user_services
end

def roster_user_usage
Shackles.activate(:slave) do
GuardRail.activate(:secondary) do
if authorized_action(@context, @current_user, :read_reports)
@user = @context.users.find(params[:user_id])
contexts = [@context] + @user.group_memberships_for(@context).to_a
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/context_modules_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module ModuleIndexHelper
include ContextModulesHelper

def load_module_file_details
attachment_tags = Shackles.activate(:slave) { @context.module_items_visible_to(@current_user).where(content_type: 'Attachment').preload(:content => :folder).to_a }
attachment_tags = GuardRail.activate(:secondary) { @context.module_items_visible_to(@current_user).where(content_type: 'Attachment').preload(:content => :folder).to_a }
attachment_tags.inject({}) do |items, file_tag|
items[file_tag.id] = {
id: file_tag.id,
Expand Down Expand Up @@ -72,7 +72,7 @@ def load_modules

@menu_tools = {}
placements = [:assignment_menu, :discussion_topic_menu, :file_menu, :module_menu, :quiz_menu, :wiki_page_menu]
tools = Shackles.activate(:slave) do
tools = GuardRail.activate(:secondary) do
ContextExternalTool.all_tools_for(@context, placements: placements,
:root_account => @domain_root_account, :current_user => @current_user).to_a
end
Expand Down Expand Up @@ -312,7 +312,7 @@ def content_tag_assignment_data
if authorized_action(@context, @current_user, :read)
info = {}

all_tags = Shackles.activate(:slave) { @context.module_items_visible_to(@current_user).to_a }
all_tags = GuardRail.activate(:secondary) { @context.module_items_visible_to(@current_user).to_a }
user_is_admin = @context.grants_right?(@current_user, session, :read_as_admin)

ActiveRecord::Associations::Preloader.new.preload(all_tags, :content)
Expand Down Expand Up @@ -368,7 +368,7 @@ def content_tag_master_course_data
is_master_course = MasterCourses::MasterTemplate.is_master_course?(@context)

if is_child_course || is_master_course
tag_ids = Shackles.activate(:slave) do
tag_ids = GuardRail.activate(:secondary) do
tag_scope = @context.module_items_visible_to(@current_user).where(:content_type => %w{Assignment Attachment DiscussionTopic Quizzes::Quiz WikiPage})
tag_scope = tag_scope.where(:id => params[:tag_id]) if params[:tag_id]
tag_scope.pluck(:id)
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/conversations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ def show

@conversation.update_attribute(:workflow_state, "read") if @conversation.unread? && auto_mark_as_read?
messages = nil
Shackles.activate(:slave) do
GuardRail.activate(:secondary) do
messages = @conversation.messages
ActiveRecord::Associations::Preloader.new.preload(messages, :asset)
end
Expand Down Expand Up @@ -1027,7 +1027,7 @@ def public_feed
f.updated = Time.now
f.id = conversations_url
end
Shackles.activate(:slave) do
GuardRail.activate(:secondary) do
@entries = []
@conversation_contexts = {}
@current_user.conversations.each do |conversation|
Expand Down
20 changes: 10 additions & 10 deletions app/controllers/courses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ class CoursesController < ApplicationController
#
# @returns [Course]
def index
Shackles.activate(:slave) do
GuardRail.activate(:secondary) do
respond_to do |format|
format.html {
css_bundle :context_list, :course_list
Expand Down Expand Up @@ -630,7 +630,7 @@ def enrollments_for_index(type)
#
# @returns [Course]
def user_index
Shackles.activate(:slave) do
GuardRail.activate(:secondary) do
render json: courses_for_user(@user, paginate_url: api_v1_user_courses_url(@user))
end
end
Expand Down Expand Up @@ -963,7 +963,7 @@ def students
# "active" and "invited" enrollments are returned by default.
# @returns [User]
def users
Shackles.activate(:slave) do
GuardRail.activate(:secondary) do
get_context
if authorized_action(@context, @current_user, [:read_roster, :view_all_grades, :manage_grades])
log_api_asset_access([ "roster", @context ], 'roster', 'other')
Expand Down Expand Up @@ -1218,7 +1218,7 @@ def activity_stream_summary
#
# For full documentation, see the API documentation for the user todo items, in the user api.
def todo_items
Shackles.activate(:slave) do
GuardRail.activate(:secondary) do
get_context
if authorized_action(@context, @current_user, :read)
bookmark = Plannable::Bookmarker.new(Assignment, false, [:due_at, :created_at], :id)
Expand Down Expand Up @@ -1646,7 +1646,7 @@ def enrollment_invitation
def accept_enrollment(enrollment)
if @current_user && enrollment.user == @current_user
if enrollment.workflow_state == 'invited'
Shackles.activate(:master) do
GuardRail.activate(:primary) do
DueDateCacher.with_executing_user(@current_user) do
enrollment.accept!
end
Expand Down Expand Up @@ -1685,7 +1685,7 @@ def accept_enrollment(enrollment)
# Returns nothing.
def reject_enrollment(enrollment)
if enrollment.invited?
Shackles.activate(:master) do
GuardRail.activate(:primary) do
enrollment.reject!
end
flash[:notice] = t('notices.invitation_cancelled', 'Invitation canceled.')
Expand Down Expand Up @@ -1727,7 +1727,7 @@ def check_enrollment(ignore_restricted_courses = false)

if enrollment.rejected?
enrollment.workflow_state = 'invited'
Shackles.activate(:master) {enrollment.save_without_broadcasting}
GuardRail.activate(:primary) {enrollment.save_without_broadcasting}
end

if enrollment.self_enrolled?
Expand Down Expand Up @@ -1915,7 +1915,7 @@ def check_for_xlist
#
# @returns Course
def show
Shackles.activate(:slave) do
GuardRail.activate(:secondary) do
if api_request?
includes = Set.new(Array(params[:include]))

Expand Down Expand Up @@ -1968,7 +1968,7 @@ def show

return if check_for_xlist
@unauthorized_message = t('unauthorized.invalid_link', "The enrollment link you used appears to no longer be valid. Please contact the course instructor and make sure you're still correctly enrolled.") if params[:invitation]
Shackles.activate(:master) do
GuardRail.activate(:primary) do
claim_course if session[:claim_course_uuid] || params[:verification]
@context.claim if @context.created?
end
Expand All @@ -1990,7 +1990,7 @@ def show
check_incomplete_registration

add_crumb(@context.nickname_for(@current_user, :short_name), url_for(@context), :id => "crumb_#{@context.asset_string}")
Shackles.activate(:master) do
GuardRail.activate(:primary) do
set_badge_counts_for(@context, @current_user, @current_enrollment)
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/discussion_topics_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ def show

js_hash = {:DISCUSSION => env_hash}
if @context.is_a?(Course)
Shackles.activate(:slave) do
GuardRail.activate(:secondary) do
js_hash[:TOTAL_USER_COUNT] = @topic.context.enrollments.not_fake.
active_or_pending_by_date_ignoring_access.distinct.count(:user_id)
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/enrollments_api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ class EnrollmentsApiController < ApplicationController
#
# @returns [Enrollment]
def index
Shackles.activate(:slave) do
GuardRail.activate(:secondary) do
endpoint_scope = (@context.is_a?(Course) ? (@section.present? ? "section" : "course") : "user")

return unless enrollments = @context.is_a?(Course) ?
Expand Down Expand Up @@ -515,7 +515,7 @@ def index
# The ID of the enrollment object
# @returns Enrollment
def show
Shackles.activate(:slave) do
GuardRail.activate(:secondary) do
enrollment = @context.all_enrollments.find(params[:id])
if enrollment.user_id == @current_user.id || authorized_action(@context, @current_user, :read_roster)
render :json => enrollment_json(enrollment, @current_user, session)
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/files_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def index
#
# @returns [File]
def api_index
Shackles.activate(:slave) do
GuardRail.activate(:secondary) do
get_context
verify_api_id unless @context.present?
@folder = Folder.from_context_or_id(@context, params[:id])
Expand Down Expand Up @@ -486,7 +486,7 @@ def api_show
end

def show
Shackles.activate(:slave) do
GuardRail.activate(:secondary) do
original_params = params.dup
params[:id] ||= params[:file_id]
get_context
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/gradebooks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ def load_grade_summary_data

@exclude_total = exclude_total?(@context)

Shackles.activate(:slave) do
# run these queries on the slave database for speed
GuardRail.activate(:secondary) do
# run these queries on the secondary database for speed
@presenter.assignments
aggregate_assignments
@presenter.submissions
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/jobs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def require_view_jobs
def index
@flavor = params[:flavor] || 'current'

Shackles.activate(:slave) do
GuardRail.activate(:secondary) do
respond_to do |format|
format.html do
@running_jobs_refresh_seconds = Setting.get('running_jobs_refresh_seconds', 2.seconds.to_s).to_f
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/lti/lti_apps_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def launch_definitions
end
pagination_args = {max_per_page: 100}
respond_to do |format|
launch_defs = Shackles.activate(:slave) do
launch_defs = GuardRail.activate(:secondary) do
Api.paginate(
collection,
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def unsynced_changes

max_records = Setting.get('master_courses_history_count', '150').to_i
items = []
Shackles.activate(:slave) do
GuardRail.activate(:secondary) do
MasterCourses::CONTENT_TYPES_FOR_UNSYNCED_CHANGES.each do |klass|
item_scope = case klass
when 'Attachment'
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/planner_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class PlannerController < ApplicationController
# }
# ]
def index
Shackles.activate(:slave) do
GuardRail.activate(:secondary) do
# fetch a meta key so we can invalidate just this info and not the whole of the user's cache
planner_overrides_meta_key = get_planner_cache_id(@current_user)

Expand Down
Loading

0 comments on commit c5227d3

Please sign in to comment.