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

refresh! method is being called on Aws::SharedCredentials #2685

Closed
ashiqueps opened this issue Apr 12, 2022 · 1 comment · Fixed by #2686
Closed

refresh! method is being called on Aws::SharedCredentials #2685

ashiqueps opened this issue Apr 12, 2022 · 1 comment · Fixed by #2686
Assignees
Labels
bug This issue is a bug. investigating Issue is being investigated

Comments

@ashiqueps
Copy link
Contributor

Describe the bug

The Aws::SharedCredentials class doesn't have the refresh! method implemented since this is not a refreshable credential class. Whenever we use this class for storing credentials and the credentials are expired, the SDK will try to call the refresh! method and will raise the following error.

NoMethodError (undefined method `refresh!' for #<Aws::SharedCredentials profile_name="default" path="/home/ubuntu/.aws/credentials">)

Expected Behavior

The user should not be seeing these error messages. If the credentials are expired, show a corresponding error message.

Current Behavior

Currently, this is throwing the NoMethodError.

Reproduction Steps

For reproducing the error skew the clock first.

~$ sudo timedatectl set-ntp no
~$ sudo timedatectl set-time 12:17:13 # skewed past 15 minutes
~$ aws sts get-caller-identity
An error occurred (SignatureDoesNotMatch) when calling the GetCallerIdentity operation: Signature not yet current: 20220412T132639Z is still later than 20220412T124047Z (20220412T122547Z + 15 min.)

Now open the ruby console and initialize the client and call the describe_images method:

3.0.0 :005 > ::Aws.config.update(region: 'us-east-2', profile: 'default', http_proxy: nil, ssl_verify_peer: true)
 => {:region=>"us-east-2", :profile=>"default", :http_proxy=>nil, :ssl_verify_peer=>true}

3.0.0 :006 > client = Aws::EC2::Client.new
 => #<Aws::EC2::Client>

3.0.0 :007 > client.describe_images({:image_ids=>["ami-0fb653ca2d3203ac1"]})
Traceback (most recent call last):
       16: from /usr/share/rvm/gems/ruby-3.0.0/gems/aws-sdk-core-3.130.0/lib/aws-sdk-core/plugins/idempotency_token.rb:19:in `call'
       15: from /usr/share/rvm/gems/ruby-3.0.0/gems/aws-sdk-core-3.130.0/lib/aws-sdk-core/plugins/jsonvalue_converter.rb:22:in `call'
       14: from /usr/share/rvm/gems/ruby-3.0.0/gems/aws-sdk-core-3.130.0/lib/aws-sdk-core/plugins/checksum_algorithm.rb:111:in `call'
       13: from /usr/share/rvm/gems/ruby-3.0.0/gems/aws-sdk-core-3.130.0/lib/seahorse/client/plugins/raise_response_errors.rb:16:in `call'
       12: from /usr/share/rvm/gems/ruby-3.0.0/gems/aws-sdk-core-3.130.0/lib/aws-sdk-core/plugins/param_validator.rb:26:in `call'
       11: from /usr/share/rvm/gems/ruby-3.0.0/gems/aws-sdk-core-3.130.0/lib/seahorse/client/plugins/endpoint.rb:47:in `call'
       10: from /usr/share/rvm/gems/ruby-3.0.0/gems/aws-sdk-core-3.130.0/lib/aws-sdk-core/plugins/endpoint_discovery.rb:80:in `call'
        9: from /usr/share/rvm/gems/ruby-3.0.0/gems/aws-sdk-core-3.130.0/lib/aws-sdk-core/plugins/user_agent.rb:13:in `call'
        8: from /usr/share/rvm/gems/ruby-3.0.0/gems/aws-sdk-core-3.130.0/lib/aws-sdk-core/plugins/recursion_detection.rb:18:in `call'
        7: from /usr/share/rvm/gems/ruby-3.0.0/gems/aws-sdk-core-3.130.0/lib/aws-sdk-core/query/handler.rb:30:in `call'
        6: from /usr/share/rvm/gems/ruby-3.0.0/gems/aws-sdk-core-3.130.0/lib/aws-sdk-core/plugins/checksum_algorithm.rb:136:in `call'
        5: from /usr/share/rvm/gems/ruby-3.0.0/gems/aws-sdk-core-3.130.0/lib/aws-sdk-core/plugins/endpoint_pattern.rb:30:in `call'
        4: from /usr/share/rvm/gems/ruby-3.0.0/gems/aws-sdk-core-3.130.0/lib/aws-sdk-core/plugins/http_checksum.rb:19:in `call'
        3: from /usr/share/rvm/gems/ruby-3.0.0/gems/aws-sdk-core-3.130.0/lib/aws-sdk-core/plugins/retry_errors.rb:368:in `call'
        2: from /usr/share/rvm/gems/ruby-3.0.0/gems/aws-sdk-core-3.130.0/lib/aws-sdk-core/plugins/retry_errors.rb:381:in `retry_if_possible'
        1: from /usr/share/rvm/gems/ruby-3.0.0/gems/aws-sdk-core-3.130.0/lib/aws-sdk-core/plugins/retry_errors.rb:392:in `retry_request'
NoMethodError (undefined method `refresh!' for #<Aws::SharedCredentials profile_name="default" path="/home/ubuntu/.aws/credentials">)

Possible Solution

Since the refresh! method is not available for the Aws::SharedCredentials, add that condition as well before trying to refresh the credentials.

Additional Information/Context

test-kitchen/kitchen-ec2#576

Gem name ('aws-sdk', 'aws-sdk-resources' or service gems like 'aws-sdk-s3') and its version

aws-sdk-core-3.130.0

Environment details (Version of Ruby, OS environment)

ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]

@ashiqueps ashiqueps added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 12, 2022
@alextwoods alextwoods added investigating Issue is being investigated and removed needs-triage This issue or PR still needs to be triaged. labels Apr 12, 2022
@alextwoods alextwoods self-assigned this Apr 12, 2022
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. investigating Issue is being investigated
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants