Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate SIGSEGV in CI - do not merge (dqlite 1.16.5) #14468

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
efcd279
shared/entity: Add functions to create snapshot and backup URLs.
markylaing Oct 22, 2024
61e500b
lxd/auth/drivers: Add snapshots and backups to authorization model.
markylaing Oct 22, 2024
64a51fb
lxd/auth/drivers: Clarify that "can_view" allows viewing snapshots an…
markylaing Oct 22, 2024
8aa10b6
lxd/auth: Run `make update-auth`.
markylaing Oct 22, 2024
cca43a7
metadata: Run `make update-metadata`.
markylaing Oct 22, 2024
0f411ad
lxd/auth/drivers: Remove entitlement validation check.
markylaing Oct 22, 2024
0411944
lxd/db/openfga: Use entity types for parent-child relations.
markylaing Oct 25, 2024
51efb53
lxd/db/openfga: Handle instance and storage_volume relations on Read.
markylaing Oct 22, 2024
7132f8d
lxd/db/openfga: Handle instance and storage_volume relations on ReadS…
markylaing Oct 22, 2024
8c97385
lxd: Update instance backup and snapshot authorization checks.
markylaing Oct 22, 2024
7075b21
lxd: Add location to storage volume details.
markylaing Oct 22, 2024
6b1ad72
lxd: Parameterise the storagePoolVolumeTypeAccessHandler by entity type.
markylaing Oct 22, 2024
c2f7a78
lxd: Update calls to the storage volume access handler.
markylaing Oct 22, 2024
fe1456b
lxd: Update storage volume snapshot and backup access checks.
markylaing Oct 22, 2024
ba02391
test/suites: Add tests for storage pool used-by filtering.
markylaing Oct 22, 2024
a97c5d6
Fix linter errors (revive: redefines-builtin-id).
markylaing Nov 15, 2024
5eded9c
DEBUG: Add recovery handling and instance put logging
markylaing Nov 14, 2024
621b81c
Makefile: Use dqlite 1.16.5.
markylaing Nov 15, 2024
150545a
Revert "lxd: Switch to v3 of go-dqlite"
markylaing Nov 15, 2024
bb125d0
Revert "gomod: Switch to v3 of go-dqlite"
markylaing Nov 15, 2024
19997fb
Revert "lxd/cluster: Print last dqlite entry on gateway shutdown"
markylaing Nov 15, 2024
4d3f521
test/includes: Set ulimit before spawning LXD.
markylaing Nov 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
LD_LIBRARY_PATH: "/home/runner/go/bin/dqlite/libs/"
LD_RUN_PATH: "/home/runner/go/bin/dqlite/libs/"
CGO_LDFLAGS_ALLOW: "(-Wl,-wrap,pthread_create)|(-Wl,-z,now)"
GOTRACEBACK: "crash"
name: Code
runs-on: ubuntu-22.04
steps:
Expand Down Expand Up @@ -211,6 +212,7 @@ jobs:
LXD_VERBOSE: "1"
LXD_OFFLINE: "1"
LXD_TMPFS: "1"
GOTRACEBACK: "crash"
name: System
runs-on: ubuntu-22.04
needs: code-tests
Expand Down Expand Up @@ -318,7 +320,7 @@ jobs:
chmod +x ~
echo "root:1000000:1000000000" | sudo tee /etc/subuid /etc/subgid
cd test
sudo --preserve-env=PATH,GOPATH,GOCOVERDIR,GITHUB_ACTIONS,LXD_VERBOSE,LXD_BACKEND,LXD_CEPH_CLUSTER,LXD_CEPH_CEPHFS,LXD_CEPH_CEPHOBJECT_RADOSGW,LXD_OFFLINE,LXD_SKIP_TESTS,LXD_REQUIRED_TESTS, LXD_BACKEND=${{ matrix.backend }} ./main.sh ${{ matrix.suite }}
sudo --preserve-env=PATH,GOPATH,GOCOVERDIR,GITHUB_ACTIONS,LXD_VERBOSE,LXD_BACKEND,LXD_CEPH_CLUSTER,LXD_CEPH_CEPHFS,LXD_CEPH_CEPHOBJECT_RADOSGW,LXD_OFFLINE,LXD_SKIP_TESTS,LXD_REQUIRED_TESTS,GOTRACEBACK, LXD_BACKEND=${{ matrix.backend }} ./main.sh ${{ matrix.suite }}

- name: Upload coverage data
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
Expand Down
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SPHINXENV=doc/.sphinx/venv/bin/activate
SPHINXPIPPATH=doc/.sphinx/venv/bin/pip
GOMIN=1.22.7
GOCOVERDIR ?= $(shell go env GOCOVERDIR)
DQLITE_BRANCH=master
DQLITE_BRANCH=v1.16.5

ifneq "$(wildcard vendor)" ""
DQLITE_PATH=$(CURDIR)/vendor/dqlite
Expand All @@ -37,7 +37,7 @@ ifeq "$(TAG_SQLITE3)" ""
endif

ifeq "$(GOCOVERDIR)" ""
CC="$(CC)" CGO_LDFLAGS_ALLOW="$(CGO_LDFLAGS_ALLOW)" go install -v -tags "$(TAG_SQLITE3)" -trimpath $(DEBUG) ./lxd ./lxc-to-lxd
CC="$(CC)" CGO_LDFLAGS_ALLOW="$(CGO_LDFLAGS_ALLOW)" go install -v -tags "$(TAG_SQLITE3)" -trimpath $(DEBUG) -gcflags="all=-N -l" ./lxd ./lxc-to-lxd
CGO_ENABLED=0 go install -v -tags netgo -trimpath $(DEBUG) ./lxd-user ./lxd-benchmark
else
CC="$(CC)" CGO_LDFLAGS_ALLOW="$(CGO_LDFLAGS_ALLOW)" go install -v -tags "$(TAG_SQLITE3)" -trimpath -cover $(DEBUG) ./lxd ./lxc-to-lxd
Expand Down Expand Up @@ -91,12 +91,13 @@ deps:
# dqlite (+raft)
@if [ ! -e "$(DQLITE_PATH)" ]; then \
echo "Retrieving dqlite from ${DQLITE_BRANCH} branch"; \
git clone --depth=1 --branch "${DQLITE_BRANCH}" "https://github.com/canonical/dqlite" "$(DQLITE_PATH)"; \
git clone --branch "${DQLITE_BRANCH}" "https://github.com/canonical/dqlite" "$(DQLITE_PATH)"; \
elif [ -e "$(DQLITE_PATH)/.git" ]; then \
echo "Updating existing dqlite branch"; \
cd "$(DQLITE_PATH)"; git pull; \
fi


cd "$(DQLITE_PATH)" && \
autoreconf -i && \
./configure --enable-build-raft && \
Expand Down
4 changes: 2 additions & 2 deletions doc/metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5999,7 +5999,7 @@ container or containers that use it. This allows using the `zfs` command in the
: Grants permission to delete the instance.

`can_view`
: Grants permission to view the instance.
: Grants permission to view the instance and any snapshots or backups it might have.

`can_update_state`
: Grants permission to change the instance state.
Expand Down Expand Up @@ -6365,7 +6365,7 @@ container or containers that use it. This allows using the `zfs` command in the
: Grants permission to delete the storage volume.

`can_view`
: Grants permission to view the storage volume.
: Grants permission to view the storage volume and any snapshots or backups it might have.

`can_manage_snapshots`
: Grants permission to create and delete snapshots of the storage volume.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/NVIDIA/nvidia-container-toolkit v1.17.0
github.com/Rican7/retry v0.3.1
github.com/armon/go-proxyproto v0.1.0
github.com/canonical/go-dqlite/v3 v3.0.0
github.com/canonical/go-dqlite v1.22.0
github.com/checkpoint-restore/go-criu/v6 v6.3.0
github.com/dell/goscaleio v1.16.0
github.com/digitalocean/go-qemu v0.0.0-20230711162256-2e3d0186973e
Expand Down
458 changes: 453 additions & 5 deletions go.sum

Large diffs are not rendered by default.

10 changes: 0 additions & 10 deletions lxd/auth/drivers/openfga.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,6 @@ func (e *embeddedOpenFGA) CheckPermission(ctx context.Context, entityURL *api.UR
return fmt.Errorf("Failed to parse entity URL: %w", err)
}

err = auth.ValidateEntitlement(entityType, entitlement)
if err != nil {
return fmt.Errorf("Cannot check permissions for entity type %q and entitlement %q: %w", entityType, entitlement, err)
}

logCtx := logger.Ctx{"entity_url": entityURL.String(), "entitlement": entitlement}
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
Expand Down Expand Up @@ -324,11 +319,6 @@ func (e *embeddedOpenFGA) CheckPermission(ctx context.Context, entityURL *api.UR
// this function is called. The returned auth.PermissionChecker will expect entity URLs to contain the request URL. These
// will be re-written to contain the effective project if set, so that they correspond to the list returned by OpenFGA.
func (e *embeddedOpenFGA) GetPermissionChecker(ctx context.Context, entitlement auth.Entitlement, entityType entity.Type) (auth.PermissionChecker, error) {
err := auth.ValidateEntitlement(entityType, entitlement)
if err != nil {
return nil, fmt.Errorf("Cannot get a permission checker for entity type %q and entitlement %q: %w", entityType, entitlement, err)
}

logCtx := logger.Ctx{"entity_type": entityType, "entitlement": entitlement}
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
Expand Down
34 changes: 32 additions & 2 deletions lxd/auth/drivers/openfga_model.openfga
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ type instance
# Grants permission to delete the instance.
define can_delete: [identity, service_account, group#member] or can_delete_instances from project

# Grants permission to view the instance.
# Grants permission to view the instance and any snapshots or backups it might have.
define can_view: [identity, service_account, group#member] or user or operator or can_edit or can_delete or can_view_instances from project

# Grants permission to change the instance state.
Expand All @@ -389,6 +389,21 @@ type instance

# Grants permission to start a terminal session.
define can_exec: [identity, service_account, group#member] or user or operator or can_operate_instances from project

type instance_snapshot
relations
define instance: [instance]
define can_view: can_view from instance
define can_edit: can_manage_snapshots from instance
define can_delete: can_manage_snapshots from instance

type instance_backup
relations
define instance: [instance]
define can_view: can_view from instance
define can_edit: can_manage_backups from instance
define can_delete: can_manage_backups from instance

type network
relations
define project: [project]
Expand Down Expand Up @@ -447,14 +462,29 @@ type storage_volume
# Grants permission to delete the storage volume.
define can_delete: [identity, service_account, group#member] or can_delete_storage_volumes from project

# Grants permission to view the storage volume.
# Grants permission to view the storage volume and any snapshots or backups it might have.
define can_view: [identity, service_account, group#member] or can_edit or can_delete or can_view_storage_volumes from project

# Grants permission to create and delete snapshots of the storage volume.
define can_manage_snapshots: [identity, service_account, group#member] or can_edit_storage_volumes from project

# Grants permission to create and delete backups of the storage volume.
define can_manage_backups: [identity, service_account, group#member] or can_edit_storage_volumes from project

type storage_volume_snapshot
relations
define storage_volume: [storage_volume]
define can_view: can_view from storage_volume
define can_edit: can_manage_snapshots from storage_volume
define can_delete: can_manage_snapshots from storage_volume

type storage_volume_backup
relations
define storage_volume: [storage_volume]
define can_view: can_view from storage_volume
define can_edit: can_manage_backups from storage_volume
define can_delete: can_manage_backups from storage_volume

type storage_bucket
relations
define project: [project]
Expand Down
4 changes: 2 additions & 2 deletions lxd/auth/entitlements_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 3 additions & 15 deletions lxd/cluster/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (
"sync"
"time"

"github.com/canonical/go-dqlite/v3"
"github.com/canonical/go-dqlite/v3/client"
"github.com/canonical/go-dqlite"
"github.com/canonical/go-dqlite/client"

"github.com/canonical/lxd/lxd/db"
"github.com/canonical/lxd/lxd/identity"
Expand Down Expand Up @@ -517,7 +517,7 @@ func (g *Gateway) DemoteOfflineNode(raftID uint64) error {

// Shutdown this gateway, stopping the gRPC server and possibly the raft factory.
func (g *Gateway) Shutdown() error {
logger.Info("Stop database gateway")
logger.Infof("Stop database gateway")

var err error
if g.server != nil {
Expand All @@ -533,18 +533,6 @@ func (g *Gateway) Shutdown() error {
g.lock.Lock()
g.memoryDial = nil
g.lock.Unlock()

// Record the raft term and index in the logs on every shutdown. This
// allows an administrator to determine the furthest-ahead cluster member
// in case recovery is needed.
lastEntryInfo, err := dqlite.ReadLastEntryInfo(g.db.Dir())
if err != nil {
return err
}

// This isn't really a warning, but it's important that this break through
// the snap's default log level of 'Warn'.
logger.Warn("Dqlite last entry", logger.Ctx{"term": lastEntryInfo.Term, "index": lastEntryInfo.Index})
}

return err
Expand Down
2 changes: 1 addition & 1 deletion lxd/cluster/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"os"
"testing"

"github.com/canonical/go-dqlite/v3/driver"
"github.com/canonical/go-dqlite/driver"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

Expand Down
2 changes: 1 addition & 1 deletion lxd/cluster/heartbeat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"
"time"

"github.com/canonical/go-dqlite/v3/driver"
"github.com/canonical/go-dqlite/driver"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

Expand Down
4 changes: 2 additions & 2 deletions lxd/cluster/membership.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"sync"
"time"

"github.com/canonical/go-dqlite/v3/app"
"github.com/canonical/go-dqlite/v3/client"
"github.com/canonical/go-dqlite/app"
"github.com/canonical/go-dqlite/client"

"github.com/canonical/lxd/lxd/certificate"
"github.com/canonical/lxd/lxd/db"
Expand Down
2 changes: 1 addition & 1 deletion lxd/cluster/membership_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"testing"
"time"

"github.com/canonical/go-dqlite/v3/driver"
"github.com/canonical/go-dqlite/driver"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

Expand Down
2 changes: 1 addition & 1 deletion lxd/cluster/raft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http/httptest"
"testing"

"github.com/canonical/go-dqlite/v3/client"
"github.com/canonical/go-dqlite/client"
"github.com/stretchr/testify/require"

"github.com/canonical/lxd/lxd/db"
Expand Down
4 changes: 2 additions & 2 deletions lxd/cluster/recover.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"strings"
"time"

dqlite "github.com/canonical/go-dqlite/v3"
"github.com/canonical/go-dqlite/v3/client"
dqlite "github.com/canonical/go-dqlite"
"github.com/canonical/go-dqlite/client"
"gopkg.in/yaml.v2"

"github.com/canonical/lxd/lxd/db"
Expand Down
2 changes: 1 addition & 1 deletion lxd/cluster/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"os"
"time"

"github.com/canonical/go-dqlite/v3/client"
"github.com/canonical/go-dqlite/client"

"github.com/canonical/lxd/client"
"github.com/canonical/lxd/lxd/db"
Expand Down
4 changes: 2 additions & 2 deletions lxd/cluster/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"testing"
"time"

"github.com/canonical/go-dqlite/v3/client"
"github.com/canonical/go-dqlite/v3/driver"
"github.com/canonical/go-dqlite/client"
"github.com/canonical/go-dqlite/driver"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

Expand Down
Loading
Loading