Skip to main content

Push and receive OSTree commits

Project description

ostree-push

Background

ostree-push uses ssh to push commits from a local OSTree repo to a remote OSTree repo. This is to fill a gap where currently you can only pull commits in core ostree. To publish commits to a remote repository, you either have to pull from the local repo to the remote repo or use an out of band mechanism like rsync.

Both approaches have significant limitations. To pull over the network, only http is supported. So, in addition to having to login on the remote machine and run ostree pull, the local repository needs to be served over http. This means your build machine needs to be an http server with appropriate configuration in addition to simply making commits. This pushes the builds to be done on the public repository server, which prevents reasonable separation of duties and makes multiarch repositories impossible.

Using rsync for publishing has some major benefits since only updated objects are published. However, it has no concept of the OSTree object store or refs structures. There are a few problems deriving from this issue. First, objects are published in sort order, but this means that objects can be published before their children. In the most extreme case, a commit object could be published before it's complete. The remote repo would assume this commit object was valid even though some children might be missing. Second, the refs might get updated before the commit objects are in place. If a client pulls while rsync is publishing, it may attempt to pull an incomplete or entirely missing commit. Finally, rsync will push the objects directly into the store rather than using a staging directory like pull or commit do. If rsync is interrupted, it could leave partial objects in the store.

ostree-push tries to offer functionality like git where commits can be pushed over ssh to avoid these issues.

Operation

When ostree-push is started, it first starts a local HTTP server providing the contents of the local ostree repo. It then connects to the remote host with ssh and tunnels the HTTP server port through the SSH connection. Finally, it runs ostree-receive on the remote host with the URL of the tunneled HTTP server. ostree-receive then creates a temporary remote using this URL and pulls the desired refs from it.

In essence, ostree-push and ostree-receive coordinate to pull from the local repo to a remote repo while avoiding the limitations described above. Namely, no HTTP server needs to be running and no port needs to be exposed on the local host. Both resources are created temporarily and only exposed to the remote host through the secure SSH connection.

Installation

Use pip to install the otpush package and the ostree-push and ostree-receive scripts. From a git checkout, run:

pip install .

If ostree-receive is not in a default PATH location, it may not be located when run in the environment spawned by the SSH server. As a workaround, make a symbolic link in a standard location:

sudo ln -s /path/to/ostree-receive /usr/bin/ostree-receive

In order to restrict SSH usage to only running ostree-receive, the ostree-receive-shell script can be used as a login shell. This way someone with SSH access to the remote machine cannot run arbitrary commands as the user owning the repositories. To use it, set the login shell of the repo owner to ostree-receive-shell:

sudo chsh -s /path/to/ostree-receive-shell <user>

ostree-receive-shell will also append the directory it's installed in to PATH to allow ostree-receive to be found in non-standard locations. In that scenario, the symbolic link to ostree-receive described above is not needed.

Both ostree-push and ostree-receive require the OSTree GObject Introspection bindings. Typically these would be installed from the host distro. On Debian systems the package is gir1.2-ostree-1.0 while on RedHat systems they are in the ostree-libs package.

ostree-push relies on the connection sharing and port forwarding features of OpenSSH and is unlikely to work with another SSH client. Similarly, ostree-receive has only be tested with the OpenSSH server, but it might work correctly with other SSH servers.

Configuration

ostree-receive can be configured from YAML formatted files. It will load ~/.config/ostree/ostree-receive.conf and /etc/ostree/ostree-receive.conf or a file specified in the OSTREE_RECEIVE_CONF environment variable. See the example ostree-receive.conf file for available options.

Testing

A test suite is provided using pytest. Most of the time simply running pytest from a git checkout will run it correctly. tox can also be used to automate running the test suite in a prepared Python environment.

In addition to the ostree-push dependencies, many of the tests depend on using OpenSSH sshd locally. On both Debian and RedHat systems this is available in the openssh-server package.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ostree-push-1.2.0.tar.gz (61.3 kB view details)

Uploaded Source

Built Distribution

ostree_push-1.2.0-py3-none-any.whl (31.9 kB view details)

Uploaded Python 3

File details

Details for the file ostree-push-1.2.0.tar.gz.

File metadata

  • Download URL: ostree-push-1.2.0.tar.gz
  • Upload date:
  • Size: 61.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for ostree-push-1.2.0.tar.gz
Algorithm Hash digest
SHA256 bb113587f9190b50e8af89523cf1611d650194d390ee50ab10a136db8af1117a
MD5 46056e06564ec989fd2c40ca4cd4a3bc
BLAKE2b-256 b516afdb4a31c82ac1917d57f2e513b385829cc614360f73dcf8f32e4b43958e

See more details on using hashes here.

File details

Details for the file ostree_push-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: ostree_push-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 31.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for ostree_push-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 377a611f3b142240f81d7f2dc4a50159e6113955a8e79892e3a5eade039056f2
MD5 788401100a13470d9660037bac54cb42
BLAKE2b-256 672ba52ddc282122305ed681ac07a694d5ab1b93787b9f50436e7e8a24837842

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page