Skip to content

Commit

Permalink
Merge pull request juju#16274 from hpidcock/merge-3.2-3.3-20230918
Browse files Browse the repository at this point in the history
juju#16274

Forward ports:
- juju#16270
- juju#16262
- juju#16271
- juju#16272

Conflicts:
- .github/workflows/microk8s-tests.yml
  • Loading branch information
jujubot authored Sep 18, 2023
2 parents 7a9b76f + cff857d commit 4016256
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 23 deletions.
17 changes: 17 additions & 0 deletions .github/microk8s-launch-config-aws.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
version: 0.1.0
extraKubeletArgs:
--cluster-domain: cluster.local
--cluster-dns: 10.152.183.10
addons:
- name: dns
containerdRegistryConfigs:
docker.io: |
[host."http://10.0.1.123:80"]
capabilities = ["pull", "resolve"]
skip_verify = true
10.152.183.69: |
[host."https://10.152.183.69:443"]
capabilities = ["pull", "resolve", "push"]
skip_verify = true
12 changes: 10 additions & 2 deletions .github/workflows/microk8s-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
fail-fast: false
matrix:
microk8s: [1.21/stable]
microk8s: [1.28/stable]

steps:
- name: Checking out repo
Expand All @@ -37,11 +37,19 @@ jobs:
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Setup Docker Mirror
shell: bash
run: |
(cat /etc/docker/daemon.json 2> /dev/null || echo "{}") | yq -o json '.registry-mirrors += ["http://10.0.1.123:80"]' | sudo tee /etc/docker/daemon.json
sudo systemctl restart docker
docker system info
- uses: balchua/microk8s-actions@bd37d99d167cfd7499a33c97eaaa04688a1a25b6
with:
channel: '${{ matrix.microk8s }}'
# enable now to give microk8s more time to settle down.
addons: '["dns", "storage", "dashboard", "ingress", "metallb:10.64.140.43-10.64.140.49"]'
addons: '["dns", "hostpath-storage", "dashboard", "ingress", "metallb:10.64.140.43-10.64.140.49"]'
launch-configuration: "$GITHUB_WORKSPACE/.github/microk8s-launch-config-aws.yaml"

- name: Install Dependencies
run: |
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,20 @@ jobs:
if: matrix.cloud == 'localhost'
uses: canonical/setup-lxd@4e959f8e0d9c5feb27d44c5e4d9a330a782edee0

- name: Setup Docker Mirror
shell: bash
run: |
(cat /etc/docker/daemon.json 2> /dev/null || echo "{}") | yq -o json '.registry-mirrors += ["http://10.0.1.123:80"]' | sudo tee /etc/docker/daemon.json
sudo systemctl restart docker
docker system info
- name: Setup MicroK8s
if: matrix.cloud == 'microk8s'
uses: balchua/microk8s-actions@bd37d99d167cfd7499a33c97eaaa04688a1a25b6
with:
channel: "1.25-strict/stable"
channel: "1.28-strict/stable"
addons: '["dns", "hostpath-storage", "rbac"]'
launch-configuration: "$GITHUB_WORKSPACE/.github/microk8s-launch-config-aws.yaml"

- name: Set up Go
uses: actions/setup-go@v4
Expand Down
33 changes: 17 additions & 16 deletions .github/workflows/upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ jobs:
if: env.RUN_TEST == 'RUN'
uses: actions/checkout@v3

# We use LXD in the microk8s test too, to build the snap.
- name: Setup LXD
if: env.RUN_TEST == 'RUN' && matrix.model_type == 'localhost'
uses: canonical/setup-lxd@4e959f8e0d9c5feb27d44c5e4d9a330a782edee0
Expand Down Expand Up @@ -82,12 +81,22 @@ jobs:
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Setup Docker Mirror
if: env.RUN_TEST == 'RUN' && matrix.model_type == 'microk8s'
shell: bash
run: |
(cat /etc/docker/daemon.json 2> /dev/null || echo "{}") | yq -o json '.registry-mirrors += ["http://10.0.1.123:80"]' | sudo tee /etc/docker/daemon.json
(cat /etc/docker/daemon.json 2> /dev/null || echo "{}") | yq -o json ".insecure-registries += [\"${DOCKER_REGISTRY}\"]" | sudo tee /etc/docker/daemon.json
sudo systemctl restart docker
docker system info
- name: Setup k8s
if: env.RUN_TEST == 'RUN' && matrix.model_type == 'microk8s'
uses: balchua/microk8s-actions@bd37d99d167cfd7499a33c97eaaa04688a1a25b6
with:
channel: "1.25-strict/stable"
channel: "1.28-strict/stable"
addons: '["dns", "hostpath-storage"]'
launch-configuration: "$GITHUB_WORKSPACE/.github/microk8s-launch-config-aws.yaml"

- name: Setup local caas registry
if: env.RUN_TEST == 'RUN' && matrix.model_type == 'microk8s'
Expand All @@ -104,23 +113,15 @@ jobs:
# Recognise CA
sudo cp ~/certs/ca.crt /usr/local/share/ca-certificates
sudo update-ca-certificates
sudo mkdir -p /etc/docker/certs.d/${DOCKER_REGISTRY}/
sudo cp ~/certs/ca.crt /etc/docker/certs.d/${DOCKER_REGISTRY}/
# Generate certs
openssl req -nodes -newkey rsa:2048 -keyout ~/certs/registry.key -out ~/certs/registry.csr -subj "/CN=registry"
openssl x509 -req -in ~/certs/registry.csr -CA ~/certs/ca.crt -CAkey ~/certs/ca.key \
-out ~/certs/registry.crt -CAcreateserial -days 365 -sha256 -extfile .github/registry.ext
-out ~/certs/registry.crt -CAcreateserial -days 365 -sha256 -extfile $GITHUB_WORKSPACE/.github/registry.ext
# Deploy registry
cat .github/reg.yml | CERT_DIR=$HOME/certs envsubst | sg snap_microk8s "microk8s kubectl create -f -"
# TODO:(jack-w-shaw) Figure out why we need this and do something nicer
sudo microk8s refresh-certs --cert ca.crt
sudo microk8s refresh-certs --cert server.crt
sg snap_microk8s "microk8s status --wait-ready"
cat $GITHUB_WORKSPACE/.github/reg.yml | CERT_DIR=$HOME/certs envsubst | sg snap_microk8s "microk8s kubectl create -f -"
# Wait for registry
sg snap_microk8s "microk8s kubectl wait --for condition=available deployment registry -n container-registry --timeout 180s" || true
Expand Down Expand Up @@ -208,7 +209,7 @@ jobs:
juju wait-for application ${CHARM_${{ matrix.model_type }}}
.github/verify-${CHARM_${{ matrix.model_type }}}.sh 30
$GITHUB_WORKSPACE/.github/verify-${CHARM_${{ matrix.model_type }}}.sh 30
- name: Update Juju
if: env.RUN_TEST == 'RUN'
Expand Down Expand Up @@ -282,7 +283,7 @@ jobs:
exit 1
fi
.github/verify-${CHARM_${{ matrix.model_type }}}.sh 30
$GITHUB_WORKSPACE/.github/verify-${CHARM_${{ matrix.model_type }}}.sh 30
- name: Test upgrade model
if: env.RUN_TEST == 'RUN'
Expand Down Expand Up @@ -321,7 +322,7 @@ jobs:
exit 1
fi
.github/verify-${CHARM_${{ matrix.model_type }}}.sh 30
$GITHUB_WORKSPACE/.github/verify-${CHARM_${{ matrix.model_type }}}.sh 30
- name: Wrap up
if: env.RUN_TEST == 'RUN'
Expand Down
14 changes: 11 additions & 3 deletions state/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package state

import (
"fmt"
"strconv"
"time"

"github.com/juju/charm/v11"
Expand Down Expand Up @@ -285,13 +286,20 @@ func (st *State) cleanupRelationSettings(prefix string) error {
}

func (st *State) cleanupForceDestroyedRelation(prefix string) (err error) {
relation, err := st.KeyRelation(prefix)
var relation *Relation
var relId int
if relId, err = strconv.Atoi(prefix); err == nil {
relation, err = st.Relation(relId)
} else if err != nil {
logger.Warningf("handling legacy cleanupForceDestroyedRelation with relation key %q", prefix)
relation, err = st.KeyRelation(prefix)
}
if errors.IsNotFound(err) {
return nil
}
if err != nil {
} else if err != nil {
return errors.Annotatef(err, "getting relation %q", prefix)
}

scopes, closer := st.db().GetCollection(relationScopesC)
defer closer()

Expand Down
3 changes: 2 additions & 1 deletion state/relation.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package state
import (
"fmt"
"sort"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -427,7 +428,7 @@ func (r *Relation) destroyOps(ignoreApplication string, op *ForcedOperation) (op
// Since we are force destroying, life assert should be current relation's life.
lifeAssert = bson.D{{"life", r.doc.Life}}
deadline := r.st.stateClock.Now().Add(op.MaxWait)
ops = append(ops, newCleanupAtOp(deadline, cleanupForceDestroyedRelation, relationKey(r.Endpoints())))
ops = append(ops, newCleanupAtOp(deadline, cleanupForceDestroyedRelation, strconv.Itoa(r.Id())))
}

ops = append(ops, txn.Op{
Expand Down

0 comments on commit 4016256

Please sign in to comment.