diff options
-rw-r--r-- | .github/workflows/check_cirrus_cron.yml | 8 | ||||
-rw-r--r-- | .github/workflows/issue-labeler.yml | 2 | ||||
-rw-r--r-- | .github/workflows/multi-arch-build.yaml | 19 | ||||
-rw-r--r-- | .github/workflows/pr-title.yml | 2 | ||||
-rw-r--r-- | .github/workflows/stale.yml | 8 | ||||
-rw-r--r-- | docs/source/markdown/podman-image-unmount.1.md | 10 | ||||
-rw-r--r-- | docs/source/markdown/podman-network-prune.1.md | 5 | ||||
-rw-r--r-- | docs/source/markdown/podman-pod-pause.1.md | 6 | ||||
-rw-r--r-- | docs/source/markdown/podman-unmount.1.md | 9 | ||||
-rw-r--r-- | docs/source/markdown/podman-unpause.1.md | 1 | ||||
-rw-r--r-- | docs/source/markdown/podman-volume-ls.1.md | 2 | ||||
-rw-r--r-- | docs/source/markdown/podman-volume-unmount.1.md | 7 | ||||
-rw-r--r-- | pkg/machine/qemu/config.go | 11 | ||||
-rw-r--r-- | pkg/machine/qemu/machine.go | 87 |
14 files changed, 153 insertions, 24 deletions
diff --git a/.github/workflows/check_cirrus_cron.yml b/.github/workflows/check_cirrus_cron.yml index 5c206ae2f..5704b0b9d 100644 --- a/.github/workflows/check_cirrus_cron.yml +++ b/.github/workflows/check_cirrus_cron.yml @@ -29,7 +29,7 @@ jobs: cron_failures: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@629c2de402a417ea7690ca6ce3f33229e27606a5 # v2 with: persist-credentials: false @@ -61,7 +61,7 @@ jobs: - if: steps.cron.outputs.failures > 0 name: Send failure notification e-mail # Ref: https://github.com/dawidd6/action-send-mail - uses: dawidd6/action-send-mail@v2.2.2 + uses: dawidd6/action-send-mail@a80d851dc950256421f1d1d735a2dc1ef314ac8f # v2.2.2 with: server_address: ${{secrets.ACTION_MAIL_SERVER}} server_port: 465 @@ -73,14 +73,14 @@ jobs: body: file://./artifacts/email_body.txt - if: always() - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@82c141cc518b40d92cc801eee768e7aafc9c2fa2 # v2 with: name: ${{ github.job }}_artifacts path: artifacts/* - if: failure() name: Send error notification e-mail - uses: dawidd6/action-send-mail@v2.2.2 + uses: dawidd6/action-send-mail@a80d851dc950256421f1d1d735a2dc1ef314ac8f # v2.2.2 with: server_address: ${{secrets.ACTION_MAIL_SERVER}} server_port: 465 diff --git a/.github/workflows/issue-labeler.yml b/.github/workflows/issue-labeler.yml index ee9785d23..18fff7f7c 100644 --- a/.github/workflows/issue-labeler.yml +++ b/.github/workflows/issue-labeler.yml @@ -7,7 +7,7 @@ jobs: triage: runs-on: ubuntu-latest steps: - - uses: github/issue-labeler@v2.0 + - uses: github/issue-labeler@3ae0e4623c1fda729347ae0d8f1c2e52302ef4c6 # v2.0 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" configuration-path: .github/issue-labeler.yml diff --git a/.github/workflows/multi-arch-build.yaml b/.github/workflows/multi-arch-build.yaml index fff617865..1dc485d71 100644 --- a/.github/workflows/multi-arch-build.yaml +++ b/.github/workflows/multi-arch-build.yaml @@ -18,6 +18,9 @@ on: # allows to run this workflow manually from the Actions tab workflow_dispatch: +permissions: + contents: read + jobs: multi: name: multi-arch image build @@ -50,19 +53,19 @@ jobs: - 5000:5000 steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@629c2de402a417ea7690ca6ce3f33229e27606a5 # v2 - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@27d0a4f181a40b142cce983c5393082c365d1480 # v1 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@94ab11c41e45d028884a99163086648e898eed25 # v1 with: driver-opts: network=host install: true - name: Build and locally push image - uses: docker/build-push-action@v2 + uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a # v2 with: context: contrib/${{ env.REPONAME }}image/${{ matrix.source }} file: ./contrib/${{ env.REPONAME }}image/${{ matrix.source }}/Dockerfile @@ -162,7 +165,7 @@ jobs: # Push to $REPONAME_QUAY_REGISTRY for stable, testing. and upstream - name: Login to ${{ env.REPONAME_QUAY_REGISTRY }} - uses: docker/login-action@v1 + uses: docker/login-action@dd4fa0671be5250ee6f50aedf4cb05514abda2c7 # v1 if: steps.reponame_reg.outputs.push == 'true' with: registry: ${{ env.REPONAME_QUAY_REGISTRY }} @@ -172,7 +175,7 @@ jobs: password: ${{ secrets.REPONAME_QUAY_PASSWORD }} - name: Push images to ${{ steps.reponame_reg.outputs.fqin }} - uses: docker/build-push-action@v2 + uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a # v2 if: steps.reponame_reg.outputs.push == 'true' with: cache-from: type=registry,ref=localhost:5000/${{ env.REPONAME }}/${{ matrix.source }} @@ -188,7 +191,7 @@ jobs: # Push to $CONTAINERS_QUAY_REGISTRY only stable - name: Login to ${{ env.CONTAINERS_QUAY_REGISTRY }} if: steps.containers_reg.outputs.push == 'true' - uses: docker/login-action@v1 + uses: docker/login-action@dd4fa0671be5250ee6f50aedf4cb05514abda2c7 # v1 with: registry: ${{ env.CONTAINERS_QUAY_REGISTRY}} username: ${{ secrets.CONTAINERS_QUAY_USERNAME }} @@ -196,7 +199,7 @@ jobs: - name: Push images to ${{ steps.containers_reg.outputs.fqin }} if: steps.containers_reg.outputs.push == 'true' - uses: docker/build-push-action@v2 + uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a # v2 with: cache-from: type=registry,ref=localhost:5000/${{ env.REPONAME }}/${{ matrix.source }} cache-to: type=inline diff --git a/.github/workflows/pr-title.yml b/.github/workflows/pr-title.yml index e00b8465c..2b57392ce 100644 --- a/.github/workflows/pr-title.yml +++ b/.github/workflows/pr-title.yml @@ -11,7 +11,7 @@ jobs: update_pr: runs-on: ubuntu-latest steps: - - uses: tzkhan/pr-update-action@v2 + - uses: tzkhan/pr-update-action@bbd4c9395df8a9c4ef075b8b7fe29f2ca76cdca9 # v2 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" base-branch-regex: '^(?!master).*$' diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index d6f92873e..b340c9238 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -7,13 +7,19 @@ on: schedule: - cron: "0 0 * * *" +permissions: + contents: read + jobs: stale: + permissions: + issues: write # for actions/stale to close stale issues + pull-requests: write # for actions/stale to close stale PRs runs-on: ubuntu-latest steps: - - uses: actions/stale@v3 + - uses: actions/stale@98ed4cb500039dbcccf4bd9bedada4d0187f2757 # v3 with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-issue-message: 'A friendly reminder that this issue had no activity for 30 days.' diff --git a/docs/source/markdown/podman-image-unmount.1.md b/docs/source/markdown/podman-image-unmount.1.md index 71ec5488f..f2d75f15f 100644 --- a/docs/source/markdown/podman-image-unmount.1.md +++ b/docs/source/markdown/podman-image-unmount.1.md @@ -33,11 +33,19 @@ as the mount point could be removed without their knowledge. ## EXAMPLE +Unmount image with a given ID +``` podman image unmount imageID +``` +Unmount multiple images wit given IDs +``` podman image unmount imageID1 imageID2 imageID3 +``` +Unmount all images +``` podman image unmount --all - +``` ## SEE ALSO **[podman(1)](podman.1.md)**, **[podman-image-mount(1)](podman-image-mount.1.md)**, **[podman-container-mount(1)](podman-container-mount.1.md)** diff --git a/docs/source/markdown/podman-network-prune.1.md b/docs/source/markdown/podman-network-prune.1.md index 2c8cf13db..b0a81646d 100644 --- a/docs/source/markdown/podman-network-prune.1.md +++ b/docs/source/markdown/podman-network-prune.1.md @@ -36,11 +36,14 @@ Do not prompt for confirmation ## EXAMPLE Prune networks - ``` podman network prune ``` +Prune all networks created before 2h +``` +podman network prune --filter until=2h +``` ## SEE ALSO **[podman(1)](podman.1.md)**, **[podman-network(1)](podman-network.1.md)**, **[podman-network-rm(1)](podman-network-rm.1.md)** diff --git a/docs/source/markdown/podman-pod-pause.1.md b/docs/source/markdown/podman-pod-pause.1.md index 1f29cb2ed..2d2fac00d 100644 --- a/docs/source/markdown/podman-pod-pause.1.md +++ b/docs/source/markdown/podman-pod-pause.1.md @@ -21,9 +21,15 @@ Instead of providing the pod name or ID, pause the last created pod. (This optio ## EXAMPLE +Pause a pod with a given name +``` podman pod pause mywebserverpod +``` +Pause a pod with a given ID +``` podman pod pause 860a4b23 +``` ## SEE ALSO **[podman(1)](podman.1.md)**, **[podman-pod(1)](podman-pod.1.md)**, **[podman-pod-unpause(1)](podman-pod-unpause.1.md)**, **[podman-pause(1)](podman-pause.1.md)** diff --git a/docs/source/markdown/podman-unmount.1.md b/docs/source/markdown/podman-unmount.1.md index 692b1e495..3f45e8114 100644 --- a/docs/source/markdown/podman-unmount.1.md +++ b/docs/source/markdown/podman-unmount.1.md @@ -47,11 +47,20 @@ started container could be from either of those methods. (This option is not ava ## EXAMPLE +Unmount container with a given ID +``` podman container unmount containerID +``` +Unmount multiple containers with given IDs +``` podman unmount containerID1 containerID2 containerID3 +``` +Unmount all containers +``` podman unmount --all +``` ## SEE ALSO **[podman(1)](podman.1.md)**, **[podman-container-mount(1)](podman-container-mount.1.md)**, **[podman-image-mount(1)](podman-image-mount.1.md)** diff --git a/docs/source/markdown/podman-unpause.1.md b/docs/source/markdown/podman-unpause.1.md index 0eb1f1bb8..4f66bf393 100644 --- a/docs/source/markdown/podman-unpause.1.md +++ b/docs/source/markdown/podman-unpause.1.md @@ -25,7 +25,6 @@ podman unpause mywebserver ``` Unpause a container by a partial container ID. - ``` podman unpause 860a4b23 ``` diff --git a/docs/source/markdown/podman-volume-ls.1.md b/docs/source/markdown/podman-volume-ls.1.md index 4f5ce6888..4a3489425 100644 --- a/docs/source/markdown/podman-volume-ls.1.md +++ b/docs/source/markdown/podman-volume-ls.1.md @@ -26,7 +26,7 @@ Volumes can be filtered by the following attributes: | name | [Name] Volume name (accepts regex) | | opt | Matches a storage driver options | | scope | Filters volume by scope | -| until | Only remove volumes created before given timestamp | +| until | Only remove volumes created before given timestamp | #### **--format**=*format* diff --git a/docs/source/markdown/podman-volume-unmount.1.md b/docs/source/markdown/podman-volume-unmount.1.md index e2fcd425f..c489af6c9 100644 --- a/docs/source/markdown/podman-volume-unmount.1.md +++ b/docs/source/markdown/podman-volume-unmount.1.md @@ -19,9 +19,14 @@ counter reaches zero indicating no other processes are using the mount. ## EXAMPLE +Unmount volume with a given ID +``` podman volume unmount volumeID +``` +Unmount multiple volumes with given IDs +``` podman volume unmount volumeID1 volumeID2 volumeID3 - +``` ## SEE ALSO **[podman(1)](podman.1.md)**, **[podman-volume(1)](podman-volume.1.md)**, **[podman-volume-mount(1)](podman-volume-mount.1.md)** diff --git a/pkg/machine/qemu/config.go b/pkg/machine/qemu/config.go index 408b33a33..05a1d74d3 100644 --- a/pkg/machine/qemu/config.go +++ b/pkg/machine/qemu/config.go @@ -49,7 +49,7 @@ type MachineVMV1 struct { // SSH port for user networking Port int // QMPMonitor is the qemu monitor object for sending commands - QMPMonitor Monitor + QMPMonitor Monitorv1 // RemoteUsername of the vm user RemoteUsername string // Whether this machine should run in a rootful or rootless manner @@ -134,6 +134,15 @@ type Mount struct { ReadOnly bool } +type Monitorv1 struct { + // Address portion of the qmp monitor (/tmp/tmp.sock) + Address string + // Network portion of the qmp monitor (unix) + Network string + // Timeout in seconds for qmp monitor transactions + Timeout time.Duration +} + type Monitor struct { // Address portion of the qmp monitor (/tmp/tmp.sock) Address MachineFile diff --git a/pkg/machine/qemu/machine.go b/pkg/machine/qemu/machine.go index ac8e7d75c..07155bbcf 100644 --- a/pkg/machine/qemu/machine.go +++ b/pkg/machine/qemu/machine.go @@ -131,6 +131,75 @@ func (p *Provider) NewMachine(opts machine.InitOptions) (machine.VM, error) { return vm, nil } +// migrateVM takes the old configuration structure and migrates it +// to the new structure and writes it to the filesystem +func migrateVM(configPath string, config []byte, vm *MachineVM) error { + fmt.Printf("Migrating machine %q\n", vm.Name) + var old MachineVMV1 + err := json.Unmarshal(config, &old) + if err != nil { + return err + } + // Looks like we loaded the older structure; now we need to migrate + // from the old structure to the new structure + _, pidFile, err := vm.getSocketandPid() + if err != nil { + return err + } + + pidFilePath := MachineFile{Path: pidFile} + qmpMonitor := Monitor{ + Address: MachineFile{Path: old.QMPMonitor.Address}, + Network: old.QMPMonitor.Network, + Timeout: old.QMPMonitor.Timeout, + } + socketPath, err := getRuntimeDir() + if err != nil { + return err + } + virtualSocketPath := filepath.Join(socketPath, "podman", vm.Name+"_ready.sock") + readySocket := MachineFile{Path: virtualSocketPath} + + vm.HostUser = HostUser{} + vm.ImageConfig = ImageConfig{} + vm.ResourceConfig = ResourceConfig{} + vm.SSHConfig = SSHConfig{} + + vm.CPUs = old.CPUs + vm.CmdLine = old.CmdLine + vm.DiskSize = old.DiskSize + vm.IdentityPath = old.IdentityPath + vm.IgnitionFilePath = old.IgnitionFilePath + vm.ImagePath = old.ImagePath + vm.ImageStream = old.ImageStream + vm.Memory = old.Memory + vm.Mounts = old.Mounts + vm.Name = old.Name + vm.PidFilePath = pidFilePath + vm.Port = old.Port + vm.QMPMonitor = qmpMonitor + vm.ReadySocket = readySocket + vm.RemoteUsername = old.RemoteUsername + vm.Rootful = old.Rootful + vm.UID = old.UID + + // Backup the original config file + if err := os.Rename(configPath, configPath+".orig"); err != nil { + return err + } + // Write the config file + if err := vm.writeConfig(); err != nil { + // If the config file fails to be written, put the origina + // config file back before erroring + if renameError := os.Rename(configPath+".orig", configPath); renameError != nil { + logrus.Warn(renameError) + } + return err + } + // Remove the backup file + return os.Remove(configPath + ".orig") +} + // LoadByName reads a json file that describes a known qemu vm // and returns a vm instance func (p *Provider) LoadVMByName(name string) (machine.VM, error) { @@ -140,7 +209,8 @@ func (p *Provider) LoadVMByName(name string) (machine.VM, error) { if err != nil { return nil, err } - b, err := ioutil.ReadFile(filepath.Join(vmConfigDir, name+".json")) + path := filepath.Join(vmConfigDir, name+".json") + b, err := ioutil.ReadFile(path) if os.IsNotExist(err) { return nil, errors.Wrap(machine.ErrNoSuchVM, name) } @@ -148,7 +218,13 @@ func (p *Provider) LoadVMByName(name string) (machine.VM, error) { return nil, err } err = json.Unmarshal(b, vm) - + if err != nil { + migrateErr := migrateVM(path, b, vm) + if migrateErr != nil { + return nil, migrateErr + } + err = migrateErr + } // It is here for providing the ability to propagate // proxy settings (e.g. HTTP_PROXY and others) on a start // and avoid a need of re-creating/re-initiating a VM @@ -911,7 +987,12 @@ func GetVMInfos() ([]*machine.ListResponse, error) { } err = json.Unmarshal(b, vm) if err != nil { - return err + // Checking if the file did not unmarshal because it is using + // the deprecated config file format. + migrateErr := migrateVM(fullPath, b, vm) + if migrateErr != nil { + return migrateErr + } } listEntry := new(machine.ListResponse) |