GithubHelp home page GithubHelp logo

app-sre / sretoolbox Goto Github PK

View Code? Open in Web Editor NEW
7.0 7.0 22.0 256 KB

Set of libraries commonly used by multiple SRE projects

License: Apache License 2.0

Makefile 0.87% Shell 0.20% Python 98.58% Dockerfile 0.35%

sretoolbox's Introduction

SRE Toolbox

Set of libraries commonly used by multiple SRE projects:

  • container.Image: class for container image inspection.
  • container.Skopeo: wrapper around Skopeo.
  • utils.replace_values: deep replace of object values according to values map.
  • utils.retry: decorator to add resilience to function calls.

Install

From PyPI:

$ pip install sretoolbox

From source:

$ python setup.py install

Use

Just import the library you want. Example:

>>> from sretoolbox import container
>>> image = container.Image('fedora')
>>> if image:
...     print('Image exists!')
...
Image exists!
>>>

Develop

Install the development requirements:

$  make develop

Run the code checks and tests:

$  make check

Release

Edit the VERSION file and change the new version. Submit a pull request to master. When it is merged, create a tag and push it to app-sre/sretoolbox.

This will trigger a CI job that will publish the package on pypi.

License

The default license of the code in this repository is [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0). That applies for most of the code here, as they were written from scratch, but exceptions exist. In any case, each module carries the corresponding licensing information.

sretoolbox's People

Contributors

2uasimojo avatar apahim avatar arilivigni avatar dependabot[bot] avatar erdii avatar geoberle avatar hemslo avatar jfchevrette avatar jmelis avatar kylape avatar maorfr avatar mayankshah1607 avatar patjlm avatar piojo avatar pombredanne avatar rporres avatar rpriyanshu9 avatar sandhyadalavi avatar suzana-nesic avatar yashvardhan-kukreja avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

sretoolbox's Issues

License of retry decorator

While reviewing the code of

# source: https://www.calazan.com/retry-decorator-for-python-3/
I visited the URL at https://www.calazan.com/retry-decorator-for-python-3/ and found that it was mentioning this:

Below is a nice retry decorator I found on this https://www.saltycrane.com/blog/2009/11/trying-out-retry-decorator-python/ site. I just changed one line of code to make it Python 3 compatible (basically had to change the print statement to a function).

And on https://www.saltycrane.com/blog/2009/11/trying-out-retry-decorator-python/

Code / License
This code is also on github at: https://github.com/saltycrane/retry-decorator It is BSD licensed.

And a link to https://github.com/saltycrane/retry-decorator/blob/master/LICENSE

This is a BSD-3-Clause. It would make sense to add this in the repo?

_parse_image_url() doesn't support image digests

A recent deploy of a Hive operator failed with:

Image does not exist: quay.io/****/pagerduty-operator-registry@sha256:bc1ed82a75f2ca160225b8281c50b7074e7678c2a1f61b1fb298e545b455925e

The image exists:

