Git Product home page Git Product logo

qontract-reconcile's Introduction

build license

qontract-reconcile

A tool to reconcile services with their desired state as defined in App-Interface. Additional tools that use the libraries created by the reconciliations are also hosted here.

Subcommands

qontract-reconcile

  acs-policies                    Manages RHACS security policy configurations
  acs-rbac                        Manages RHACS rbac configuration
  advanced-upgrade-scheduler      Manage Cluster Upgrade Policy schedules in
                                  OCM organizations based on OCM labels.
  aws-ami-cleanup                 Cleanup old and unused AMIs.
  aws-ami-share                   Share AMI and AMI tags between accounts.
  aws-cloudwatch-log-retention    Set up retention period for Cloudwatch logs.
  aws-ecr-image-pull-secrets      Generate AWS ECR image pull secrets and
                                  store them in Vault.
  aws-garbage-collector           Delete orphan AWS resources.
  aws-iam-keys                    Delete IAM access keys by access key ID.
  aws-iam-password-reset          Reset IAM user password by user reference.
  aws-saml-idp                    Manage the SAML IDP config for all AWS
                                  accounts.
  aws-saml-roles                  Manage the SAML IAM roles for all AWS
                                  accounts with SSO enabled
  aws-support-cases-sos           Scan AWS support cases for reports of leaked
                                  keys and remove them (only submits PR)
  aws-version-sync                Sync AWS asset version numbers to App-
                                  Interface
  blackbox-exporter-endpoint-monitoring
                                  Manages Prometheus Probe resources for
                                  blackbox-exporter
  change-owners                   Detects owners for changes in app-interface
                                  PRs and allows them to self-service merge.
  cluster-deployment-mapper       Maps ClusterDeployment resources to Cluster
                                  IDs.
  cna-resources                   Manage Cloud Resources using Cloud Native
                                  Assets (CNA).
  dashdotdb-cso                   Collects the ImageManifestVuln CRs from all
                                  the clusters and posts them to Dashdotdb.
  dashdotdb-dora                  Collects dora metrics.
  dashdotdb-dvo                   Collects the DeploymentValidations from all
                                  the clusters and posts them to Dashdotdb.
  dashdotdb-slo                   Collects the ServiceSloMetrics from all the
                                  clusters and posts them to Dashdotdb.
  database-access-manager         Manage Databases and Database Users.
  dynatrace-token-provider        Automatically provide dedicated Dynatrace
                                  tokens to management clusters
  email-sender                    Send email notifications to app-interface
                                  audience.
  gabi-authorized-users           Manages user access for GABI instances.
  gcr-mirror                      Mirrors external images into Google
                                  Container Registry.
  github                          Configures the teams and members in a GitHub
                                  org.
  github-owners                   Configures owners in a GitHub org.
  github-repo-invites             Accept GitHub repository invitations for
                                  known repositories.
  github-repo-permissions-validator
                                  Validates permissions in github
                                  repositories.
  github-users                    Validate compliance of GitHub user profiles.
  github-validator                Validates GitHub organization settings.
  gitlab-fork-compliance          Ensures that forks of App Interface are
                                  compliant.
  gitlab-housekeeping             Manage issues and merge requests on GitLab
                                  projects.
  gitlab-labeler                  Guesses and adds labels to merge requests
                                  according to changed paths.
  gitlab-members                  Manage GitLab group members.
  gitlab-mr-sqs-consumer          Listen to SQS and creates MRs out of the
                                  messages.
  gitlab-owners                   Manages labels on gitlab merge requests
                                  based on OWNERS files schema.
  gitlab-permissions              Manage permissions on GitLab projects.
  gitlab-projects                 Create GitLab projects.
  glitchtip                       Configure and enforce glitchtip instance
                                  configuration.
  glitchtip-project-alerts        Configure Glitchtip project alerts.
  glitchtip-project-dsn           Glitchtip project dsn as openshift secret.
  integrations-manager            Manages Qontract Reconcile integrations.
  jenkins-job-builder             Manage Jenkins jobs configurations using
                                  jenkins-jobs.
  jenkins-job-builds-cleaner      Clean up jenkins job history.
  jenkins-job-cleaner             Delete Jenkins jobs in multiple tenant
                                  instances.
  jenkins-roles                   Manage Jenkins roles association via REST
                                  API.
  jenkins-webhooks                Manage web hooks to Jenkins jobs.
  jenkins-webhooks-cleaner        Remove webhooks to previous Jenkins
                                  instances.
  jenkins-worker-fleets           Manage Jenkins worker fleets via JCasC.
  jira-permissions-validator      Validate permissions in Jira.
  jira-watcher                    Watch for changes in Jira boards and notify
                                  on Slack.
  ldap-groups                     Manages LDAP groups based on App-Interface
                                  roles.
  ldap-users                      Removes users which are not found in LDAP
                                  search.
  ocm-additional-routers          Manage additional routers in OCM.
  ocm-addons                      Manages cluster Addons in OCM.
  ocm-addons-upgrade-scheduler-org
                                  Manage Addons Upgrade Policy schedules in
                                  OCM organizations.
  ocm-addons-upgrade-tests-trigger
                                  Trigger jenkins jobs following Addon
                                  upgrades.
  ocm-aws-infrastructure-access   Grants AWS infrastructure access to members
                                  in AWS groups via OCM.
  ocm-clusters                    Manages clusters via OCM.
  ocm-external-configuration-labels
                                  Manage External Configuration labels in OCM.
  ocm-github-idp                  Manage GitHub Identity Providers in OCM.
  ocm-groups                      Manage membership in OpenShift groups via
                                  OCM.
  ocm-internal-notifications      Notifications to internal Red Hat users
                                  based on conditions in OCM.
  ocm-labels                      Manage cluster OCM labels.
  ocm-machine-pools               Manage Machine Pools in OCM.
  ocm-oidc-idp                    Manage OIDC cluster configuration in OCM
                                  organizations based on OCM labels. Part of
                                  RHIDP.
  ocm-standalone-user-management  Manages OCM cluster usergroups and
                                  notifications via OCM labels.
  ocm-update-recommended-version  Update recommended version for OCM orgs
  ocm-upgrade-scheduler-org       Manage Upgrade Policy schedules in OCM
                                  organizations.
  ocm-upgrade-scheduler-org-updater
                                  Update Upgrade Policy schedules in OCM
                                  organizations.
  openshift-cluster-bots          Manages dedicated-admin and cluster-admin
                                  creds.
  openshift-clusterrolebindings   Configures ClusterRolebindings in OpenShift
                                  clusters.
  openshift-groups                Manages OpenShift Groups.
  openshift-limitranges           Manages OpenShift LimitRange objects.
  openshift-namespace-labels      Manages labels on OpenShift namespaces.
  openshift-namespaces            Manages OpenShift Namespaces.
  openshift-network-policies      Manages OpenShift NetworkPolicies.
  openshift-resourcequotas        Manages OpenShift ResourceQuota objects.
  openshift-resources             Manages OpenShift Resources.
  openshift-rolebindings          Configures Rolebindings in OpenShift
                                  clusters.
  openshift-routes                Manages OpenShift Routes.
  openshift-saas-deploy           Manage OpenShift resources defined in Saas
                                  files.
  openshift-saas-deploy-change-tester
                                  Runs openshift-saas-deploy for each saas-
                                  file that changed within a bundle.
  openshift-saas-deploy-trigger-cleaner
                                  Clean up deployment related resources.
  openshift-saas-deploy-trigger-configs
                                  Trigger deployments when configuration
                                  changes.
  openshift-saas-deploy-trigger-images
                                  Trigger deployments when images are pushed.
  openshift-saas-deploy-trigger-moving-commits
                                  Trigger deployments when a commit changed
                                  for a ref.
  openshift-saas-deploy-trigger-upstream-jobs
                                  Trigger deployments when upstream job runs.
  openshift-serviceaccount-tokens
                                  Use OpenShift ServiceAccount tokens across
                                  namespaces/clusters.
  openshift-tekton-resources      Manages custom resources for Tekton based
                                  deployments.
  openshift-upgrade-watcher       Watches for OpenShift upgrades and sends
                                  notifications.
  openshift-users                 Deletion of users from OpenShift clusters.
  openshift-vault-secrets         Manages OpenShift Secrets from Vault.
  prometheus-rules-tester         Tests prometheus rules using promtool.
  quay-membership                 Configures the teams and members in Quay.
  quay-mirror                     Mirrors external images into Quay.
  quay-mirror-org                 Mirrors entire Quay orgs.
  quay-permissions                Manage permissions for Quay Repositories.
  quay-repos                      Creates and Manages Quay Repos.
  query-validator                 Validate queries to maintain consumer schema
                                  compatibility.
  requests-sender                 Send emails to users based on requests
                                  submitted to app-interface.
  resource-scraper                Get resources from clusters and store in
                                  Vault.
  resource-template-tester        Tests templating of resources.
  rhidp-sso-client                Manage Keycloak SSO clients for OCM
                                  clusters. Part of RHIDP.
  saas-auto-promotions-manager    Manage auto-promotions defined in SaaS files
  saas-file-validator             Validates Saas files.
  sendgrid-teammates              Manages SendGrid teammates for a given
                                  account.
  service-dependencies            Validate dependencies are defined for each
                                  service.
  signalfx-prometheus-endpoint-monitoring
                                  Manages Prometheus Probe resources for
                                  signalfx exporter
  skupper-network                 Manages Skupper Networks.
  slack-usergroups                Manage Slack User Groups (channels and
                                  users).
  sql-query                       Runs SQL Queries against app-interface RDS
                                  resources.
  status-board-exporter           Export Product and Application informnation
                                  to Status Board.
  status-page-components          Manages components on statuspage.io hosted
                                  status pages.
  terraform-aws-route53           Manage AWS Route53 resources using
                                  Terraform.
  terraform-cloudflare-dns        Manage Cloudflare DNS using Terraform.
  terraform-cloudflare-resources  Manage Cloudflare Resources using Terraform.
  terraform-cloudflare-users      Manage Cloudflare Users using Terraform.
  terraform-repo                  Manages raw HCL Terraform from a separate
                                  repository.
  terraform-resources             Manage AWS Resources using Terraform.
  terraform-tgw-attachments       Manages Transit Gateway attachments.
  terraform-users                 Manage AWS users using Terraform.
  terraform-vpc-peerings          Manage VPC peerings between OSD clusters and
                                  AWS accounts or other OSD clusters.
  vault-replication               Allow vault to replicate secrets to other
                                  instances.
  vpc-peerings-validator          Validates that VPC peerings do not exist
                                  between public and internal clusters.

tools

  • app-interface-metrics-exporter: Exports metrics from App-Interface.
  • app-interface-reporter: Creates service reports and submits PR to App-Interface.
  • qontract-cli: A cli tool for qontract (currently very good at getting information).

Usage

Use config.toml.example as a template to create a config.toml file.

Run a reconcile integration like this:

qontract-reconcile --config config.toml --dry-run <subcommand>

# review output and run without `--dry-run` to perform actual changes
qontract-reconcile --config config.toml <subcommand>

Note: you can use the QONTRACT_CONFIG environment variable instead of using --config.

OpenShift usage

OpenShift templates can be found here. In order to add integrations there please use the helm chart provided.

Installation

This project targets Python version 3.11.x for best compatibility. Verify the Python3 version that your shell is using with python3 --version. You can optionally use a tool like pyenv or asdf to manage Python versions on your computer.

Create and enter the virtualenv environment:

python3 -m venv venv
source venv/bin/activate

# make sure you are running the latest setuptools
pip install --upgrade pip setuptools

Install build prerequisites for psycopg2:

  • A C compiler
  • The Python header files. They are usually installed in a package such as python-dev or python3-dev.
  • libpq and pg_config
    • The libpq header files. They are usually installed in a package such as libpq-dev.
    • The pg_config program: it is usually installed by the libpq-dev package but sometimes it is not in a PATH directory.
    • On macOS, can be installed via brew install libpq. Make sure the installation path is added to your PATH, otherwise pg_config will not be available.
    • On Fedora, it can be installed with dnf install libpq-devel

Note: In macOS with M1/M2 pip will fail to install in a virtualenvironment unless LDFLAGS reference the openssl library path. It can be fixed with export LDFLAGS="-I/opt/homebrew/opt/openssl/include -L/opt/homebrew/opt/openssl/lib".

Install the package:

pip install .

# or use this for development mode so rebuild/reinstall isn't necessary after
# each change that is made during development
pip install -e .

# optionally install all test/type dependencies - useful when writing tests,
# auto-completion in your IDE, etc.
pip install -r ./requirements/requirements-dev.txt

If the commands above don't work maybe you need to install the python-devel and gcc-c++ packages. You may also need to first install a rust compiler (Mac OS directions) and then run python3 -m pip install --upgrade pip setuptools_rust.

Install runtime requirements:

Versions can be found in qontract-reconcile-base Dockerfile.

  • amtool
  • git-secrets
  • helm
  • kubectl
  • oc
  • promtool
  • skopeo
  • terraform

Requirements

Please see setup.py.

All requirements files are gathered in ./requirements/. It consists of:

Image build

In order to speed up frequent builds and avoid issues with dependencies, docker image makes use qontract-reconcile-build image. See app-sre/coontainer-images repository if you want to make changes to the base image.

This repo Dockerfile must only contain instructions related to the python code build.

The README contains more information about the Dockerfile and the build stages.

CI Tooling

This project uses tox for running tests, linting/static analysis, and type checkers. Some of the more common commands have been provided below, but see the tox docs for more complete documentation.

Running all checks (tests, linting, and type checkers):

tox

To run the checks faster (run in parallel):

tox -p

Running specific checks (can be much faster):

# Only run unit tests using Python 3.6
tox -e py36

# Only run linters
tox -e lint

# Only run the type checker
tox -e type

# Look at tox.ini for usage of posargs, this allows us to override which
# options are passed to the CLI where it's being used. This can be helpful
# for type checking a specific file, or running a subset of unit tests (this
# can be even faster).
tox -e type -- reconcile/utils/slack_api.py

Run reconcile loop for an integration locally in a container

This is currently only tested with the docker container engine.

For more flexible way to run in container, please see qontract-development-cli.

Prepare config.toml

Make sure the file ./config.dev.toml exists and contains your current configuration. Your config.dev.toml should point to the following qontract-server address:

[graphql]
server = "http://host.docker.internal:4000/graphql"

Run qontract-server

Start the qontract-server in a different window, e.g., via:

qontract-server$ make dev

Trigger integration

make dev-reconcile-loop INTEGRATION_NAME=terraform-resources DRY_RUN=--dry-run INTEGRATION_EXTRA_ARGS=--light SLEEP_DURATION_SECS=100

Query Classes

We use qenerate to generate data classes for GQL queries. GQL definitions and generated classes can be found here.

Workflow

  1. Define your query or fragment in a .gql file somewhere in reconcile/gql_definitions.
  2. Every gql file must hold exactly one query OR fragment definition. You must not have multiple definitions within one file.
  3. Do not forget to add # qenerate: plugin=pydantic_v1 in the beginning of the file. This tells qenerate which plugin is used to render the code.
  4. Have an up-to-date schema available at localhost:4000
  5. make gql-introspection gets the type definitions. They will be stored in reconcile/gql_definitions/introspection.json
  6. make gql-query-classes generates the data classes for your queries and fragments

Troubleshooting

faulthandler is enabled for this project and SIGUSR1 is registered to dump the traceback. To do so, you can use kill -USR1 pid where pid is the ID of the qontract-reconcile process.

Code style guide

Qontract-reconcile uses PEP8 as the code style guide. The style is enforced via PR checks with the help of the following utilities:

Run make format before you commit your changes to keep the code compliant.

Release

Release version are calculated from git tags of the form X.Y.Z.

  • If the current commit has such a tag, it will be used as is
  • Otherwise the latest tag of that format is used and:
    • the patch label (Z) is incremented
    • the string .pre<count>+<commitid> is appended. <count> is the number of commits since the X.Y.Z tag. ` is... the current commitid.

After the PR is merged, a CI job will be triggered that will publish the package to pypi: https://pypi.org/project/qontract-reconcile.

Licence

Apache License Version 2.0.

Authors

These tools have been written by the Red Hat App-SRE Team.

qontract-reconcile's People

Contributors

apahim avatar arilivigni avatar bhushanthakur93 avatar bkez322 avatar bumblefeng avatar chassing avatar cubismod avatar dependabot[bot] avatar dwelch0 avatar esron avatar fishi0x01 avatar geoberle avatar hemslo avatar janboll avatar jfchevrette avatar jmelis avatar jonmosco avatar kwilczynski avatar kylape avatar lechuk47 avatar maorfr avatar oliviahy avatar patjlm avatar piojo avatar rporres avatar skryzhny avatar suzana-nesic avatar tgpski avatar violetyao avatar xyntrix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qontract-reconcile's Issues

Improve error messaging when CLI fails to connect to specified GraphQL server

Currently, if the connection to the app-interface graphql server fails, we'll get an exception similar to the following.

Example (removed actual cluster names and config names)

(venv) [akonarde@katana qontract-reconcile]$ qontract-reconcile --config=config.toml --dry-run openshift-resources-annotate masked masked ConfigMap masked
Traceback (most recent call last):
  File "/usr/lib64/python3.7/urllib/request.py", line 1317, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/usr/lib64/python3.7/http/client.py", line 1229, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib64/python3.7/http/client.py", line 1275, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.7/http/client.py", line 1224, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib64/python3.7/http/client.py", line 1016, in _send_output
    self.send(msg)
  File "/usr/lib64/python3.7/http/client.py", line 956, in send
    self.connect()
  File "/usr/lib64/python3.7/http/client.py", line 928, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "/usr/lib64/python3.7/socket.py", line 727, in create_connection
    raise err
  File "/usr/lib64/python3.7/socket.py", line 716, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

What we should do:
Handle the exception and provide a better output, something along the lines of 'Could not connect to app-interface server specified in config.toml'

Handle qontract-reconcile resource not found exceptions

What I did

(venv) [akonarde@katana qontract-reconcile]$ qontract-reconcile --config=config.toml --dry-run openshift-resources-annotate cluster namespace ConfigMap some-config

Traceback (most recent call last):
  File "/home/akonarde/Git/qontract-reconcile/venv/lib/python3.7/site-packages/reconcile-0.1.0-py3.7.egg/reconcile/openshift_resources_annotate.py", line 49, in run
    resource = oc.get(namespace, kind, name)
  File "/home/akonarde/Git/qontract-reconcile/venv/lib/python3.7/site-packages/reconcile-0.1.0-py3.7.egg/utils/oc.py", line 51, in get
    return self._run_json(cmd)
  File "/home/akonarde/Git/qontract-reconcile/venv/lib/python3.7/site-packages/reconcile-0.1.0-py3.7.egg/utils/oc.py", line 89, in _run_json
    out = self._run(cmd)
  File "/home/akonarde/Git/qontract-reconcile/venv/lib/python3.7/site-packages/reconcile-0.1.0-py3.7.egg/utils/oc.py", line 81, in _run
    raise StatusCodeError(err)
utils.oc.StatusCodeError: b'Error from server (NotFound): configmaps "cloudwatch-exporter-config" not found\n'

In the above case, the said configmap was not present in the namespace.

Expected output:

Perhaps directly show utils.oc.StatusCodeError's message: Error from server (NotFound): configmaps "some-config" not found

Python3 Support

As seen in #27 ;

Looks like we have at least some compatibility issues with Python3. We should adapt the code in such a way that it works for both python 2 and 3.

Possible issue with parsing very long OpenShift annotations with serialized encapsulation

Problem: Unable to update a SelectorSyncSet, with a large (over 20k characters) last-applied-configuration annotation.

Error message from Openshift API:

The nnn-objectType "nnn-objectName" is invalid: metadata.resourceVersion: Invalid value: 0x0: must be specified for an update

Workaround: Manually edited the (SelectorSyncSet) object and removed metadata.annotations.kubectl.kubernetes.io/last-applied-configuration on the cluster. This allowed the "oc apply" to apply successfully.

Possible Upstream Bug-ID(s):

Symptom(s): Encountered an error from the OpenShift API where attempting to "oc apply" an object with a very large (20k character) metadata.annotations.kubectl.kubernetes.io/last-applied-configuration results in error. The annotation blob (which is serialized) converted to yaml, results in some new-lines following white space in the output, which may or may not be triggering this condition.

Data Gathering, Other artifacts:

When exporting the object as json (oc get nnType/nnObject -ojson), the line feeds are not present the the serialization is sane. When exporting the object as yaml (oc get nnType/nnObject -oyaml, the line feeds are present in some locations where whitespace is present, which seems to be corrupting the serialization.

Likewise, if I dump the entire object to json, and then attempt to convert the json to yaml using yq, the result is also new-line-included serialization -- so this may be exclusive to how our oc-apply the parse/re-parsing the serialized output and attempting to canonicalize [1]. Trying to track down the default line-wrap width there..

[1]

def canonicalize(body):
body = copy.deepcopy(body)
# create annotations if not present
body['metadata'].setdefault('annotations', {})
if body['metadata']['annotations'] is None:
body['metadata']['annotations'] = {}
annotations = body['metadata']['annotations']
# remove openshift specific params
body['metadata'].pop('creationTimestamp', None)
body['metadata'].pop('resourceVersion', None)
body['metadata'].pop('generation', None)
body['metadata'].pop('selfLink', None)
body['metadata'].pop('uid', None)
body['metadata'].pop('namespace', None)
annotations.pop('kubectl.kubernetes.io/last-applied-configuration',
None)

Removing the single serialized line from json input demonstrates 8 extra new-lines are being added when parsed into yaml.

$ yq -y .metadata.annotations[]  raw.json  | wc -l
14
$ yq -y .metadata.annotations[]  raw.last-removed.json  | wc -l
5

# json: 1 line, 20,247 characters
# yaml: 9 lines, 17,185 characters
$ jq . line.json  | wc
      1      25   20182
$ yq -y . line.json | wc 
      9      25   17185

It is also possible that some encoding within the yaml (de-)serialization is causing the syntax to become multi-lined or invalid. This size of annotation is also highly irregular and a-typical for openshift objects.

Have a single way to interact with OpenShift API

Currently, the openshift-resources subcommand talks to openshift API with a wrapper to the binary, while the openshift-rolebindings integration uses requests to talk directly to the OpenShift api.

This is causing confusion debugging, where we are seeing one of the integration fail on an SSL cert verification check, while the others interacting with OpenShift work just fine.

Proposal: We should have a uniform way of talking to the OpenShift API across integrations.

CC @jmelis @maorfr

Invalid podman arguments in makefile

The Makefile includes automatic use of podman, but includes an option that is not accepted by podman.

https://github.com/app-sre/qontract-reconcile/blob/master/Makefile#L68

This argument is not valid for podman:

--add-host=host.docker.internal:host-gateway

And creates the following failure mode when dev-reconcile-loop is used:

Error: invalid IP address in add-host: "host-gateway"

Currently playing with what would be valid arguments for podman runtime. It ties into qontract-server makefile as well, since that runs the server with direct port bindings. Maybe both using an expected podman network would be a preferable solution, although it looks like the argument isn't needed at all when running in podman, or the --network host argument can be used.

Handle exception when GraphQL server is not running

Currently if you try to run qontract-reconcile without having the graphql server running, it'll throw an exception.

Proposal: Handle this gracefully, return a clean message

~/Git/qontract-reconcile ⑂master* $ qontract-reconcile --config=config.local.toml --dry-run openshift-resources

Traceback (most recent call last):
  File "/home/akonarde/Git/qontract-reconcile/venv/bin/qontract-reconcile", line 11, in <module>
    load_entry_point('reconcile', 'console_scripts', 'qontract-reconcile')()
  File "/home/akonarde/Git/qontract-reconcile/venv/lib/python2.7/site-packages/Click-7.0-py2.7.egg/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/akonarde/Git/qontract-reconcile/venv/lib/python2.7/site-packages/Click-7.0-py2.7.egg/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/akonarde/Git/qontract-reconcile/venv/lib/python2.7/site-packages/Click-7.0-py2.7.egg/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/akonarde/Git/qontract-reconcile/venv/lib/python2.7/site-packages/Click-7.0-py2.7.egg/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/akonarde/Git/qontract-reconcile/venv/lib/python2.7/site-packages/Click-7.0-py2.7.egg/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/akonarde/Git/qontract-reconcile/venv/lib/python2.7/site-packages/Click-7.0-py2.7.egg/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/akonarde/Git/qontract-reconcile/reconcile/cli.py", line 159, in openshift_resources
    ctx.obj['dry_run'], thread_pool_size)
  File "/home/akonarde/Git/qontract-reconcile/reconcile/cli.py", line 65, in run_integration
    func(*args)
  File "/home/akonarde/Git/qontract-reconcile/reconcile/openshift_resources.py", line 507, in run
    namespaces_query = gqlapi.query(NAMESPACES_QUERY)['namespaces']
  File "/home/akonarde/Git/qontract-reconcile/utils/gql.py", line 24, in query
    result_json = self.client.execute(query, variables)
  File "/home/akonarde/Git/qontract-reconcile/venv/lib/python2.7/site-packages/graphqlclient-0.2.4-py2.7.egg/graphqlclient/client.py", line 11, in execute
    return self._send(query, variables)
  File "/home/akonarde/Git/qontract-reconcile/venv/lib/python2.7/site-packages/graphqlclient-0.2.4-py2.7.egg/graphqlclient/client.py", line 29, in _send
    response = urllib.request.urlopen(req)
  File "/usr/lib64/python2.7/urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib64/python2.7/urllib2.py", line 429, in open
    response = self._open(req, data)
  File "/usr/lib64/python2.7/urllib2.py", line 447, in _open
    '_open', req)
  File "/usr/lib64/python2.7/urllib2.py", line 407, in _call_chain
    result = func(*args)
  File "/usr/lib64/python2.7/urllib2.py", line 1230, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/usr/lib64/python2.7/urllib2.py", line 1200, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error [Errno 111] Connection refused>

saasherder.py:_process_template does not work in private GitHub repositories

When configuring a /app-sre/saas-file-2.yml pointing to a private GitHub repository, the following error happens (even having app-sre-bot with write access):

[2022-01-21 18:14:24] [ERROR] [saasherder.py:_process_template:479] - [https://github.com/quarkusio/registry.quarkus.redhat.com//openshift/template.yaml:9178abdbcb01f35c09473113afb67239d74ad85d] error fetching template: 404 {"message": "Not Found", "documentation_url": "https://docs.github.com/rest/reference/repos#get-a-repository"}
[2022-01-21 18:14:24] [ERROR] [saasherder.py:_process_template:479] - [https://github.com/quarkusio/registry.quarkus.redhat.com//openshift/template.yaml:main] error fetching template: 404 {"message": "Not Found", "documentation_url": "https://docs.github.com/rest/reference/repos#get-a-repository"}

The error is gone if I change the repository visibility to public

Reconcile openshift_resources fail on actual apply, passes dry run

Dry run for annotating a configmap:

(venv) [akonarde@katana qontract-reconcile]$ qontract-reconcile --config=config.toml --dry-run openshift-resources-annotate app-sre app-sre-exporters ConfigMap cloudwatch-exporter-config
INFO: annotated

For the same resource, running the actual annotation

(venv) [akonarde@katana qontract-reconcile]$ qontract-reconcile --config=config.toml openshift-resources-annotate app-sre app-sre-exporters ConfigMap cloudwatch-exporter-config
Traceback (most recent call last):
  File "/home/akonarde/Git/qontract-reconcile/venv/bin/qontract-reconcile", line 11, in <module>
    load_entry_point('reconcile==0.1.0', 'console_scripts', 'qontract-reconcile')()
  File "/home/akonarde/Git/qontract-reconcile/venv/lib/python3.7/site-packages/Click-7.0-py3.7.egg/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/akonarde/Git/qontract-reconcile/venv/lib/python3.7/site-packages/Click-7.0-py3.7.egg/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/akonarde/Git/qontract-reconcile/venv/lib/python3.7/site-packages/Click-7.0-py3.7.egg/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/akonarde/Git/qontract-reconcile/venv/lib/python3.7/site-packages/Click-7.0-py3.7.egg/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/akonarde/Git/qontract-reconcile/venv/lib/python3.7/site-packages/Click-7.0-py3.7.egg/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/akonarde/Git/qontract-reconcile/venv/lib/python3.7/site-packages/Click-7.0-py3.7.egg/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/akonarde/Git/qontract-reconcile/venv/lib/python3.7/site-packages/reconcile-0.1.0-py3.7.egg/reconcile/cli.py", line 99, in openshift_resources_annotate
    ctx.obj['dry_run'], cluster, namespace, kind, name)
  File "/home/akonarde/Git/qontract-reconcile/venv/lib/python3.7/site-packages/reconcile-0.1.0-py3.7.egg/reconcile/cli.py", line 20, in run_integration
    func(*args)
  File "/home/akonarde/Git/qontract-reconcile/venv/lib/python3.7/site-packages/reconcile-0.1.0-py3.7.egg/reconcile/openshift_resources_annotate.py", line 64, in run
    oc.apply(namespace, openshift_resource.toJSON())
  File "/home/akonarde/Git/qontract-reconcile/venv/lib/python3.7/site-packages/reconcile-0.1.0-py3.7.egg/utils/oc.py", line 55, in apply
    self._run(cmd, stdin=resource)
  File "/home/akonarde/Git/qontract-reconcile/venv/lib/python3.7/site-packages/reconcile-0.1.0-py3.7.egg/utils/oc.py", line 76, in _run
    out, err = p.communicate(stdin_text)
  File "/usr/lib64/python3.7/subprocess.py", line 939, in communicate
    stdout, stderr = self._communicate(input, endtime, timeout)
  File "/usr/lib64/python3.7/subprocess.py", line 1666, in _communicate
    input_view = memoryview(self._input)
TypeError: memoryview: a bytes-like object is required, not 'str'

Should the State class handle content?

At this point, the state required by integrations is very basic (exists+add). No content handling is required, the state is only used to persist that an action was carried out.

As we grow in complexity, we may need to enhance utils/state.py to keep state with content.

#418 (comment)

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.