Skip to content

Commit 90c9387

Browse files
jakecorrentibaude
authored andcommitted
Add functionality for podman machine set --rootful
Adds the functionality for `podman machine set --rootful` for AppleHV, QEMU, and HyperV. Abstracts the functionality out to a method of `MachineConfig`. WSL currently uses a function `SetRootful` that is provided by the `machine` package, which will eventually get changed when WSL moves to the refactored structure. Re-enables the "set rootful with docker sock change" test. [NO NEW TESTS NEEDED] Signed-off-by: Jake Correnti <[email protected]> Signed-off-by: Brent Baude <[email protected]>
1 parent f23b144 commit 90c9387

File tree

9 files changed

+166
-267
lines changed

9 files changed

+166
-267
lines changed

.cirrus.yml

Lines changed: 116 additions & 236 deletions
Original file line numberDiff line numberDiff line change
@@ -442,50 +442,50 @@ alt_build_task:
442442

443443

444444
# Confirm building the remote client, natively on a Mac OS-X VM.
445-
osx_alt_build_task:
446-
name: "OSX Cross"
447-
alias: osx_alt_build
448-
# Docs: ./contrib/cirrus/CIModes.md
449-
only_if: *no_rhel_release # RHEL never releases podman mac installer binary
450-
depends_on:
451-
- build
452-
persistent_worker: &mac_pw
453-
labels:
454-
os: darwin
455-
arch: arm64
456-
purpose: prod
457-
env: &mac_env
458-
CIRRUS_SHELL: "/bin/bash" # sh is the default
459-
CIRRUS_WORKING_DIR: "$HOME/ci/task-${CIRRUS_TASK_ID}" # Isolation: $HOME will be set to "ci" dir.
460-
# Prevent cache-pollution fron one task to the next.
461-
GOPATH: "$CIRRUS_WORKING_DIR/.go"
462-
GOCACHE: "$CIRRUS_WORKING_DIR/.go/cache"
463-
GOENV: "$CIRRUS_WORKING_DIR/.go/support"
464-
GOSRC: "$HOME/ci/task-${CIRRUS_TASK_ID}"
465-
# This host is/was shared with potentially many other CI tasks.
466-
# The previous task may have been canceled or aborted.
467-
prep_script: &mac_cleanup "contrib/cirrus/mac_cleanup.sh"
468-
lint_script:
469-
- make lint || true # TODO: Enable when code passes check
470-
basic_build_script:
471-
- make .install.ginkgo
472-
- make podman-remote
473-
- make podman-mac-helper
474-
build_amd64_script:
475-
- make podman-remote-release-darwin_amd64.zip
476-
build_arm64_script:
477-
- make podman-remote-release-darwin_arm64.zip
478-
build_pkginstaller_script:
479-
- cd contrib/pkginstaller
480-
- make ARCH=amd64 NO_CODESIGN=1 pkginstaller
481-
- make ARCH=aarch64 NO_CODESIGN=1 pkginstaller
482-
# Produce a new repo.tbz artifact for consumption by dependent tasks.
483-
repo_prep_script: *repo_prep
484-
repo_artifacts: *repo_artifacts
485-
# This host is/was shared with potentially many other CI tasks.
486-
# Ensure nothing is left running while waiting for the next task.
487-
always:
488-
task_cleanup_script: *mac_cleanup
445+
osx_alt_build_task:
446+
name: "OSX Cross"
447+
alias: osx_alt_build
448+
# Docs: ./contrib/cirrus/CIModes.md
449+
only_if: *no_rhel_release # RHEL never releases podman mac installer binary
450+
depends_on:
451+
- build
452+
persistent_worker: &mac_pw
453+
labels:
454+
os: darwin
455+
arch: arm64
456+
purpose: prod
457+
env: &mac_env
458+
CIRRUS_SHELL: "/bin/bash" # sh is the default
459+
CIRRUS_WORKING_DIR: "$HOME/ci/task-${CIRRUS_TASK_ID}" # Isolation: $HOME will be set to "ci" dir.
460+
# Prevent cache-pollution fron one task to the next.
461+
GOPATH: "$CIRRUS_WORKING_DIR/.go"
462+
GOCACHE: "$CIRRUS_WORKING_DIR/.go/cache"
463+
GOENV: "$CIRRUS_WORKING_DIR/.go/support"
464+
GOSRC: "$HOME/ci/task-${CIRRUS_TASK_ID}"
465+
# This host is/was shared with potentially many other CI tasks.
466+
# The previous task may have been canceled or aborted.
467+
prep_script: &mac_cleanup "contrib/cirrus/mac_cleanup.sh"
468+
lint_script:
469+
- make lint || true # TODO: Enable when code passes check
470+
basic_build_script:
471+
- make .install.ginkgo
472+
- make podman-remote
473+
- make podman-mac-helper
474+
build_amd64_script:
475+
- make podman-remote-release-darwin_amd64.zip
476+
build_arm64_script:
477+
- make podman-remote-release-darwin_arm64.zip
478+
build_pkginstaller_script:
479+
- cd contrib/pkginstaller
480+
- make ARCH=amd64 NO_CODESIGN=1 pkginstaller
481+
- make ARCH=aarch64 NO_CODESIGN=1 pkginstaller
482+
# Produce a new repo.tbz artifact for consumption by dependent tasks.
483+
repo_prep_script: *repo_prep
484+
repo_artifacts: *repo_artifacts
485+
# This host is/was shared with potentially many other CI tasks.
486+
# Ensure nothing is left running while waiting for the next task.
487+
always:
488+
task_cleanup_script: *mac_cleanup
489489

490490
# Build freebsd release natively on a FreeBSD VM.
491491
#freebsd_alt_build_task:
@@ -774,197 +774,77 @@ podman_machine_aarch64_task:
774774
always: *int_logs_artifacts
775775

776776

777-
<<<<<<< HEAD
778-
podman_machine_windows_task:
779-
name: *std_name_fmt
780-
alias: podman_machine_windows
781-
# Only run for non-docs/copr PRs and non-release branch builds
782-
# and never for tags. Docs: ./contrib/cirrus/CIModes.md
783-
only_if: *machine_cron_not_tag_build_docs
784-
depends_on:
785-
- alt_build
786-
- build
787-
- win_installer
788-
- local_integration_test
789-
- remote_integration_test
790-
- container_integration_test
791-
- rootless_integration_test
792-
ec2_instance:
793-
<<: *windows
794-
type: m5zn.metal
795-
platform: windows
796-
env: *winenv
797-
matrix:
798-
- env:
799-
TEST_FLAVOR: "machine-wsl"
800-
- env:
801-
TEST_FLAVOR: "machine-hyperv"
802-
clone_script: *winclone
803-
main_script: ".\\repo\\contrib\\cirrus\\win-podman-machine-main.ps1"
804-
805-
806-
podman_machine_mac_task:
807-
name: *std_name_fmt
808-
alias: podman_machine_mac
809-
only_if: *machine_cron_not_tag_build_docs
810-
depends_on:
811-
- osx_alt_build
812-
- local_integration_test
813-
- remote_integration_test
814-
- container_integration_test
815-
- rootless_integration_test
816-
persistent_worker: *mac_pw
817-
env:
818-
<<: *mac_env
819-
# Consumed by podman-machine ginkgo tests
820-
CONTAINERS_MACHINE_PROVIDER: "applehv"
821-
# TODO: Should not require a special image, for now it does.
822-
# Simply remove the line below when a mac image is GA.
823-
MACHINE_IMAGE: "https://fedorapeople.org/groups/podman/testing/applehv/arm64/fedora-coreos-38.20230925.dev.0-applehv.aarch64.raw.gz"
824-
# Values necessary to populate std_name_fmt alias
825-
TEST_FLAVOR: "machine-mac"
826-
DISTRO_NV: "darwin"
827-
PRIV_NAME: "rootless" # intended use-case
828-
clone_script: # artifacts from osx_alt_build_task
829-
- mkdir -p $CIRRUS_WORKING_DIR
830-
- cd $CIRRUS_WORKING_DIR
831-
- $ARTCURL/OSX%20Cross/repo/repo.tbz
832-
- tar xjf repo.tbz
833-
# This host is/was shared with potentially many other CI tasks.
834-
# The previous task may have been canceled or aborted.
835-
prep_script: *mac_cleanup
836-
setup_script: "contrib/cirrus/mac_setup.sh"
837-
env_script: "contrib/cirrus/mac_env.sh"
838-
# TODO: Timeout bumped b/c initial image download (~5min) and VM
839-
# resize (~2min) causes test-timeout (90s default). Should
840-
# tests deal with this internally?
841-
smoke_test_script:
842-
- MACHINE_TEST_TIMEOUT=500 make localmachine FOCUS_FILE="basic_test.go"
843-
test_script:
844-
- make localmachine
845-
# This host is/was shared with potentially many other CI tasks.
846-
# Ensure nothing is left running while waiting for the next task.
847-
always:
848-
task_cleanup_script: *mac_cleanup
849-
=======
850-
#podman_machine_windows_task:
851-
# name: *std_name_fmt
852-
# alias: podman_machine_windows
853-
# # Only run for non-docs/copr PRs and non-release branch builds
854-
# # and never for tags. Docs: ./contrib/cirrus/CIModes.md
855-
# only_if: *not_tag_branch_build_docs
856-
# depends_on:
857-
# - alt_build
858-
# - build
859-
# - win_installer
860-
# - local_integration_test
861-
# - remote_integration_test
862-
# - container_integration_test
863-
# - rootless_integration_test
864-
# ec2_instance:
865-
# <<: *windows
866-
# type: m5zn.metal
867-
# platform: windows
868-
# env: *winenv
869-
# matrix:
870-
# - env:
871-
# TEST_FLAVOR: "machine-wsl"
872-
# - env:
873-
# TEST_FLAVOR: "machine-hyperv"
874-
# clone_script: *winclone
875-
# main_script: ".\\repo\\contrib\\cirrus\\win-podman-machine-main.ps1"
876-
877-
878-
<<<<<<< HEAD
879-
#podman_machine_mac_task:
880-
# name: *std_name_fmt
881-
# alias: podman_machine_mac
882-
# only_if: *not_tag_branch_build_docs
883-
# depends_on:
884-
# - osx_alt_build
885-
# - local_integration_test
886-
# - remote_integration_test
887-
# - container_integration_test
888-
# - rootless_integration_test
889-
# persistent_worker: *mac_pw
890-
# env:
891-
# <<: *mac_env
892-
# # Consumed by podman-machine ginkgo tests
893-
# CONTAINERS_MACHINE_PROVIDER: "applehv"
894-
# # TODO: Should not require a special image, for now it does.
895-
# # Simply remove the line below when a mac image is GA.
896-
# MACHINE_IMAGE: "https://fedorapeople.org/groups/podman/testing/applehv/arm64/fedora-coreos-38.20230925.dev.0-applehv.aarch64.raw.gz"
897-
# # Values necessary to populate std_name_fmt alias
898-
# TEST_FLAVOR: "machine-mac"
899-
# DISTRO_NV: "darwin"
900-
# PRIV_NAME: "rootless" # intended use-case
901-
# clone_script: # artifacts from osx_alt_build_task
902-
# - mkdir -p $CIRRUS_WORKING_DIR
903-
# - cd $CIRRUS_WORKING_DIR
904-
# - $ARTCURL/OSX%20Cross/repo/repo.tbz
905-
# - tar xjf repo.tbz
906-
# # This host is/was shared with potentially many other CI tasks.
907-
# # The previous task may have been canceled or aborted.
908-
# prep_script: *mac_cleanup
909-
# setup_script: "contrib/cirrus/mac_setup.sh"
910-
# env_script: "contrib/cirrus/mac_env.sh"
911-
# # TODO: Timeout bumped b/c initial image download (~5min) and VM
912-
# # resize (~2min) causes test-timeout (90s default). Should
913-
# # tests deal with this internally?
914-
# smoke_test_script:
915-
# - MACHINE_TEST_TIMEOUT=500 make localmachine FOCUS_FILE="basic_test.go"
916-
# test_script:
917-
# - make localmachine
918-
# # This host is/was shared with potentially many other CI tasks.
919-
# # Ensure nothing is left running while waiting for the next task.
920-
# always:
921-
# task_cleanup_script: *mac_cleanup
922-
>>>>>>> 0ff0e1dfe8 ([CI:MACHINE]Podman5 QEMU refactor)
923-
=======
924-
podman_machine_mac_task:
925-
name: *std_name_fmt
926-
alias: podman_machine_mac
927-
only_if: *not_tag_branch_build_docs
928-
depends_on:
929-
- osx_alt_build
930-
- local_integration_test
931-
- remote_integration_test
932-
- container_integration_test
933-
- rootless_integration_test
934-
persistent_worker: *mac_pw
935-
env:
936-
<<: *mac_env
937-
# Consumed by podman-machine ginkgo tests
938-
CONTAINERS_MACHINE_PROVIDER: "applehv"
939-
# TODO: Should not require a special image, for now it does.
940-
# Simply remove the line below when a mac image is GA.
941-
# MACHINE_IMAGE: "https://fedorapeople.org/groups/podman/testing/applehv/arm64/fedora-coreos-38.20230925.dev.0-applehv.aarch64.raw.gz"
942-
# Values necessary to populate std_name_fmt alias
943-
TEST_FLAVOR: "machine-mac"
944-
DISTRO_NV: "darwin"
945-
PRIV_NAME: "rootless" # intended use-case
946-
clone_script: # artifacts from osx_alt_build_task
947-
- mkdir -p $CIRRUS_WORKING_DIR
948-
- cd $CIRRUS_WORKING_DIR
949-
- $ARTCURL/OSX%20Cross/repo/repo.tbz
950-
- tar xjf repo.tbz
951-
# This host is/was shared with potentially many other CI tasks.
952-
# The previous task may have been canceled or aborted.
953-
prep_script: *mac_cleanup
954-
setup_script: "contrib/cirrus/mac_setup.sh"
955-
env_script: "contrib/cirrus/mac_env.sh"
956-
# TODO: Timeout bumped b/c initial image download (~5min) and VM
957-
# resize (~2min) causes test-timeout (90s default). Should
958-
# tests deal with this internally?
959-
smoke_test_script:
960-
- MACHINE_TEST_TIMEOUT=500 make localmachine FOCUS_FILE="basic_test.go"
961-
test_script:
962-
- make localmachine
963-
# This host is/was shared with potentially many other CI tasks.
964-
# Ensure nothing is left running while waiting for the next task.
965-
always:
966-
task_cleanup_script: *mac_cleanup
967-
>>>>>>> 09f119d4a6 (Podman Machine AppleHV CI fixes)
777+
#podman_machine_windows_task:
778+
# name: *std_name_fmt
779+
# alias: podman_machine_windows
780+
# # Only run for non-docs/copr PRs and non-release branch builds
781+
# # and never for tags. Docs: ./contrib/cirrus/CIModes.md
782+
# only_if: *not_tag_branch_build_docs
783+
# depends_on:
784+
# - alt_build
785+
# - build
786+
# - win_installer
787+
# - local_integration_test
788+
# - remote_integration_test
789+
# - container_integration_test
790+
# - rootless_integration_test
791+
# ec2_instance:
792+
# <<: *windows
793+
# type: m5zn.metal
794+
# platform: windows
795+
# env: *winenv
796+
# matrix:
797+
# - env:
798+
# TEST_FLAVOR: "machine-wsl"
799+
# - env:
800+
# TEST_FLAVOR: "machine-hyperv"
801+
# clone_script: *winclone
802+
# main_script: ".\\repo\\contrib\\cirrus\\win-podman-machine-main.ps1"
803+
804+
805+
#podman_machine_mac_task:
806+
# name: *std_name_fmt
807+
# alias: podman_machine_mac
808+
# only_if: *not_tag_branch_build_docs
809+
# depends_on:
810+
# - osx_alt_build
811+
# - local_integration_test
812+
# - remote_integration_test
813+
# - container_integration_test
814+
# - rootless_integration_test
815+
# persistent_worker: *mac_pw
816+
# env:
817+
# <<: *mac_env
818+
# # Consumed by podman-machine ginkgo tests
819+
# CONTAINERS_MACHINE_PROVIDER: "applehv"
820+
# # TODO: Should not require a special image, for now it does.
821+
# # Simply remove the line below when a mac image is GA.
822+
# # MACHINE_IMAGE: "https://fedorapeople.org/groups/podman/testing/applehv/arm64/fedora-coreos-38.20230925.dev.0-applehv.aarch64.raw.gz"
823+
# # Values necessary to populate std_name_fmt alias
824+
# TEST_FLAVOR: "machine-mac"
825+
# DISTRO_NV: "darwin"
826+
# PRIV_NAME: "rootless" # intended use-case
827+
# clone_script: # artifacts from osx_alt_build_task
828+
# - mkdir -p $CIRRUS_WORKING_DIR
829+
# - cd $CIRRUS_WORKING_DIR
830+
# - $ARTCURL/OSX%20Cross/repo/repo.tbz
831+
# - tar xjf repo.tbz
832+
# # This host is/was shared with potentially many other CI tasks.
833+
# # The previous task may have been canceled or aborted.
834+
# prep_script: *mac_cleanup
835+
# setup_script: "contrib/cirrus/mac_setup.sh"
836+
# env_script: "contrib/cirrus/mac_env.sh"
837+
# # TODO: Timeout bumped b/c initial image download (~5min) and VM
838+
# # resize (~2min) causes test-timeout (90s default). Should
839+
# # tests deal with this internally?
840+
# smoke_test_script:
841+
# - MACHINE_TEST_TIMEOUT=500 make localmachine FOCUS_FILE="basic_test.go"
842+
# test_script:
843+
# - make localmachine
844+
# # This host is/was shared with potentially many other CI tasks.
845+
# # Ensure nothing is left running while waiting for the next task.
846+
# always:
847+
# task_cleanup_script: *mac_cleanup
968848

969849
# Always run subsequent to integration tests. While parallelism is lost
970850
# with runtime, debugging system-test failures can be more challenging
@@ -1184,7 +1064,7 @@ success_task:
11841064
- podman_machine_aarch64
11851065
#- podman_machine_windows
11861066
# TODO: Issue #20853; Tests mostly fail then timeout after an hour.
1187-
- podman_machine_mac
1067+
# - podman_machine_mac
11881068
- local_system_test
11891069
- local_system_test_aarch64
11901070
- remote_system_test

cmd/podman/machine/set.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ func setMachine(cmd *cobra.Command, args []string) error {
9292
err error
9393
newCPUs, newMemory *uint64
9494
newDiskSize *strongunits.GiB
95+
newRootful *bool
9596
)
9697

9798
vmName := defaultMachineName
@@ -110,7 +111,7 @@ func setMachine(cmd *cobra.Command, args []string) error {
110111
}
111112

112113
if cmd.Flags().Changed("rootful") {
113-
mc.HostUser.Rootful = setFlags.Rootful
114+
newRootful = &setFlags.Rootful
114115
}
115116
if cmd.Flags().Changed("cpus") {
116117
mc.Resources.CPUs = setFlags.CPUs
@@ -139,7 +140,7 @@ func setMachine(cmd *cobra.Command, args []string) error {
139140

140141
// At this point, we have the known changed information, etc
141142
// Walk through changes to the providers if they need them
142-
if err := provider.SetProviderAttrs(mc, newCPUs, newMemory, newDiskSize); err != nil {
143+
if err := provider.SetProviderAttrs(mc, newCPUs, newMemory, newDiskSize, newRootful); err != nil {
143144
return err
144145
}
145146

0 commit comments

Comments
 (0)