docker pull quay.io/****/pagerduty-operator-registry@sha256:bc1ed82a75f2ca160225b8281c50b7074e7678c2a1f61b1fb298e545b455925e
quay.io/****/pagerduty-operator-registry@sha256:bc1ed82a75f2ca160225b8281c50b7074e7678c2a1f61b1fb298e545b455925e: Pulling from ****/pagerduty-operator-registry
Digest: sha256:bc1ed82a75f2ca160225b8281c50b7074e7678c2a1f61b1fb298e545b455925e
Status: Image is up to date for quay.io/****/pagerduty-operator-registry@sha256:bc1ed82a75f2ca160225b8281c50b7074e7678c2a1f61b1fb298e545b455925e
quay.io/****/pagerduty-operator-registry@sha256:bc1ed82a75f2ca160225b8281c50b7074e7678c2a1f61b1fb298e545b455925e
13:58:43 [2021-04-16 17:58:43] [ERROR] [saasherder.py:_check_image:543] - [saas-pagerduty-operator/pagerduty-operator] https://github.com/openshift/pagerduty-operator/blob/master/hack/olm-registry/olm-artifacts-template.yaml: Image does not exist: quay.io/****/pagerduty-operator-registry@sha256:bc1ed82a75f2ca160225b8281c50b7074e7678c2a1f61b1fb298e545b455925e
13:58:43 Traceback (most recent call last):
13:58:43   File "/usr/local/bin/qontract-reconcile", line 33, in <module>
13:58:43     sys.exit(load_entry_point('reconcile==0.2.2', 'console_scripts', 'qontract-reconcile')())
13:58:43   File "/usr/local/lib/python3.6/site-packages/click-7.1.2-py3.6.egg/click/core.py", line 829, in __call__
13:58:43     return self.main(*args, **kwargs)
13:58:43   File "/usr/local/lib/python3.6/site-packages/click-7.1.2-py3.6.egg/click/core.py", line 782, in main
13:58:43     rv = self.invoke(ctx)
13:58:43   File "/usr/local/lib/python3.6/site-packages/click-7.1.2-py3.6.egg/click/core.py", line 1259, in invoke
13:58:43     return _process_result(sub_ctx.command.invoke(sub_ctx))
13:58:43   File "/usr/local/lib/python3.6/site-packages/click-7.1.2-py3.6.egg/click/core.py", line 1066, in invoke
13:58:43     return ctx.invoke(self.callback, **ctx.params)
13:58:43   File "/usr/local/lib/python3.6/site-packages/click-7.1.2-py3.6.egg/click/core.py", line 610, in invoke
13:58:43     return callback(*args, **kwargs)
13:58:43   File "/usr/local/lib/python3.6/site-packages/reconcile-0.2.2-py3.6.egg/reconcile/utils/environ.py", line 15, in f_environ
13:58:43     f(*args, **kwargs)
13:58:43   File "/usr/local/lib/python3.6/site-packages/reconcile-0.2.2-py3.6.egg/reconcile/utils/environ.py", line 15, in f_environ
13:58:43     f(*args, **kwargs)
13:58:43   File "/usr/local/lib/python3.6/site-packages/reconcile-0.2.2-py3.6.egg/reconcile/utils/binary.py", line 18, in f_binary
13:58:43     f(*args, **kwargs)
13:58:43   File "/usr/local/lib/python3.6/site-packages/reconcile-0.2.2-py3.6.egg/reconcile/utils/binary.py", line 60, in f_binary_version
13:58:43     f(*args, **kwargs)
13:58:43   File "/usr/local/lib/python3.6/site-packages/click-7.1.2-py3.6.egg/click/decorators.py", line 21, in new_func
13:58:43     return f(get_current_context(), *args, **kwargs)
13:58:43   File "/usr/local/lib/python3.6/site-packages/reconcile-0.2.2-py3.6.egg/reconcile/cli.py", line 758, in openshift_saas_deploy
13:58:43     saas_file_name, env_name, gitlab_project_id)
13:58:43   File "/usr/local/lib/python3.6/site-packages/reconcile-0.2.2-py3.6.egg/reconcile/cli.py", line 399, in run_integration
13:58:43     func_container.run(dry_run, *args, **kwargs)
13:58:43   File "/usr/local/lib/python3.6/site-packages/reconcile-0.2.2-py3.6.egg/reconcile/utils/defer.py", line 15, in func_wrapper
13:58:43     return func(*args, defer=defer, **kwargs)
13:58:43   File "/usr/local/lib/python3.6/site-packages/reconcile-0.2.2-py3.6.egg/reconcile/openshift_saas_deploy.py", line 69, in run
13:58:43     if not saasherder.validate_promotions():
13:58:43   File "/usr/local/lib/python3.6/site-packages/reconcile-0.2.2-py3.6.egg/reconcile/utils/saasherder.py", line 928, in validate_promotions
13:58:43     commit_sha = item['commit_sha']
13:58:43 TypeError: 'NoneType' object is not subscriptable

SREP haven't hit this issue yet because on cluster operators are deployed via selector sync set inside the OC template. Saasherder doesn't validate the CatalogSource images inside the selector sync set here. This is different for Hive operators as we deploy the CatalogSource directly in the OC template.

It looks like that method is the issue.

Parsing a digest returns the following structure:

{'scheme': 'docker://', 'registry': 'docker.io', 'port_colon': None, 'port': None, 'registry_slash': None, 'repository': 'library', 'repo_slash': None, 'image': 'sha256', 'tag_colon': ':', 'tag': 'bc1ed82a75f2ca160225b8281c50b7074e7678c2a1f61b1fb298e545b455925e'}

cc/ @2uasimojo @BumbleFeng @apahim

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.