Skip to content

Retries for token resfresh are infinite #3077

@3dquattro

Description

@3dquattro

Description

Retries for token resfresh are infinite, in cases when, for example, key in memory have changed or something like that (initial key validation passed, but on init/refresh token something happens (auth service is returning 504s, or cache gets broken if client is cached, anything) user might not get any feedback except prints (which are not seen in some cases when logging is used)

Steps to reproduce

Example is purely for example.
It happens from time to time, not stable reproduction, but it happens when doing something like this:

from functools import cached_property
import json

from stackit.core.auth_methods.key_auth import (
    KeyAuth
)
from stackit.core.configuration import Configuration

from stackit.iaas.api.default_api import DefaultApi
from stackit.iaas.models import (
    CreateVolumePayload,
)


class Example:
    def __init__(self, config):
        self.config = config
        sa_dict = json.loads(self.config["service_account"])
        key_auth = KeyAuth(self._build_service_account_key(sa_dict))
        self._credentials = Configuration(custom_auth=key_auth)
    
    @cached_property
    def client(self):
        return DefaultApi(self._credentials)
    
    def _create_volume(self, **kwargs):
        payload = CreateVolumePayload(**kwargs)
        return self.client.create_volume(self.project_id, payload)

# 
  1. Run some cloud operation
  2. If something wrong goes with token retreival, operation gets infinitely stuck

Actual behavior

HTTP kind on token retreival is getting ignored. 504, 400 - any of it

Expected behavior

Do not ignore errors on token retreival and limit retries before raising exception.

Environment

  • OS: Ubuntu 23.04
  • Python version (see python --version): 3.11.4
  • Version of the Python STACKIT SDK: 0.1.7
$ pip list | grep "stackit"

stackit                   0.1.7
stackit-core              0.2.0
stackit-iaas              0.5.5

Additional information
PR: #3078

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions