Giter Site home page Giter Site logo

oci_env's Introduction

OCI Env

A developer environment for pulp based off of the Pulp OCI Images

Getting started

  1. Install the oci-env python client.
cd oci_env

# if pip3 isn't available, try pip. Python 3 is required for oci-env.
pip3 install -e client
  1. Install podman or docker compose

  2. Set up your directory with the following structure:

    .
    ├── oci_env
    ├── pulp-openapi-generator
    ├── pulp_ansible
    ├── pulp_container
    ├── pulpcore
    └── any_other_python_sources
    

    The OCI env project should be in the same directory as any pulp plugins you wish to run.

    Note, the /src/ folder in the container is the parent folder containing the oci_env and all plugin checkouts on the container host.

  3. Define your compose.env file.

    cp compose.env.example compose.env

    A minimal compose.env will look something like this:

    DEV_SOURCE_PATH=pulpcore:pulp_ansible
    
    # this is set to podman by default.
    COMPOSE_BINARY=docker
    

    In this example, ../pulpcore and ../pulp_ansible will be installed from source. Other settings include:

    • COMPOSE_PROFILE: this is used to define environments with extra services running. This could be used to launch a UI, set up an authentication provider service or configure an object store. Example COMPOSE_PROFILE=ha:galaxy_ng/ui. This will use the the ha profile from oci_env/profiles/ and the ui profile from galaxy_ng/profiles/
    • PULP_<SETTING_NAME>: set any setting.py value for your environment. Example: PULP_GALAXY_REQUIRE_CONTENT_APPROVAL=False
  4. Run the environment

    # build the images
    oci-env compose build
    
    # start the service
    oci-env compose up 

    The oci-env compose command accepts all the same arguments as podman-compose or docker-compose

    By default the API will be served from http://localhost:5001/pulp/api/v3/. You can login with admin/password by default. E.g.: http --auth admin:password get http://localhost:5001/pulp/api/v3/status/ The api will reload anytime changes are made to any of the DEV_SOURCE_PATH projects.

    oci-env compose accepts all of the arguments that docker and podman compose take. You can also launch the environment in the background with oci-env compose up -d and access the logs with oci-env compose logs -f if you don't want to run it in the foreground.

    In case you have problems with setup in macOS, check these troubleshooting tips.

  5. Teardown

    To shut down the containers run oci-env compose down. Data in your system will be preserved when you restart the containers.

    To delete the database run oci-env compose down --volumes. This will shut down the containers and delete all the container data in your system.

The oci-env CLI

This CLI has all the functionality required to run the OCI Env developer environment. See oci-env --help for a list of supported commands.

oci-env can either be run in the oci_env/ root dir, or it can be executed from anywhere by setting the OCI_ENV_PATH environment variable. The path supplied to OCI_ENV_PATH is expected to be the oci_env/ project root dir.

Resetting the DB

The DB can be reset and migrations rerun with the oci-env db reset command. Alternatively, you could run the following:

oci-env compose down --volumes  # Shut down the containers and delete all the container data on your system
oci-env compose up

Multiple environments

oci-env supports running multiple environments simultaneously. To do this, simply create a new .env file such as:

# custom.env

COMPOSE_PROFILE=my_profiles
DEV_SOURCE_PATH=pulpcore

# These three values must be different from the api port, docs port and project name for any other
# instances of the environment that are running to avoid conflicts.
API_PORT=4002
DOCS_PORT=12346
COMPOSE_PROJECT_NAME=test

# If you want to use a different directory for your git checkouts you can set this
# SRC_DIR=/path/to/my/git/checkouts

Once the file is defined run oci-env -e custom.env compose up to launch the new environment. The path to custom.env can be an absolute path or relative to your PWD. If you have OCI_ENV_PATH defined you can create a directory for your custom definitions and run oci-env from there without having to specify an absolute path.

Example:

~
├── oci_env
└── oci_env_configs
    ├── custom.env
    └── test.env
export OCI_ENV_PATH="~/oci_env"

cd oci_env_configs
oci-env -e custom.env compose up

Running Tests

Lint

# Install the lint requirements and run the linter for a specific plugin

oci-env test -i -p PLUGIN_NAME lint

# Run the linter without installing lint dependencies.
oci-env test -p PLUGIN_NAME lint

Functional

Before functional tests can be run, you must clone github.com/pulp/pulp-openapi-generator into the parent directory.

Ex:

.
├── (...)
├── oci_env
└── pulp-openapi-generator
# Generate the pulp client. This will build clients for all plugins in DEV_SOURCE_PATH. -i will also install the client in the container.
oci-env generate-client -i

# Install the functional test requirements and run the tests
oci-env test -i -p PLUGIN_NAME functional

# Run the tests without installing dependencies.
oci-env test -p PLUGIN_NAME functional

Bindings for specific plugins can be regenerated with oci-env generate-client PLUGIN_NAME.

Use --language parameter to specify the programming language the bindings should be generated for (default: python), e.g. oci-env generate-client -l ruby PLUGIN_NAME.

Debugging functional tests

  1. Add "epdb" to the functest_requirements.txt file in your pulp_ansible checkout path.
  2. Inside any functional test, add import epdb; epdb.st().
  3. Re-run oci-env test -i functional and oci-env test -p pulp_ansible functional --capture=no commands again.

Using PyCharm remote debug server

  1. Start the debugger server in PyCharm. When using podman, the hostname should be set to host.containers.internal hostname. Docker users should use host.docker.internal hostname.
  2. Add a break point to your Pythong code:
import pydevd_pycharm
pydevd_pycharm.settrace('host.containers.internal', port=3013, stdoutToServer=True, stderrToServer=True)`
  1. Restart all services you need to pick up the code change by running s6-svc -r /var/run/service/<service_name>
  2. Perform the action that should trigger the code to run.

Please note that host.containers.internal points to the wrong interface in podman < 4.1. When using podman < 4.1, you need modify /etc/hosts inside the container running Pulp with the IP address for the publicly facing network interface on the host.

Building docs

First, navigate to /src/{plugin}/docs in the container and do the following:

pip3 install -r ../doc_requirements.txt
make clean && make diagrams && make html
python3 -m http.server ${DOCS_PORT}

Then, visit 0.0.0.0:${DOCS_PORT} in a web browser to preview the documentation.

Unit

# Install the unit test dependencies for a plugin and run it.
oci-env test -i -p PLUGIN_NAME unit

# Run the unit tests for a plugin without installing test dependencies.
oci-env test -p PLUGIN_NAME unit

Profiles

Custom Profiles

You can create custom profiles for your instance of oci_env by creating adding _local to the end of the profile name. These profiles will be ignored by git. Example oci_env/profiles/my_custom_profile_local/.

Writing New Profiles

OCI env has a pluggable profile system. Profiles can be defined in oci_env/profiles/ or in any pulp plugin at <PLUGIN_NAME>/profiles/.

To generate a new profile template run:

# Generate a new profile in oci_env
oci-env profile init my_profile

# Generate a new profile in a plugin repo
oci-env profile init -p PLUGIN_NAME my_profile

# List available profiles
oci-env profile ls

# Display the README.md for a profile
oci-env profile docs my_profile

Each profile goes in it's own directory and can include:

  • compose.yaml: This is a docker compose file that can define new services or modify the base pulp service.
  • pulp_config.env: Environment file that defines any settings that the profile needs to run.
  • init.sh: Script that gets run when the environment loads. Can be used to initialize data and set up tests. Must be a bash script.
  • profile_reqirements.txt: A list of other profiles that are required to be set in COMPOSE_PROFILE for this profile to function.
  • profile_default_config.env: A list of default variables to use if not specified by the user.
  • README.md: Readme file describing what the profile is for and how to use it.

Variables

These variables can be used in pulp_config.env and compose.yaml:

  • API_HOST: hostname where pulp expects to run (default: localhost).
  • API_PORT: port that pulp expects to run on. This port will also get exposed on the pulp container (default: 5001).
  • API_PROTOCOL: can be http or https (default: http).
  • NGINX_SSL_PORT: the port on which Nginx listens to https traffic (default: 443). API_PROTOCOL needs to be https.
  • NGINX_PORT: the port on which Nginx listens to http traffic. Note: the functional tests won't work correctly if this is different from API_PORT. (default: 5001, or the value of API_PORT).
  • DEV_SOURCE_PATH: colon separated list of python dependencies to include from source.
  • COMPOSE_PROFILE: colon separated list of profiles.
  • DJANGO_SUPERUSER_USERNAME: username for the super user (default: admin).
  • DJANGO_SUPERUSER_PASSWORD: password for the super user (default: password).
  • COMPOSE_PROJECT_NAME: the project name passed to podman-compose. Use this when running multiple environments to keep containers and volumes separate (default: oci_env).
  • SRC_DIR: path to load source code from. Set this if you want to use a different set of git checkouts with your environment (default: oci_env/../)

Variables are templated using pythons "{VAR}".template(VAR="my_var") function, so they must be referenced as {VARIABLE_NAME} in environment and compose files.

Profiles can use variables outside of this list as well. They are just required to be defined in the user's compose.env file or in the profile's (or its parents) profile_default_config.env file.

Example pulp_config.env:

PULP_ANSIBLE_API_HOSTNAME="{API_PROTOCOL}://{API_HOST}:{API_PORT}"
PULP_ANSIBLE_CONTENT_HOSTNAME="{API_PROTOCOL}://{API_HOST}:{API_PORT}/pulp/content"

Example

Profile structure in the galaxy_ng plugin

galaxy_ng/profiles/
└── ui
    ├── compose.yaml
    └── pulp_config.env

compose.yaml: This defines a UI service that builds the container found at ANSIBLE_HUB_UI_PATH and configures the UI to proxy requests to the pulp API server.

version: "3.7"

services:
  ui:
    build:
      context: "{ANSIBLE_HUB_UI_PATH}"
    ports:
      - "8002:8002"
    volumes:
      - "{ANSIBLE_HUB_UI_PATH}:/hub/app/"
    tmpfs:
      # Forces npm to ignore the node_modules in the volume and look
      # for it in ../node_modules instead, while still being able to write .cache
      - "/hub/app/node_modules"
    depends_on:
      - pulp
    environment:
      - "API_PROXY_HOST=pulp"
      - "API_PROXY_PORT=80"
      - "DEPLOYMENT_MODE=standalone"

pulp_config.env: The UI expects the galaxy apis to be served from /api/automation-hub/ and for the app to be launched in standalone mode. The environment file provided with the profile ensures that the API is configured correctly to consume the new service.

PULP_CONTENT_PATH_PREFIX=/api/automation-hub/v3/artifacts/collections/

PULP_GALAXY_API_PATH_PREFIX=/api/automation-hub/

PULP_GALAXY_COLLECTION_SIGNING_SERVICE=ansible-default
PULP_RH_ENTITLEMENT_REQUIRED=insights

PULP_ANSIBLE_API_HOSTNAME={API_PROTOCOL}://{API_HOST}:{API_PORT}
PULP_ANSIBLE_CONTENT_HOSTNAME={API_PROTOCOL}://{API_HOST}:{API_PORT}/api/automation-hub/v3/artifacts/collections

PULP_TOKEN_AUTH_DISABLED=true

To activate this profile set COMPOSE_PROFILE=galaxy_ng/ui. Running this will launch the UI container along with pulp.

dnewswan-mac:oci_env dnewswan$ docker ps
CONTAINER ID   IMAGE                         COMMAND                  CREATED         STATUS         PORTS                    NAMES
2cc06f79bc87   oci_env_ui                    "docker-entrypoint.s…"   3 seconds ago   Up 1 second    0.0.0.0:8002->8002/tcp   oci_env_ui_1
e1c3ae797018   localhost/oci_env/pulp:base   "/init"                  6 seconds ago   Up 2 seconds   0.0.0.0:5001->80/tcp     oci_env_pulp_1

Multiple profiles can be selected with COMPOSE_PROFILE=galaxy_ng/ui:profile2:profile3. The last profile loaded gets priority on environment variables. Each compose.yaml is added additively, and subsquent profles can modify the services from previous profiles.

How it Works

At it's core, the oci-env command launches a predictable set of containers with a CLI interface to communicate with them. Thes containers are launched by taking advantage of a feature in docker and podman compose that allow multiple compose.yaml files to be selected via the -f flag. The command that oci-env runs can be viewed with the -v flag:

oci-env -v compose up
Running command in container: docker-compose -p oci_env -f /Users/dnewswan/code/hub/oci_env/.compiled/oci_env/base_compose.yaml -f /Users/dnewswan/code/hub/oci_env/.compiled/oci_env/galaxy_ui_compose.yaml up

Since not all compose runtimes support variable interpolation, oci-env handles that by itself. The compose.yaml files provided by all of the plugins are gathered up and the variables defined in your compose.env file are substituted using python's str.format() command and placed in the .compiled/<COMPOSE_PROJECT_NAME>/ directory. This directory contains all the information for the running instance of your dev enviornment:

(venv) dnewswan-mac:oci_env dnewswan$ tree .compiled/
.compiled/
├── ci
│  ├── base_compose.yaml
│  ├── combined.env
│  └── init.sh
└── oci_env
    ├── base_compose.yaml
    ├── combined.env
    ├── galaxy_ui_compose.yaml
    └── init.sh

.compiled/ contains all your compose files (with the correct variable substitutions) as well as an init.sh script that launches each profile's init.sh script and a combined.env file which combines all the pulp_config.env files into one and performs variable substitution. The combined.env file is then loaded into the pulp container as an environment variable, and init.sh is run once the container has initialized.

Once all of the information here is compiled, oci-env launches the container runtime and mounts the following directories:

  • oci_env is mounted into /opt/oci_env/. This creates a predictable location to launch scripts provided by oci_env (such as /opt/oci_env/base/container_scripts/run_functional_tests.sh)
  • your source code directory is mountent into /opt/src/. This provies a predictable location to find plugin source code (such as /src/pulpcore/).

oci_env's People

Contributors

bmbouter avatar decko avatar dkliban avatar douglas avatar dralley avatar eamontracey avatar fao89 avatar gerrod3 avatar ggainey avatar jctanner avatar jerabekjiri avatar kahowell avatar lubosmj avatar m-bucher avatar mdellweg avatar michalpysik avatar mikedep333 avatar newswangerd avatar pedro-psb avatar quba42 avatar rochacbruno avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

oci_env's Issues

Include pulp_file to the `generate-client` command if using a pulpcore >=`3.40.1`

If you one is using the current main branch of pulpcore where it includes pulp_file now by default the default command oci-env generate-client -i (which installs all clients for the projects included in the DEV_SOURCE_PATH) does not install the pulp_file clients resulting into an error if you wanna run tests.

It works if you explicitly tell it to install the pulp_file client like so: oci-env generate-client -i pulp_file

It would be great if the default command can somehow check if pulp_file clients needs to be included on its own.

generate-client doesn't work with docker & selinux

Problem is that pulp-openapi-generator adds a label to its directory when the bindings are generated and this prevents the oci-env container from being able to read the directory and install the bindings.

Need this change to the pulp-openapi-generator pulp/pulp-openapi-generator#79 and need the generate-client script to account for docker as well when setting the label.

Exit the container startup if there are errors installing a plugin.

Right now if a plugin can't be installed, the environment will happily start up without installing it. This is confusing and a bad user experience.

S6 can be configured to exit if an init script fails by setting this to 2: https://github.com/pulp/oci_env/blob/main/base/compose.yaml#L38, however the pulp-api init script is designed to fail and exit if it's already been run (https://github.com/pulp/pulp-oci-images/blob/latest/assets/init/pulpcore-api#L10), which blocks the container from starting up.

Once this is fixed in the base images, the containers can be configured to exit on errors.

Improve remote debugging tooling

Problem

Couldn't run remote debugging (aka, set breakpoints inside the running server code) with the instructions provided by the README.

Context

I followed the steps in the README for debuging functional tests but it didn't work.

After some research + trial-and-error, I was able to make it work with:

# Setting the breakpoint in the code
#   I've relied on the already exposed 12345, which I don't know if have another purpose
import epdb; epdb.serve(port=12345)

# Attaching pdb from another terminal
#   from here: https://github.com/ionelmc/python-remote-pdb#usage
sudo dnf install rlwrap socat
rlwrap socat - tcp:127.0.0.1:12345

But still, epdb doesn't have a very good documentation and is unmaintained in years.

Proposal

I'd like to have better builtin support for remote debugging out-of-the-box.

The idea I have for this is using remote-pdb, which has slighly better documentation and tooling. For example, it can be configured via envvars to integrate with regular breakpoints(). oci-env could set those envvars by default and we don't have to worry about porting and can use normal breakpoints() syntax.

Alternatives

  1. Continue using epdb and update README instructions
  2. Look another tool with convenient remote-debug capability and update README

add a profile for telemetry dev env

The telemetry profile needs to spin up an additional container that serves analytics.pulpproject.org website. It should also modify the /etc/hosts file in the container running pulp to point dev.analytics.pulpproject.org to the container running that site.

Make docs building easier

Right now you can build docs with:

oci-env shell
pip install -r /src/pulpcore/doc_requirements.txt
cd /src/pulpcore/docs
make diagrams html

It would be great if:

  • There was an easy command to install the doc_requirements
  • There was an easy way to call the make file command (passing through the args to make would be ideal)

Container name generated by docker-compose not matching the ones defined for oci-env cli commands

After building the images and starting the services my system creates a container named oci_env-pulp-1. However this apparently does not match the convention used for the oci-env cli commands. I get the following error trying to run them:

$ oci-env test -p pulp_deb functional
Error: No such container: oci_env_pulp_1

For reference I'm using the docker-compose version 2.9.0 with the following .compose.env:

# : separated list of profiles to use. Ex: galaxy_ng/ui:ha
COMPOSE_PROFILE=

# : separate list of python dependencies to include from source
DEV_SOURCE_PATH=pulpcore:pulp_rpm:pulp_deb

# Program to use for compose. This defaults to podman. Uncomment this to use docker-compose.
COMPOSE_BINARY=docker

# Set any custom pulp settings by adding environment variables with the PULP_ prefix
# PULP_MY_SETTING....

# Django admin user credentials that gets created during startup
# DJANGO_SUPERUSER_USERNAME=admin
# DJANGO_SUPERUSER_PASSWORD=password

# Port, hostname and protocol used to configure pulp content origin
# API_HOST=localhost
# API_PORT=5001
# API_PROTOCOL=http

Running a docker ps:

$ docker ps
CONTAINER ID   IMAGE                         COMMAND   CREATED          STATUS          PORTS                                     NAMES
d12999f43c5f   localhost/oci_env/pulp:base   "/init"   30 minutes ago   Up 30 minutes   80/tcp, 0.0.0.0:5001->5001/tcp, :::5001->5001/tcp   oci_env-pulp-1

Provide a method to rollback the base image

We've had a few instances where changes to the base image (ghcr.io/pulp/pulp-ci-centos:latest) have caused the developer environment to break (in some cases for up to a week with the user permission changes). Developers should have the option to rollback to a previous base image when this happens so that they can continue working while a fix is created.

Need to tweak requirements file to get pulp-cli newer versions

pulp-cli is pinned to version ==0.20.2 in dev_requirements.txt, which makes it a little inconvenient to pull updates/bug-fixes into the development environment.

Edit: I don't know why I did not consider using pulp-cli from host (outside oci-env shell), which works fine. So it's not really a significant inconvenient. Still, it seems odd

I've noticed it was done as part of a bugfix (#130), but it's not clear to me if pinning to that version is really part of the fix.
If it's not, we should unpin it again.

Unable to start container due to directory permissions

Alongside my pulp development repos I have a directory of various RPM repos - despite not being referenced in the configuration at all, I get the following error when I try to start the environment:

Error: unable to start container aedae1b7800720aeb9bc1053adbb782a422875db8ea2a767078d395c30bc6fb0: lsetxattr /home/dalley/devel/repos: operation not permitted

I'm guessing it wants to recursively make everything under ~/devel available inside the container but doesn't like the permissions on that one directory?

It appears a while back I made it owned by the nginx user to make it easy to symlink to /usr/share/nginx/html/ or something.

-rw-r--r--.  1 dalley dalley    2419 Apr 21 21:48 repo_list.txt
drwxrwxrwx. 15 nginx  nginx   151552 Aug 24 23:53 repos
-rw-r--r--.  1 dalley dalley    4885 Apr 21 14:42 repo_sizes.txt

You can see it has permissions 777 so any user can read it.

After using chown and chgrp on this directory with my own user it all works so this isn't a critical issue, just nice to address if possible.

A mismatch between repositories' names and installed packages

An issue occurs when a user runs tests for pulp-certguard within the environment. The environment should be capable of handling discrepancies between pulp-cerguard and pulp_certguard.

We decided not to rename the root name of the repository because we could not evaluate the impact of this change on sources that depend on pulp-certguard.

build fails with docker buildkit enabled

Sorry, I don't have good reproducer steps for this and I unfortunately don't have time to debug further, but when following the guide to set up galaxy-ng (https://ansible.readthedocs.io/projects/galaxy-ng/en/latest/community/devstack/#oci-env) I found that I was unable to build until I disabled buildkit with export DOCKER_BUILDKIT=0

Possibly relevant:
docker/compose#8538
docker/compose#8449

I believe the issue is that buildkit tries to build in parallel but can't do that with images that depend on each other... but I haven't dug too much beyond that.

In any case exporting that env var let me work around the issue - it might be something worth considering doing in oci-env itself.

Convert oci_env docs to new stack

The general workflow for this task can be found here.

For this repository, the migration process should involve breaking the readme down into the appropriate content categories.

Unable to run tests

pulpcore-manager test pulp_rpm.tests.unit.test_models returns

Creating test database for alias 'default'...
Got an error creating the test database: permission denied to create database

unfortunately no trace back or line in the logs
maybe related to #17

Use a single pip install command on startup

oci_env calls pip in multiple places multiple times. Pip is not meant to be used that way wand will happily create conflicts with already installed packages or update otherwise pinned dependencies.

Consolidating all calls to pip install into a single one can be considered a hard blocker for using it in any kind of CI.

oci-env can't mount files between host and container

Description

When using the volumes directive on the compose.yaml file of a profile you can't use it to mount a host file into the container.

How to reproduce

Create a new profile and in the compose.yaml file, create a new services entry, add a new volumes directive to it and try to mount or bind a file from the host to the container, like this:

services:
    some_service:
        volumes:
            - ./a_local_file.yml:/etc/a_container_file.yml

What is expected

You're expected to find that same file inside of the container, although you gonna find it mounted as an empty directory.

Additional info

You can find under the ./compiled/oci_env directory the directory with the same name of the file which was intended to be mounted into the container.

Set the nginx timeout value

When users want to change the gunicorn timeout, they can set the PULP_GUNICORN_TIMEOUT to a value of its choice.
But this only works when you set it to a value less than 60 seconds. After that, the application doesn't increase its timeout.

The reason is that we need to set the same value to nginx itself, since it's a proxy between gunicorn and the client.

Services fail to start due to "connection in use: ('127.0.0.1', 24817)"

I'm on Fedora-36, and oci-env compose up is hitting the following, forever, trying to bring up services

40 static files symlinked to '/var/lib/pulp/assets'.
[2022-09-12 17:42:33 +0000] [245] [INFO] Starting gunicorn 20.1.0
[2022-09-12 17:42:33 +0000] [245] [ERROR] Connection in use: ('127.0.0.1', 24817)
[2022-09-12 17:42:33 +0000] [245] [ERROR] Retrying in 1 second.
[2022-09-12 17:42:34 +0000] [245] [ERROR] Connection in use: ('127.0.0.1', 24817)
[2022-09-12 17:42:34 +0000] [245] [ERROR] Retrying in 1 second.
[2022-09-12 17:42:35 +0000] [245] [ERROR] Connection in use: ('127.0.0.1', 24817)
[2022-09-12 17:42:35 +0000] [245] [ERROR] Retrying in 1 second.
[2022-09-12 17:42:36 +0000] [245] [ERROR] Connection in use: ('127.0.0.1', 24817)
[2022-09-12 17:42:36 +0000] [245] [ERROR] Retrying in 1 second.
[2022-09-12 17:42:37 +0000] [245] [ERROR] Connection in use: ('127.0.0.1', 24817)
[2022-09-12 17:42:37 +0000] [245] [ERROR] Retrying in 1 second.
[2022-09-12 17:42:38 +0000] [245] [ERROR] Can't connect to ('127.0.0.1', 24817)
Already migrated!
Deleting 'import_export/action_formats.js'
Deleting 'import_export/import.css'
Deleting 'rest_framework/css/bootstrap-theme.min.css'
Deleting 'rest_framework/css/bootstrap-tweaks.css'
Deleting 'rest_framework/css/bootstrap.min.css'

Anyone else seeing this?

Non-fatal error during compose-up calling postgres-prepare

I see this error (seemingly from dynaconf) during compose up. It doesn't stop the machine from launching so not sure what is going on. Using pulpcore & pulp_file on main.

pulp_1   | Calling /etc/init/postgres-prepare
pulp_1   | 2022-09-28 20:17:15.957 UTC [596] LOG:  starting PostgreSQL 12.11 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-13), 64-bit
pulp_1   | 2022-09-28 20:17:15.958 UTC [596] LOG:  listening on IPv4 address "127.0.0.1", port 5432
pulp_1   | 2022-09-28 20:17:15.958 UTC [596] LOG:  could not bind IPv6 address "::1": Cannot assign requested address
pulp_1   | 2022-09-28 20:17:15.958 UTC [596] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
pulp_1   | 2022-09-28 20:17:15.959 UTC [596] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
pulp_1   | 2022-09-28 20:17:15.961 UTC [596] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
pulp_1   | 2022-09-28 20:17:15.968 UTC [596] LOG:  redirecting log output to logging collector process
pulp_1   | 2022-09-28 20:17:15.968 UTC [596] HINT:  Future log output will appear in directory "log".
pulp_1   | Traceback (most recent call last):
pulp_1   |   File "/usr/local/bin/pulpcore-manager", line 8, in <module>
pulp_1   |     sys.exit(manage())
pulp_1   |   File "/src/pulpcore/pulpcore/app/manage.py", line 11, in manage
pulp_1   |     execute_from_command_line(sys.argv)
pulp_1   |   File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
pulp_1   |     utility.execute()
pulp_1   |   File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 363, in execute
pulp_1   |     settings.INSTALLED_APPS
pulp_1   |   File "/usr/local/lib/python3.8/site-packages/django/conf/__init__.py", line 82, in __getattr__
pulp_1   |     self._setup(name)
pulp_1   |   File "/usr/local/lib/python3.8/site-packages/django/conf/__init__.py", line 69, in _setup
pulp_1   |     self._wrapped = Settings(settings_module)
pulp_1   |   File "/usr/local/lib/python3.8/site-packages/django/conf/__init__.py", line 170, in __init__
pulp_1   |     mod = importlib.import_module(self.SETTINGS_MODULE)
pulp_1   |   File "/usr/lib64/python3.8/importlib/__init__.py", line 127, in import_module
pulp_1   |     return _bootstrap._gcd_import(name[level:], package, level)
pulp_1   |   File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
pulp_1   |   File "<frozen importlib._bootstrap>", line 991, in _find_and_load
pulp_1   |   File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
pulp_1   |   File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
pulp_1   |   File "<frozen importlib._bootstrap_external>", line 843, in exec_module
pulp_1   |   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
pulp_1   |   File "/src/pulpcore/pulpcore/app/settings.py", line 299, in <module>
pulp_1   |     from dynaconf import DjangoDynaconf, Validator  # noqa
pulp_1   |   File "/usr/local/lib/python3.8/site-packages/dynaconf/__init__.py", line 3, in <module>
pulp_1   |     from dynaconf.base import LazySettings  # noqa
pulp_1   |   File "/usr/local/lib/python3.8/site-packages/dynaconf/base.py", line 17, in <module>
pulp_1   |     from dynaconf.loaders import env_loader
pulp_1   |   File "/usr/local/lib/python3.8/site-packages/dynaconf/loaders/env_loader.py", line 8, in <module>
pulp_1   |     from dynaconf.vendor.dotenv import cli as dotenv_cli
pulp_1   |   File "/usr/local/lib/python3.8/site-packages/dynaconf/vendor/dotenv/cli.py", line 16, in <module>
pulp_1   |     @click.option('-f','--file',default=os.path.join(os.getcwd(),'.env'),type=click.Path(exists=_A),help='Location of the .env file, defaults to .env file in current working directory.')
pulp_1   | FileNotFoundError: [Errno 2] No such file or directory
pulp_1   | Operations to perform:
pulp_1   |   Apply all migrations: auth, contenttypes, core, file, python, sessions
pulp_1   | Running migrations:
pulp_1   |   No migrations to apply.

As a plugin writer, I want to use the pulp cli

Install and configure the pulp CLI in the oci env container so that it's available from oci-env shell. Additionally it might be nice to provide an oci-env pulp <args> cmd (similar to the pulpcore-manager cmd) that allows users to run pulp cli commands from their host machine.

The single most important file to interact with is hidden.

As a new user of this environment, it is very confusing to see a reference to a "compose.sth" file in the README and nothing to show up in ls. It took me a while to realize that the filename started with a dot (marking a hidden file in unix fs).

Run Podman in such a way that it has access to system coredumps

I'm having an issue with createrepo_c 1.0 crashing with segmentation fault during tests. Unfortunately I can't really utilize the coredumps to debug.

The coredump appears when I run coredumpctl on my host machine, but my host machine doesn't have the debug symbols to make the dump useful.

The container on the other hand doesn't have the ability to access the coredump on the host.

There are guides like this for making it work

https://dev.to/mizutani/how-to-get-core-file-of-segmentation-fault-process-in-docker-22ii
https://serverfault.com/questions/1143055/how-to-check-core-dump-inside-a-podman-container

The overall gist is that the container needs loosened security restrictions. Possibly this is something that we wouldn't want to enable all the time, but make it easy to enable when needed?

Pulp user password - required by tests

When I run oci-env test -i -p pulp_rpm functional test required pulp password. Is it even set (Tried few without luck)?

===================================================== test session starts ======================================================
platform linux -- Python 3.8.13, pytest-7.2.0, pluggy-1.0.0
rootdir: /var/lib/pulp
plugins: pulpcore-3.22.0.dev0, xdist-3.0.2, custom-exit-code-0.3.0, pulp-smash-1!0.13.0
collected 294 items                                                                                                            

../../var/lib/pulp/api/test_acs.py ..                                                                                    [  0%]
../../var/lib/pulp/api/test_advisory_conflict.py .                                                                       [  1%]
../../var/lib/pulp/api/test_advisory_upload.py ....                                                                      [  2%]
../../var/lib/pulp/api/test_auto_publish.py ..                                                                           [  3%]
../../var/lib/pulp/api/test_character_encoding.py ..                                                                     [  3%]
../../var/lib/pulp/api/test_comps.py ......                                                                              [  5%]
../../var/lib/pulp/api/test_consume_content.py 
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for pulp:

Fatal error during compose build

Using freshly pulled code

[dalley@thinkpad oci_env]$ oci-env compose build
['podman', '--version', '']
using podman version: 4.2.1
podman build -t localhost/oci_env/pulp:base -f /home/dalley/devel/oci_env/base/Dockerfile /home/dalley/devel/oci_env/base/
STEP 1/11: FROM ghcr.io/pulp/pulp-ci-centos:latest
STEP 2/11: ENV S6_KEEP_ENV=1
--> Using cache f88ba142767b421a71ec163871ac9990e964470c0d75cad411cb5c3f6c871207
--> f88ba142767
STEP 3/11: COPY dev_requirements.txt /dev_requirements.txt
--> Using cache af2c4a414af861793635c379a80bbfc19d0a66f6658be2891c9483a71eb5e005
--> af2c4a414af
STEP 4/11: RUN pip3 install -r dev_requirements.txt
--> Using cache b2b7897542fa116ecbfd3d936fde8c7b29d4a64c3b1470d768eb197eda26e5a2
--> b2b7897542f
STEP 5/11: COPY settings.py /etc/pulp/settings.py
--> Using cache fa33627095ef3ce546746c6519d7f677ba8efa6959ad77c858548e71d2c211d2
--> fa33627095e
STEP 6/11: COPY s6-rc.d/oci-env-prepare/ /etc/s6-overlay/s6-rc.d/oci-env-prepare/
--> Using cache 0e9162c7c4b3fcc062b5f2750c436b74d03af77db434b15a18ce524c00a40ef3
--> 0e9162c7c4b
STEP 7/11: COPY s6-rc.d/oci-env-profiles /etc/s6-overlay/s6-rc.d/oci-env-profiles/
--> Using cache 680a309870fb81681d721803e8a14907f27bfb9df19e0c3cbdf2721c0bf5d9be
--> 680a309870f
STEP 8/11: RUN cd /etc/s6-overlay/s6-rc.d/user/contents.d && touch oci-env-prepare oci-env-profiles
/bin/sh: line 0: cd: /etc/s6-overlay/s6-rc.d/user/contents.d: No such file or directory
Error: error building at STEP "RUN cd /etc/s6-overlay/s6-rc.d/user/contents.d && touch oci-env-prepare oci-env-profiles": error while running runtime: exit status 1
exit code: 1

root power being required by some tests

Some tests require root permissions for specific file operations.

The easiest(not the right) way to solve this is adding the pulp user to the sudoers file with NOPASSWD or adding the pulp user to the sudo group.

Using #68 as an epic.

`oci-env pulpcore-manager reset_db` fails with not enough permissions

[dkliban@localhost oci_env]$ oci-env pulpcore-manager reset_db

You have requested a database reset.
This will IRREVERSIBLY DESTROY
ALL data in the database "pulp".
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: yes
pulp [None]: root:INFO: Executing... "DROP DATABASE "pulp";"
pulp [None]: root:ERROR: Error: must be owner of database pulp
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/django_extensions/management/commands/reset_db.py", line 175, in handle
    cursor.execute(drop_query)
psycopg2.errors.InsufficientPrivilege: must be owner of database pulp

pulp [None]: root:INFO: Executing... "CREATE DATABASE "pulp" WITH OWNER = "pulp"  ENCODING = 'UTF8';"
Traceback (most recent call last):
  File "/usr/local/bin/pulpcore-manager", line 8, in <module>
    sys.exit(manage())
  File "/src/pulpcore/pulpcore/app/manage.py", line 11, in manage
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.8/site-packages/django_extensions/management/utils.py", line 62, in inner
    ret = func(self, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/django_extensions/management/commands/reset_db.py", line 190, in handle
    cursor.execute(create_query)
psycopg2.errors.InsufficientPrivilege: permission denied to create database

Possible workaround is to run oci-env shell and run pulpcore-manager reset_db from there.

oci-env compose build fails COMPOSE_BINARY=docker

Versions

  • Ubuntu 23.04
  • Python 3.11.4
  • Docker version 24.0.6, build ed223bc

Note

Works with podman

Traceback

oci-env compose build 
2023-11-08 15:27:57,399 - INFO - utils.py:37 - USING /home/workspace/oci_env FOR OCI_ENV_PATH BASED ON GIT CMD OUTPUT
2023-11-08 15:27:57,400 - INFO - utils.py:37 - USING /home/workspace/oci_env FOR OCI_ENV_PATH BASED ON GIT CMD OUTPUT
2023-11-08 15:27:57,401 - INFO - utils.py:37 - USING /home/workspace/oci_env FOR OCI_ENV_PATH BASED ON GIT CMD OUTPUT
2023-11-08 15:27:57,402 - INFO - commands.py:11 - COMPOSE Namespace(is_verbose=False, env_file='', command=['build'], func=<function compose at 0x7f655fca6e80>)
pulp uses an image, skipping
Building _base
[+] Building 22.2s (7/16)                                                                                                                                                      docker:default
 => [internal] load build definition from Dockerfile                                                                                                                                     0.0s
 => => transferring dockerfile: 961B                                                                                                                                                     0.0s
 => [internal] load .dockerignore                                                                                                                                                        0.0s
 => => transferring context: 2B                                                                                                                                                          0.0s
 => [internal] load metadata for ghcr.io/pulp/pulp-ci-centos:latest                                                                                                                      0.0s
 => [internal] load build context                                                                                                                                                        0.0s
 => => transferring context: 811B                                                                                                                                                        0.0s
 => [ 1/12] FROM ghcr.io/pulp/pulp-ci-centos:latest                                                                                                                                      0.0s
 => CACHED [ 2/12] COPY dev_requirements.txt /dev_requirements.txt                                                                                                                       0.0s
 => ERROR [ 3/12] RUN dnf install -y which                                                                                                                                              22.1s
------                                                                                                                                                                                        
 > [ 3/12] RUN dnf install -y which:
22.01 CentOS Stream 8 - AppStream                     1.6 MB/s |  34 MB     00:20    
22.03 Error: Cannot create directory "/var/cache/dnf/appstream-97a634f7b5a0dc54/repodata": Invalid argument
------
Dockerfile:10
--------------------
   8 |     
   9 |     COPY dev_requirements.txt /dev_requirements.txt
  10 | >>> RUN dnf install -y which
  11 |     
  12 |     COPY switch_python /usr/bin/switch_python
--------------------
ERROR: failed to solve: process "/bin/sh -c dnf install -y which" did not complete successfully: exit code: 1
ERROR: Service '_base' failed to build : Build failed

oci-env db reset leaves Pulp in a broken state

At commit 2b0de81 if I run:

  1. oci-env compose up
  2. Check pulp is happy at the URL http://localhost:5001/pulp/api/v3/ and it is
  3. Try to reset the db with oci-env db reset
  4. Check again Pulp is happy at http://localhost:5001/pulp/api/v3/ and it isn't it gives a connection reset

What I expected from this command was to:

  1. Stop the Pulp services
  2. Delete the db
  3. Recreate the db
  4. Apply migrations
  5. Start the services

I'm not sure (a) if that's what others expected or (b) how much of that is being done versus not done.

Failed to build on ppc64 : oci-env compose up

Trying to build on ppc64le arch facing below issue while running the command

[root@ibm-p9z-26-lp14 oci_env]# oci-env compose up
Creating network "oci_env_default" with the default driver
Creating volume "oci_env_pulp" with default driver
Creating volume "oci_env_pg_data" with default driver
Creating volume "oci_env_redis_data" with default driver
Building _base
[+] Building 1.7s (7/14)
 => [internal] load build definition from Dockerfile                                                                                                    0.1s
 => => transferring dockerfile: 916B                                                                                                                    0.0s
 => [internal] load .dockerignore                                                                                                                       0.2s
 => => transferring context: 2B                                                                                                                         0.0s
 => [internal] load metadata for ghcr.io/pulp/pulp-ci-centos:3.21                                                                                       0.2s
 => [internal] load build context                                                                                                                       0.0s
 => => transferring context: 1.74kB                                                                                                                     0.0s
 => [ 1/10] FROM ghcr.io/pulp/pulp-ci-centos:3.21@sha256:d830efc3c0c200c597956ba8edaad1f0c37c19b20888c42440592bb05829fa21                               0.0s
 => CACHED [ 2/10] COPY dev_requirements.txt /dev_requirements.txt                                                                                      0.0s
 => ERROR [ 3/10] RUN dnf install -y which                                                                                                              1.1s
------
 > [ 3/10] RUN dnf install -y which:
#0 0.709 exec /bin/sh: exec format error
------
Dockerfile:10
--------------------
   8 |
   9 |     COPY dev_requirements.txt /dev_requirements.txt
  10 | >>> RUN dnf install -y which
  11 |     RUN pip3 install -r dev_requirements.txt
  12 |
--------------------
ERROR: failed to solve: process "/bin/sh -c dnf install -y which" did not complete successfully: exit code: 1
ERROR: Service '_base' failed to build : Build failed
[root@ibm-p9z-26-lp14 oci_env]#

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.