1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
5 class Arvados::V1::ContainersController < ApplicationController
6 accept_attribute_as_json :environment, Hash
7 accept_attribute_as_json :mounts, Hash
8 accept_attribute_as_json :runtime_constraints, Hash
9 accept_attribute_as_json :runtime_status, Hash
10 accept_attribute_as_json :command, Array
11 accept_attribute_as_json :scheduling_parameters, Hash
13 skip_before_action :find_object_by_uuid, only: [:current]
14 skip_before_action :render_404_if_no_object, only: [:current]
17 if @object.locked_by_uuid != Thread.current[:api_client_authorization].uuid
18 raise ArvadosModel::PermissionDeniedError.new("Not locked by your token")
20 if @object.runtime_token.nil?
21 @object = @object.auth
23 @object = ApiClientAuthorization.validate(token: @object.runtime_token)
25 raise ArvadosModel::PermissionDeniedError.new("Invalid runtime_token")
32 @object.reload.with_lock do
37 def find_objects_for_index
39 if action_name == 'lock' || action_name == 'unlock'
40 # Avoid loading more fields than we need
41 @objects = @objects.select(:id, :uuid, :state, :priority, :auth_uuid, :locked_by_uuid, :lock_count)
42 @select = %w(uuid state priority auth_uuid locked_by_uuid)
57 if Thread.current[:api_client_authorization].nil?
58 send_error("Not logged in", status: 401)
60 @object = Container.for_current_token
62 send_error("Token is not associated with a container.", status: 404)
70 c = Container.for_current_token
71 if @object && c && @object.uuid == c.uuid
72 send_json({"secret_mounts" => @object.secret_mounts})
74 send_error("Token is not associated with this container.", status: 403)