Skip to content

Commit

Permalink
Merge pull request #569 from stgraber/main
Browse files Browse the repository at this point in the history
Fix golang-ci reported issues
  • Loading branch information
brauner authored Mar 1, 2024
2 parents 95bc49d + 22313c6 commit 3d031b7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
12 changes: 6 additions & 6 deletions cmd/incusd/api_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,13 @@ func clusterGet(d *Daemon, r *http.Request) response.Response {

// Fetch information about all node-specific configuration keys set on the
// storage pools and networks of this cluster.
func clusterGetMemberConfig(ctx context.Context, cluster *db.Cluster) ([]api.ClusterMemberConfigKey, error) {
func clusterGetMemberConfig(ctx context.Context, clusterDB *db.Cluster) ([]api.ClusterMemberConfigKey, error) {
var pools map[string]map[string]string
var networks map[string]map[string]string

keys := []api.ClusterMemberConfigKey{}

err := cluster.Transaction(ctx, func(ctx context.Context, tx *db.ClusterTx) error {
err := clusterDB.Transaction(ctx, func(ctx context.Context, tx *db.ClusterTx) error {
var err error

pools, err = tx.GetStoragePoolsLocalConfig(ctx)
Expand Down Expand Up @@ -2784,8 +2784,8 @@ type internalClusterPostHandoverRequest struct {
Address string `json:"address" yaml:"address"`
}

func clusterCheckStoragePoolsMatch(ctx context.Context, cluster *db.Cluster, reqPools []api.StoragePool) error {
return cluster.Transaction(ctx, func(ctx context.Context, tx *db.ClusterTx) error {
func clusterCheckStoragePoolsMatch(ctx context.Context, clusterDB *db.Cluster, reqPools []api.StoragePool) error {
return clusterDB.Transaction(ctx, func(ctx context.Context, tx *db.ClusterTx) error {
poolNames, err := tx.GetCreatedStoragePoolNames(ctx)
if err != nil && !response.IsNotFoundError(err) {
return err
Expand Down Expand Up @@ -2829,8 +2829,8 @@ func clusterCheckStoragePoolsMatch(ctx context.Context, cluster *db.Cluster, req
})
}

func clusterCheckNetworksMatch(ctx context.Context, cluster *db.Cluster, reqNetworks []api.InitNetworksProjectPost) error {
return cluster.Transaction(ctx, func(ctx context.Context, tx *db.ClusterTx) error {
func clusterCheckNetworksMatch(ctx context.Context, clusterDB *db.Cluster, reqNetworks []api.InitNetworksProjectPost) error {
return clusterDB.Transaction(ctx, func(ctx context.Context, tx *db.ClusterTx) error {
// Get a list of projects for networks.
networkProjectNames, err := dbCluster.GetProjectNames(ctx, tx.Tx())
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions cmd/incusd/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -4545,14 +4545,14 @@ func autoSyncImages(ctx context.Context, s *state.State) error {

for fingerprint, projects := range imageProjectInfo {
ch := make(chan error)
go func() {
err := imageSyncBetweenNodes(ctx, s, nil, projects[0], fingerprint)
go func(projectName string, fingerprint string) {
err := imageSyncBetweenNodes(ctx, s, nil, projectName, fingerprint)
if err != nil {
logger.Error("Failed to synchronize images", logger.Ctx{"err": err, "fingerprint": fingerprint})
}

ch <- nil
}()
}(projects[0], fingerprint)

select {
case <-ctx.Done():
Expand Down
16 changes: 8 additions & 8 deletions cmd/incusd/storage_pools_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ func storagePoolValidate(s *state.State, poolName string, driverName string, con
return nil
}

func storagePoolCreateGlobal(ctx context.Context, state *state.State, req api.StoragePoolsPost, clientType request.ClientType) error {
func storagePoolCreateGlobal(ctx context.Context, s *state.State, req api.StoragePoolsPost, clientType request.ClientType) error {
// Create the database entry.
id, err := storagePoolDBCreate(ctx, state, req.Name, req.Description, req.Driver, req.Config)
id, err := storagePoolDBCreate(ctx, s, req.Name, req.Description, req.Driver, req.Config)
if err != nil {
return err
}
Expand All @@ -79,9 +79,9 @@ func storagePoolCreateGlobal(ctx context.Context, state *state.State, req api.St
revert := revert.New()
defer revert.Fail()

revert.Add(func() { _ = dbStoragePoolDeleteAndUpdateCache(context.Background(), state, req.Name) })
revert.Add(func() { _ = dbStoragePoolDeleteAndUpdateCache(context.Background(), s, req.Name) })

_, err = storagePoolCreateLocal(ctx, state, id, req, clientType)
_, err = storagePoolCreateLocal(ctx, s, id, req, clientType)
if err != nil {
return err
}
Expand All @@ -92,13 +92,13 @@ func storagePoolCreateGlobal(ctx context.Context, state *state.State, req api.St

// This performs local pool setup and updates DB record if config was changed during pool setup.
// Returns resulting config.
func storagePoolCreateLocal(ctx context.Context, state *state.State, poolID int64, req api.StoragePoolsPost, clientType request.ClientType) (map[string]string, error) {
func storagePoolCreateLocal(ctx context.Context, s *state.State, poolID int64, req api.StoragePoolsPost, clientType request.ClientType) (map[string]string, error) {
// Setup revert.
revert := revert.New()
defer revert.Fail()

// Load pool record.
pool, err := storagePools.LoadByName(state, req.Name)
pool, err := storagePools.LoadByName(s, req.Name)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -129,7 +129,7 @@ func storagePoolCreateLocal(ctx context.Context, state *state.State, poolID int6
// see if something like this has happened.
configDiff, _ := storagePools.ConfigDiff(req.Config, pool.Driver().Config())
if len(configDiff) > 0 {
err = state.DB.Cluster.Transaction(ctx, func(ctx context.Context, tx *db.ClusterTx) error {
err = s.DB.Cluster.Transaction(ctx, func(ctx context.Context, tx *db.ClusterTx) error {
// Update the database entry for the storage pool.
return tx.UpdateStoragePool(ctx, req.Name, req.Description, pool.Driver().Config())
})
Expand All @@ -139,7 +139,7 @@ func storagePoolCreateLocal(ctx context.Context, state *state.State, poolID int6
}

// Set storage pool node to storagePoolCreated.
err = state.DB.Cluster.Transaction(ctx, func(ctx context.Context, tx *db.ClusterTx) error {
err = s.DB.Cluster.Transaction(ctx, func(ctx context.Context, tx *db.ClusterTx) error {
return tx.StoragePoolNodeCreated(poolID)
})
if err != nil {
Expand Down
12 changes: 6 additions & 6 deletions cmd/incusd/storage_volumes_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,12 +564,12 @@ func storagePoolVolumeTypeCustomBackupGet(d *Daemon, r *http.Request) response.R

fullName := volumeName + internalInstance.SnapshotDelimiter + backupName

backup, err := storagePoolVolumeBackupLoadByName(r.Context(), s, projectName, poolName, fullName)
entry, err := storagePoolVolumeBackupLoadByName(r.Context(), s, projectName, poolName, fullName)
if err != nil {
return response.SmartError(err)
}

return response.SyncResponse(true, backup.Render())
return response.SyncResponse(true, entry.Render())
}

// swagger:operation POST /1.0/storage-pools/{poolName}/volumes/{type}/{volumeName}/backups/{backupName} storage storage_pool_volumes_type_backup_post
Expand Down Expand Up @@ -675,15 +675,15 @@ func storagePoolVolumeTypeCustomBackupPost(d *Daemon, r *http.Request) response.

oldName := volumeName + internalInstance.SnapshotDelimiter + backupName

backup, err := storagePoolVolumeBackupLoadByName(r.Context(), s, projectName, poolName, oldName)
entry, err := storagePoolVolumeBackupLoadByName(r.Context(), s, projectName, poolName, oldName)
if err != nil {
return response.SmartError(err)
}

newName := volumeName + internalInstance.SnapshotDelimiter + req.Name

rename := func(op *operations.Operation) error {
err := backup.Rename(newName)
err := entry.Rename(newName)
if err != nil {
return err
}
Expand Down Expand Up @@ -791,13 +791,13 @@ func storagePoolVolumeTypeCustomBackupDelete(d *Daemon, r *http.Request) respons

fullName := volumeName + internalInstance.SnapshotDelimiter + backupName

backup, err := storagePoolVolumeBackupLoadByName(r.Context(), s, projectName, poolName, fullName)
entry, err := storagePoolVolumeBackupLoadByName(r.Context(), s, projectName, poolName, fullName)
if err != nil {
return response.SmartError(err)
}

remove := func(op *operations.Operation) error {
err := backup.Delete()
err := entry.Delete()
if err != nil {
return err
}
Expand Down

0 comments on commit 3d031b7

Please sign in to comment.