The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7442
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) ===
From 901c2ae25c607db6f2916ae5e7e37ad921509af5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Tue, 26 May 2020 10:55:16 -0400 Subject: [PATCH 1/4] shared/subprocess: Fix race condition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- shared/subprocess/proc.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/shared/subprocess/proc.go b/shared/subprocess/proc.go index ca24eca9f1..8ce430e171 100644 --- a/shared/subprocess/proc.go +++ b/shared/subprocess/proc.go @@ -48,6 +48,9 @@ func (p *Process) Stop() error { } } + // Wait for any background goroutine to be done. + <-p.chExit + // Check if either the existence check or the kill resulted in an already finished error. if strings.Contains(err.Error(), "process already finished") { return ErrNotRunning @@ -103,8 +106,7 @@ func (p *Process) Start() error { return } - exitcode := int64(procstate.Sys().(syscall.WaitStatus).ExitStatus()) - p.exitCode = exitcode + p.exitCode = int64(procstate.ExitCode()) close(p.chExit) }() From f8304e70967a7d50d7e16648d3f76f1dda0d8fb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Tue, 26 May 2020 11:08:54 -0400 Subject: [PATCH 2/4] lxd: Make use of ExitCode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- lxd/device/device_utils_disk.go | 6 ++---- lxd/patches_utils.go | 4 +--- lxd/rsync/rsync.go | 4 +--- lxd/storage/drivers/driver_ceph_utils.go | 15 +++++---------- lxd/storage/drivers/driver_common.go | 5 +---- lxd/storage/drivers/driver_lvm_utils.go | 4 +--- 6 files changed, 11 insertions(+), 27 deletions(-) diff --git a/lxd/device/device_utils_disk.go b/lxd/device/device_utils_disk.go index a9245d0d0e..217be7e157 100644 --- a/lxd/device/device_utils_disk.go +++ b/lxd/device/device_utils_disk.go @@ -6,7 +6,6 @@ import ( "os" "os/exec" "strings" - "syscall" "time" "golang.org/x/sys/unix" @@ -149,13 +148,12 @@ again: if ok { exitError, ok := runError.Err.(*exec.ExitError) if ok { - waitStatus := exitError.Sys().(syscall.WaitStatus) - if waitStatus.ExitStatus() == 22 { + if exitError.ExitCode() == 22 { // EINVAL (already unmapped) return nil } - if waitStatus.ExitStatus() == 16 { + if exitError.ExitCode() == 16 { // EBUSY (currently in use) busyCount++ if busyCount == 10 { diff --git a/lxd/patches_utils.go b/lxd/patches_utils.go index c66ad692fd..256422f32e 100644 --- a/lxd/patches_utils.go +++ b/lxd/patches_utils.go @@ -9,7 +9,6 @@ import ( "sort" "strconv" "strings" - "syscall" "github.com/lxc/lxd/lxd/project" "github.com/lxc/lxd/lxd/state" @@ -171,8 +170,7 @@ func lvmLVExists(lvName string) (bool, error) { if ok { exitError, ok := runErr.Err.(*exec.ExitError) if ok { - waitStatus := exitError.Sys().(syscall.WaitStatus) - if waitStatus.ExitStatus() == 5 { + if exitError.ExitCode() == 5 { // logical volume not found return false, nil } diff --git a/lxd/rsync/rsync.go b/lxd/rsync/rsync.go index 8f811ff4f8..b5b70a58ce 100644 --- a/lxd/rsync/rsync.go +++ b/lxd/rsync/rsync.go @@ -7,7 +7,6 @@ import ( "net" "os" "os/exec" - "syscall" "time" "github.com/pborman/uuid" @@ -67,8 +66,7 @@ func LocalCopy(source string, dest string, bwlimit string, xattrs bool, rsyncArg if ok { exitError, ok := runError.Err.(*exec.ExitError) if ok { - waitStatus := exitError.Sys().(syscall.WaitStatus) - if waitStatus.ExitStatus() == 24 { + if exitError.ExitCode() == 24 { return msg, nil } } diff --git a/lxd/storage/drivers/driver_ceph_utils.go b/lxd/storage/drivers/driver_ceph_utils.go index 47ebdb1be2..a7a0f1fea6 100644 --- a/lxd/storage/drivers/driver_ceph_utils.go +++ b/lxd/storage/drivers/driver_ceph_utils.go @@ -10,7 +10,6 @@ import ( "regexp" "strconv" "strings" - "syscall" "time" "github.com/pborman/uuid" @@ -157,13 +156,12 @@ again: if ok { exitError, ok := runError.Err.(*exec.ExitError) if ok { - waitStatus := exitError.Sys().(syscall.WaitStatus) - if waitStatus.ExitStatus() == 22 { + if exitError.ExitCode() == 22 { // EINVAL (already unmapped). return nil } - if waitStatus.ExitStatus() == 16 { + if exitError.ExitCode() == 16 { // EBUSY (currently in use). busyCount++ if busyCount == 10 { @@ -203,8 +201,7 @@ again: if ok { exitError, ok := runError.Err.(*exec.ExitError) if ok { - waitStatus := exitError.Sys().(syscall.WaitStatus) - if waitStatus.ExitStatus() == 22 { + if exitError.ExitCode() == 22 { // EINVAL (already unmapped). return nil } @@ -256,8 +253,7 @@ func (d *ceph) rbdProtectVolumeSnapshot(vol Volume, snapshotName string) error { if ok { exitError, ok := runError.Err.(*exec.ExitError) if ok { - waitStatus := exitError.Sys().(syscall.WaitStatus) - if waitStatus.ExitStatus() == 16 { + if exitError.ExitCode() == 16 { // EBUSY (snapshot already protected). return nil } @@ -287,8 +283,7 @@ func (d *ceph) rbdUnprotectVolumeSnapshot(vol Volume, snapshotName string) error if ok { exitError, ok := runError.Err.(*exec.ExitError) if ok { - waitStatus := exitError.Sys().(syscall.WaitStatus) - if waitStatus.ExitStatus() == 22 { + if exitError.ExitCode() == 22 { // EBUSY (snapshot already unprotected). return nil } diff --git a/lxd/storage/drivers/driver_common.go b/lxd/storage/drivers/driver_common.go index 7f0c7dbf78..e3992540c4 100644 --- a/lxd/storage/drivers/driver_common.go +++ b/lxd/storage/drivers/driver_common.go @@ -4,7 +4,6 @@ import ( "fmt" "os/exec" "strings" - "syscall" "github.com/pkg/errors" @@ -207,11 +206,9 @@ func (d *common) moveGPTAltHeader(devPath string) error { if ok { exitError, ok := runErr.Err.(*exec.ExitError) if ok { - waitStatus := exitError.Sys().(syscall.WaitStatus) - // sgdisk manpage says exit status 3 means: // "Non-GPT disk detected and no -g option, but operation requires a write action". - if waitStatus.ExitStatus() == 3 { + if exitError.ExitCode() == 3 { return nil // Non-error as non-GPT disk specified. } } diff --git a/lxd/storage/drivers/driver_lvm_utils.go b/lxd/storage/drivers/driver_lvm_utils.go index fed31681bc..25fccb82bb 100644 --- a/lxd/storage/drivers/driver_lvm_utils.go +++ b/lxd/storage/drivers/driver_lvm_utils.go @@ -7,7 +7,6 @@ import ( "path/filepath" "strconv" "strings" - "syscall" "github.com/pkg/errors" @@ -120,8 +119,7 @@ func (d *lvm) isLVMNotFoundExitError(err error) bool { if ok { exitError, ok := runErr.Err.(*exec.ExitError) if ok { - waitStatus := exitError.Sys().(syscall.WaitStatus) - if waitStatus.ExitStatus() == 5 { + if exitError.ExitCode() == 5 { return true } } From ed5cf84fec386e98e524ed20995d72951d7c7854 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Tue, 26 May 2020 11:09:30 -0400 Subject: [PATCH 3/4] share/subprocess: Reduce sleep back to 5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- shared/subprocess/testscript/stoprestart.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/subprocess/testscript/stoprestart.sh b/shared/subprocess/testscript/stoprestart.sh index fb36b8e0c8..2f74e74ce2 100644 --- a/shared/subprocess/testscript/stoprestart.sh +++ b/shared/subprocess/testscript/stoprestart.sh @@ -2,4 +2,4 @@ echo "hello again" echo "waiting now" -sleep 10 +sleep 5 From 1f63aee53072be3924da17c11851b266116c4cbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Tue, 26 May 2020 13:58:30 -0400 Subject: [PATCH 4/4] DEBUG MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- lxd/instance/drivers/driver_lxc.go | 5 +- test/main.sh | 220 ++++++++++++++--------------- 2 files changed, 113 insertions(+), 112 deletions(-) diff --git a/lxd/instance/drivers/driver_lxc.go b/lxd/instance/drivers/driver_lxc.go index 4249eb814f..c36ef54f05 100644 --- a/lxd/instance/drivers/driver_lxc.go +++ b/lxd/instance/drivers/driver_lxc.go @@ -5837,9 +5837,10 @@ func (c *lxc) networkState() map[string]api.InstanceStateNetwork { // Process forkgetnet response if err != nil { - logger.Error("Error calling 'lxd forkgetnet", log.Ctx{"container": c.name, "err": err, "pid": pid}) + logger.Error("Error calling 'lxd forknet", log.Ctx{"container": c.name, "err": err, "pid": pid}) return result } + logger.Errorf("stgraber: %v", out) // If we can use netns_getifaddrs() but it failed and the setns() + // netns_getifaddrs() succeeded we should just always fallback to the @@ -5849,7 +5850,7 @@ func (c *lxc) networkState() map[string]api.InstanceStateNetwork { nw := map[string]api.InstanceStateNetwork{} err = json.Unmarshal([]byte(out), &nw) if err != nil { - logger.Error("Failure to read forkgetnet json", log.Ctx{"container": c.name, "err": err}) + logger.Error("Failure to read forknet json", log.Ctx{"container": c.name, "err": err}) return result } result = nw diff --git a/test/main.sh b/test/main.sh index 8219df0990..e5f8bcbe90 100755 --- a/test/main.sh +++ b/test/main.sh @@ -154,117 +154,117 @@ if [ "$#" -gt 0 ]; then exit fi -run_test test_check_deps "checking dependencies" -run_test test_static_analysis "static analysis" -run_test test_database_update "database schema updates" -run_test test_database_restore "database restore" -run_test test_database_no_disk_space "database out of disk space" -run_test test_sql "lxd sql" -run_test test_basic_usage "basic usage" -run_test test_remote_url "remote url handling" -run_test test_remote_admin "remote administration" -run_test test_remote_usage "remote usage" -run_test test_clustering_enable "clustering enable" -run_test test_clustering_membership "clustering membership" -run_test test_clustering_containers "clustering containers" -run_test test_clustering_storage "clustering storage" -run_test test_clustering_storage_single_node "clustering storage single node" -run_test test_clustering_network "clustering network" -run_test test_clustering_publish "clustering publish" -run_test test_clustering_profiles "clustering profiles" -run_test test_clustering_join_api "clustering join api" -run_test test_clustering_shutdown_nodes "clustering shutdown" -run_test test_clustering_projects "clustering projects" -run_test test_clustering_address "clustering address" -run_test test_clustering_image_replication "clustering image replication" -run_test test_clustering_dns "clustering DNS" -run_test test_clustering_recover "clustering recovery" -run_test test_clustering_handover "clustering handover" -run_test test_clustering_rebalance "clustering rebalance" -run_test test_clustering_remove_raft_node "custering remove raft node" -# run_test test_clustering_upgrade "clustering upgrade" -run_test test_projects_default "default project" -run_test test_projects_crud "projects CRUD operations" -run_test test_projects_containers "containers inside projects" -run_test test_projects_snapshots "snapshots inside projects" -run_test test_projects_backups "backups inside projects" -run_test test_projects_profiles "profiles inside projects" -run_test test_projects_profiles_default "profiles from the global default project" -run_test test_projects_images "images inside projects" -run_test test_projects_images_default "images from the global default project" -run_test test_projects_storage "projects and storage pools" -run_test test_projects_network "projects and networks" -run_test test_projects_limits "projects limits" -run_test test_projects_restrictions "projects restrictions" -run_test test_container_devices_disk "container devices - disk" -run_test test_container_devices_nic_p2p "container devices - nic - p2p" -run_test test_container_devices_nic_bridged "container devices - nic - bridged" -run_test test_container_devices_nic_bridged_filtering "container devices - nic - bridged - filtering" -run_test test_container_devices_nic_physical "container devices - nic - physical" -run_test test_container_devices_nic_macvlan "container devices - nic - macvlan" -run_test test_container_devices_nic_ipvlan "container devices - nic - ipvlan" -run_test test_container_devices_nic_sriov "container devices - nic - sriov" -run_test test_container_devices_nic_routed "container devices - nic - routed" -run_test test_container_devices_infiniband_physical "container devices - infiniband - physical" -run_test test_container_devices_infiniband_sriov "container devices - infiniband - sriov" -run_test test_container_devices_proxy "container devices - proxy" -run_test test_container_devices_gpu "container devices - gpu" -run_test test_container_devices_unix_char "container devices - unix-char" -run_test test_container_devices_unix_block "container devices - unix-block" -run_test test_security "security features" -run_test test_security_protection "container protection" -run_test test_image_expiry "image expiry" -run_test test_image_list_all_aliases "image list all aliases" -run_test test_image_auto_update "image auto-update" -run_test test_image_prefer_cached "image prefer cached" -run_test test_image_import_dir "import image from directory" -run_test test_concurrent_exec "concurrent exec" -run_test test_concurrent "concurrent startup" -run_test test_snapshots "container snapshots" -run_test test_snap_restore "snapshot restores" -run_test test_snap_expiry "snapshot expiry" -run_test test_config_profiles "profiles and configuration" -run_test test_config_edit "container configuration edit" -run_test test_config_edit_container_snapshot_pool_config "container and snapshot volume configuration edit" -run_test test_container_metadata "manage container metadata and templates" -run_test test_container_snapshot_config "container snapshot configuration" -run_test test_server_config "server configuration" -run_test test_filemanip "file manipulations" +###run_test test_check_deps "checking dependencies" +###run_test test_static_analysis "static analysis" +###run_test test_database_update "database schema updates" +###run_test test_database_restore "database restore" +###run_test test_database_no_disk_space "database out of disk space" +###run_test test_sql "lxd sql" +###run_test test_basic_usage "basic usage" +###run_test test_remote_url "remote url handling" +###run_test test_remote_admin "remote administration" +###run_test test_remote_usage "remote usage" +###run_test test_clustering_enable "clustering enable" +###run_test test_clustering_membership "clustering membership" +###run_test test_clustering_containers "clustering containers" +###run_test test_clustering_storage "clustering storage" +###run_test test_clustering_storage_single_node "clustering storage single node" +###run_test test_clustering_network "clustering network" +###run_test test_clustering_publish "clustering publish" +###run_test test_clustering_profiles "clustering profiles" +###run_test test_clustering_join_api "clustering join api" +###run_test test_clustering_shutdown_nodes "clustering shutdown" +###run_test test_clustering_projects "clustering projects" +###run_test test_clustering_address "clustering address" +###run_test test_clustering_image_replication "clustering image replication" +###run_test test_clustering_dns "clustering DNS" +###run_test test_clustering_recover "clustering recovery" +###run_test test_clustering_handover "clustering handover" +###run_test test_clustering_rebalance "clustering rebalance" +###run_test test_clustering_remove_raft_node "custering remove raft node" +#### run_test test_clustering_upgrade "clustering upgrade" +###run_test test_projects_default "default project" +###run_test test_projects_crud "projects CRUD operations" +###run_test test_projects_containers "containers inside projects" +###run_test test_projects_snapshots "snapshots inside projects" +###run_test test_projects_backups "backups inside projects" +###run_test test_projects_profiles "profiles inside projects" +###run_test test_projects_profiles_default "profiles from the global default project" +###run_test test_projects_images "images inside projects" +###run_test test_projects_images_default "images from the global default project" +###run_test test_projects_storage "projects and storage pools" +###run_test test_projects_network "projects and networks" +###run_test test_projects_limits "projects limits" +###run_test test_projects_restrictions "projects restrictions" +###run_test test_container_devices_disk "container devices - disk" +###run_test test_container_devices_nic_p2p "container devices - nic - p2p" +###run_test test_container_devices_nic_bridged "container devices - nic - bridged" +###run_test test_container_devices_nic_bridged_filtering "container devices - nic - bridged - filtering" +###run_test test_container_devices_nic_physical "container devices - nic - physical" +###run_test test_container_devices_nic_macvlan "container devices - nic - macvlan" +###run_test test_container_devices_nic_ipvlan "container devices - nic - ipvlan" +###run_test test_container_devices_nic_sriov "container devices - nic - sriov" +###run_test test_container_devices_nic_routed "container devices - nic - routed" +###run_test test_container_devices_infiniband_physical "container devices - infiniband - physical" +###run_test test_container_devices_infiniband_sriov "container devices - infiniband - sriov" +###run_test test_container_devices_proxy "container devices - proxy" +###run_test test_container_devices_gpu "container devices - gpu" +###run_test test_container_devices_unix_char "container devices - unix-char" +###run_test test_container_devices_unix_block "container devices - unix-block" +###run_test test_security "security features" +###run_test test_security_protection "container protection" +###run_test test_image_expiry "image expiry" +###run_test test_image_list_all_aliases "image list all aliases" +###run_test test_image_auto_update "image auto-update" +###run_test test_image_prefer_cached "image prefer cached" +###run_test test_image_import_dir "import image from directory" +###run_test test_concurrent_exec "concurrent exec" +###run_test test_concurrent "concurrent startup" +###run_test test_snapshots "container snapshots" +###run_test test_snap_restore "snapshot restores" +###run_test test_snap_expiry "snapshot expiry" +###run_test test_config_profiles "profiles and configuration" +###run_test test_config_edit "container configuration edit" +###run_test test_config_edit_container_snapshot_pool_config "container and snapshot volume configuration edit" +###run_test test_container_metadata "manage container metadata and templates" +###run_test test_container_snapshot_config "container snapshot configuration" +###run_test test_server_config "server configuration" +###run_test test_filemanip "file manipulations" run_test test_network "network management" -run_test test_idmap "id mapping" -run_test test_template "file templating" -run_test test_pki "PKI mode" -run_test test_devlxd "/dev/lxd" -run_test test_fuidshift "fuidshift" -run_test test_migration "migration" -run_test test_fdleak "fd leak" -run_test test_storage "storage" -run_test test_storage_volume_snapshots "storage volume snapshots" -run_test test_init_auto "lxd init auto" -run_test test_init_interactive "lxd init interactive" -run_test test_init_preseed "lxd init preseed" -run_test test_storage_profiles "storage profiles" -run_test test_container_import "container import" -run_test test_storage_volume_attach "attaching storage volumes" -run_test test_storage_driver_btrfs "btrfs storage driver" -run_test test_storage_driver_ceph "ceph storage driver" -run_test test_storage_driver_cephfs "cephfs storage driver" -run_test test_resources "resources" -run_test test_kernel_limits "kernel limits" -run_test test_macaroon_auth "macaroon authentication" -run_test test_console "console" -run_test test_query "query" -run_test test_storage_local_volume_handling "storage local volume handling" -run_test test_backup_import "backup import" -run_test test_backup_export "backup export" -run_test test_backup_rename "backup rename" -run_test test_container_local_cross_pool_handling "container local cross pool handling" -run_test test_incremental_copy "incremental container copy" -run_test test_profiles_project_default "profiles in default project" -run_test test_profiles_project_images_profiles "profiles in project with images and profiles enabled" -run_test test_profiles_project_images "profiles in project with images enabled and profiles disabled" -run_test test_profiles_project_profiles "profiles in project with images disabled and profiles enabled" -run_test test_filtering "API filtering" +###run_test test_idmap "id mapping" +###run_test test_template "file templating" +###run_test test_pki "PKI mode" +###run_test test_devlxd "/dev/lxd" +###run_test test_fuidshift "fuidshift" +###run_test test_migration "migration" +###run_test test_fdleak "fd leak" +###run_test test_storage "storage" +###run_test test_storage_volume_snapshots "storage volume snapshots" +###run_test test_init_auto "lxd init auto" +###run_test test_init_interactive "lxd init interactive" +###run_test test_init_preseed "lxd init preseed" +###run_test test_storage_profiles "storage profiles" +###run_test test_container_import "container import" +###run_test test_storage_volume_attach "attaching storage volumes" +###run_test test_storage_driver_btrfs "btrfs storage driver" +###run_test test_storage_driver_ceph "ceph storage driver" +###run_test test_storage_driver_cephfs "cephfs storage driver" +###run_test test_resources "resources" +###run_test test_kernel_limits "kernel limits" +###run_test test_macaroon_auth "macaroon authentication" +###run_test test_console "console" +###run_test test_query "query" +###run_test test_storage_local_volume_handling "storage local volume handling" +###run_test test_backup_import "backup import" +###run_test test_backup_export "backup export" +###run_test test_backup_rename "backup rename" +###run_test test_container_local_cross_pool_handling "container local cross pool handling" +###run_test test_incremental_copy "incremental container copy" +###run_test test_profiles_project_default "profiles in default project" +###run_test test_profiles_project_images_profiles "profiles in project with images and profiles enabled" +###run_test test_profiles_project_images "profiles in project with images enabled and profiles disabled" +###run_test test_profiles_project_profiles "profiles in project with images disabled and profiles enabled" +###run_test test_filtering "API filtering" # shellcheck disable=SC2034 TEST_RESULT=success
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel