Skip to content

Commit

Permalink
[DPE-3075] Fix rock entry point and documentation for MongoDB 6 (#28)
Browse files Browse the repository at this point in the history
* Fix rockcraft entry point and documentation

* Update charmcraft version

* Another attempt to fix the version

* Another attempt to fix the version

* Update workflow files

* Update build files

* Add debug session for CI

* Fix condition to initialize debug session

* Add keep-models tox flag for debug

* update workflows to match Dmitrys working local enc

* update build to match with 5-22.04 build

* Update checkout action

* Free disk space before running integration tests

* Clean space as part of test start

* Remove unnecessary operation from tests start

* Temporary disable tests on CI until the fix is not merged to

charm repo

* Removed tmate debug session

---------

Co-authored-by: Ubuntu <[email protected]>
Co-authored-by: Mia Altieri <[email protected]>
  • Loading branch information
3 people committed Dec 5, 2023
1 parent 7daca81 commit 98347d8
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 32 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,16 @@ jobs:
timeout-minutes: 15
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup LXD
uses: canonical/setup-lxd@main
- name: Install dependencies
run: |
sudo snap install yq
sudo snap install rockcraft --classic --edge
sudo snap install rockcraft --classic --channel=latest/stable --revision 1206
sudo snap install charmcraft --classic --revision 1349
- name: Build ROCK
run: |
app_version=$(yq '.version' rockcraft.yaml)
version=$(yq '(.version|split("-"))[0]' rockcraft.yaml)
base=$(yq '(.base|split(":"))[1]' rockcraft.yaml)
tag=${version}-${base}_edge
sed -i "s/${app_version}/${tag}/g" rockcraft.yaml
rockcraft pack
- name: Upload locally built ROCK artifact
uses: actions/upload-artifact@v3
Expand Down
29 changes: 23 additions & 6 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ jobs:
needs: build
strategy:
matrix:
env: [integration, ha-integration, tls-integration]
env: []
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: 6/edge
uses: actions/checkout@v4
- name: Setup operator environment
uses: charmed-kubernetes/actions-operator@main
with:
Expand All @@ -34,14 +32,33 @@ jobs:
juju-channel: 3.1/stable
# This is needed until
# https://bugs.launchpad.net/juju/+bug/1977582 is fixed
bootstrap-options: "--agent-version 3.1.5"
bootstrap-options: "--agent-version 3.1.6"
- name: Pin charmcraft version
run: |
sudo snap refresh --channel=2.2 charmcraft
sudo snap refresh charmcraft --classic --revision 1349
sudo snap refresh charmcraft --hold=forever
- name: Install rockcraft
run: |
sudo snap install rockcraft --classic --revision 1206
sudo snap refresh rockcraft --hold=forever
- uses: actions/download-artifact@v3
with:
name: mongodb-rock
- name: Install tox
run: python3 -m pip install tox

- name: Free disk space
run: |
echo "Free disk space before cleanup"
df -T
# free space in the runner
rockcraft clean
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/share/boost
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
echo "Free disk space after cleanup"
df -T
- name: Integration Tests
run: sg snap_microk8s -c "tox -e ${{ matrix.env }}"
4 changes: 2 additions & 2 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ jobs:
- name: Import and push to GHCR
run: |
version=$(yq '(.version|split("-"))[0]' rockcraft.yaml)
base=$(yq '(.base|split(":"))[1]' rockcraft.yaml)
base=$(yq '(.base|split("@"))[1]' rockcraft.yaml)
tag=${version}-${base}_edge
sudo skopeo --insecure-policy copy \
oci-archive:charmed-mongodb_${tag}_amd64.rock \
oci-archive:charmed-mongodb_${version}_amd64.rock \
docker-daemon:ghcr.io/canonical/charmed-mongodb:${tag}
docker push ghcr.io/canonical/charmed-mongodb:${tag}
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Charmed MongoDB ROCK is an Open Container Initiative (OCI) image derived from the [Charmed MongoDB Snap](https://snapcraft.io/charmed-mongodb). The tool used to create this ROCK is called [Rockcraft](https://canonical-rockcraft.readthedocs-hosted.com/en/latest/index.html).

The [Charmed MongoDB ROCK](https://github.com/canonical/charmed-mongodb-rock/pkgs/container/charmed-mongodb) is an enhanced, source-available, fully-compatible, drop-in replacement of the OCI image of MongoDB 5.0.13 Community version. In addition, the Charmed MongoDB ROCK package offers more features than the MongoDB Community version, such as backup and restore, monitoring and security features.
The [Charmed MongoDB ROCK](https://github.com/canonical/charmed-mongodb-rock/pkgs/container/charmed-mongodb) is an enhanced, source-available, fully-compatible, drop-in replacement of the OCI image of MongoDB 6.0.6 Community version. In addition, the Charmed MongoDB ROCK package offers more features than the MongoDB Community version, such as backup and restore, monitoring and security features.

One benefit of using the Charmed MongoDB ROCK is that it bundles MongoDB with other tools in its ecosystem to be used in the Charmed MongoDB Operator. One of the operators that uses this ROCK is the [Charmed MongoDB (Kubernetes Operator)](https://charmhub.io/mongodb-k8s).

Expand All @@ -30,11 +30,11 @@ sudo snap install docker
```
Then to use the Charmed MongoDB ROCK run the following command
```
sudo docker run --rm -it ghcr.io/canonical/charmed-mongodb:5.0.14-22.04_edge
sudo docker run --rm -it ghcr.io/canonical/charmed-mongodb:6.0.6-22.04_edge
```
By running this command you have already started the mongod service with Percona Server for MongoDB. Leave this command running and create another terminal.

*Note if you would like to start `mongod` with custom options you can append your desired options to the container run command i.e.*: `sudo docker run --rm -it ghcr.io/canonical/charmed-mongodb:5.0.14-22.04_edge --bind-ip-all --another-option` *you can read more about [mongod optons here](https://www.mongodb.com/docs/manual/reference/program/mongod/)*
*Note if you would like to start `mongod` with custom options you can append your desired options to the container run command i.e.*: `sudo docker run --rm -it ghcr.io/canonical/charmed-mongodb:6.0.6-22.04_edge --bind-ip-all --another-option` *you can read more about [mongod optons here](https://www.mongodb.com/docs/manual/reference/program/mongod/)*

To access your now running MongoDB instance enter the command:
```
Expand All @@ -43,11 +43,11 @@ sudo docker container ls
This should output something like this:
```
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0dddcc9c71d6 ghcr.io/canonical/charmed-mongodb:5.0.14-22.04_edge "/usr/bin/setpriv --…" 44 seconds ago Up 44 seconds romantic_newton
bf08481d18a3 ghcr.io/canonical/charmed-mongodb:6.0.6-22.04_edge "/bin/pebble enter -…" About a minute ago Up About a minute quizzical_sinoussi
```
The name of the container is listed under `NAME` - use this name to connect to your now running database
```
sudo docker exec --interactive <container-name> mongo
sudo docker exec --interactive <container-name> mongosh
```
Now enter `show dbs` this should show you all of your available databases and output something like:
```
Expand Down Expand Up @@ -119,7 +119,3 @@ The Charmed MongoDB Operator is free software, distributed under the [Apache Sof
## Trademark Notice

"MongoDB" is a trademark or registered trademark of MongoDB, Inc. Other trademarks are property of their respective owners. Charmed MongoDB is not sponsored, endorsed, or affiliated with MongoDB, Inc.




2 changes: 1 addition & 1 deletion retag_rock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
NAME=$(yq '.name' rockcraft.yaml)
APP_VERSION=$(yq '.version' rockcraft.yaml)
VERSION=$(yq '(.version|split("-"))[0]' rockcraft.yaml)
BASE=$(yq '(.base|split(":"))[1]' rockcraft.yaml)
BASE=$(yq '(.base|split("@"))[1]' rockcraft.yaml)
TAG=${VERSION}-${BASE}_edge
REGISTRY_NAMESPACE=ghcr.io/canonical

Expand Down
12 changes: 10 additions & 2 deletions rockcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
name: charmed-mongodb # the name of your ROCK
base: ubuntu:22.04 # the base environment for this ROCK
version: "6.0.6-1" # just for humans. Semantic versioning is recommended
base: ubuntu@22.04 # the base environment for this ROCK
version: "6.0.6-2" # just for humans. Semantic versioning is recommended
summary: MongoDB in a rock. # 79 char long summary
description: |
MongoDB is a source-available cross-platform
Expand Down Expand Up @@ -71,3 +71,11 @@ parts:
source: licenses
organize:
LICENSE-rock: licenses/LICENSE-rock

entry:
plugin: dump
source: scripts
organize:
start.sh: bin/start.sh
stage:
- bin/start.sh
13 changes: 8 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ setenv =
name=charmed-mongodb
registry_namespace=ghcr.io/canonical
repo=https://github.com/canonical/mongodb-k8s-operator.git
branch=6/edge

[testenv:lint]
description = run linters
Expand All @@ -28,8 +29,9 @@ commands =
then rockcraft pack; ./retag_rock.sh; fi'
bash -ec 'microk8s ctr image import {env:name}_*-$(yq .base rockcraft.yaml | \
cut -c 8-)_edge_amd64.rock --base-name {env:registry_namespace}/{env:name}'
bash -ec 'if ! [ -d operator ]; then git clone {env:repo} operator; fi' {posargs}
tox --workdir operator -c operator -e integration
bash -ec 'if ! [ -d operator ]; then git clone --single-branch --branch {env:branch} {env:repo} operator; fi' {posargs}
tox --workdir operator -c operator -e integration -- --keep-models


[testenv:ha-integration]
description = run operator integration tests
Expand All @@ -42,8 +44,9 @@ commands =
then rockcraft pack; ./retag_rock.sh; fi'
bash -ec 'microk8s ctr image import {env:name}_*-$(yq .base rockcraft.yaml | \
cut -c 8-)_edge_amd64.rock --base-name {env:registry_namespace}/{env:name}'
bash -ec 'if ! [ -d operator ]; then git clone {env:repo} operator; fi' {posargs}
tox --workdir operator -c operator -e ha-integration
bash -ec 'if ! [ -d operator ]; then git clone --single-branch --branch {env:branch} {env:repo} operator; fi' {posargs}
tox --workdir operator -c operator -e ha-integration -- --keep-models


[testenv:tls-integration]
description = run operator integration tests
Expand All @@ -56,5 +59,5 @@ commands =
then rockcraft pack; ./retag_rock.sh; fi'
bash -ec 'microk8s ctr image import {env:name}_*-$(yq .base rockcraft.yaml | \
cut -c 8-)_edge_amd64.rock --base-name {env:registry_namespace}/{env:name}'
bash -ec 'if ! [ -d operator ]; then git clone {env:repo} operator; fi' {posargs}
bash -ec 'if ! [ -d operator ]; then git clone --single-branch --branch {env:branch} {env:repo} operator; fi' {posargs}
tox --workdir operator -c operator -e tls-integration

0 comments on commit 98347d8

Please sign in to comment.