Skip to content

Commit

Permalink
Allow to upgrade from local directories (#264)
Browse files Browse the repository at this point in the history
- Bump installer
- Add test for upgrades from directory
- Add missing labels for autobump

Co-authored-by: Darren Shepherd <[email protected]>
Signed-off-by: Ettore Di Giacinto <[email protected]>

Co-authored-by: Darren Shepherd <[email protected]>
  • Loading branch information
mudler and ibuildthecloud authored Jun 24, 2021
1 parent 01d1cd5 commit ff5b2c7
Show file tree
Hide file tree
Showing 18 changed files with 114 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/build.yaml.gomplate
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ jobs:
needs: vbox-{{{$subset}}}-{{{ $flavor }}}
strategy:
matrix:
test: ["test-features", "test-smoke", "test-fallback", "test-recovery", "test-upgrades-images-signed", "test-upgrades-images-unsigned"]
test: ["test-features", "test-smoke", "test-fallback", "test-recovery", "test-upgrades-images-signed", "test-upgrades-images-unsigned", "test-upgrades-local"]
steps:
- name: Install Go
uses: actions/setup-go@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ jobs:
needs: vbox-squashfs-opensuse
strategy:
matrix:
test: ["test-features", "test-smoke", "test-fallback", "test-recovery", "test-upgrades-images-signed", "test-upgrades-images-unsigned"]
test: ["test-features", "test-smoke", "test-fallback", "test-recovery", "test-upgrades-images-signed", "test-upgrades-images-unsigned", "test-upgrades-local"]
steps:
- name: Install Go
uses: actions/setup-go@v2
Expand Down Expand Up @@ -407,7 +407,7 @@ jobs:
needs: vbox-nonsquashfs-opensuse
strategy:
matrix:
test: ["test-features", "test-smoke", "test-fallback", "test-recovery", "test-upgrades-images-signed", "test-upgrades-images-unsigned"]
test: ["test-features", "test-smoke", "test-fallback", "test-recovery", "test-upgrades-images-signed", "test-upgrades-images-unsigned", "test-upgrades-local"]
steps:
- name: Install Go
uses: actions/setup-go@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ jobs:
needs: vbox-squashfs-opensuse
strategy:
matrix:
test: ["test-features", "test-smoke", "test-fallback", "test-recovery", "test-upgrades-images-signed", "test-upgrades-images-unsigned"]
test: ["test-features", "test-smoke", "test-fallback", "test-recovery", "test-upgrades-images-signed", "test-upgrades-images-unsigned", "test-upgrades-local"]
steps:
- name: Install Go
uses: actions/setup-go@v2
Expand Down Expand Up @@ -379,7 +379,7 @@ jobs:
needs: vbox-nonsquashfs-opensuse
strategy:
matrix:
test: ["test-features", "test-smoke", "test-fallback", "test-recovery", "test-upgrades-images-signed", "test-upgrades-images-unsigned"]
test: ["test-features", "test-smoke", "test-fallback", "test-recovery", "test-upgrades-images-signed", "test-upgrades-images-unsigned", "test-upgrades-local"]
steps:
- name: Install Go
uses: actions/setup-go@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ jobs:
needs: vbox-squashfs-opensuse
strategy:
matrix:
test: ["test-features", "test-smoke", "test-fallback", "test-recovery", "test-upgrades-images-signed", "test-upgrades-images-unsigned"]
test: ["test-features", "test-smoke", "test-fallback", "test-recovery", "test-upgrades-images-signed", "test-upgrades-images-unsigned", "test-upgrades-local"]
steps:
- name: Install Go
uses: actions/setup-go@v2
Expand Down Expand Up @@ -385,7 +385,7 @@ jobs:
needs: vbox-nonsquashfs-opensuse
strategy:
matrix:
test: ["test-features", "test-smoke", "test-fallback", "test-recovery", "test-upgrades-images-signed", "test-upgrades-images-unsigned"]
test: ["test-features", "test-smoke", "test-fallback", "test-recovery", "test-upgrades-images-signed", "test-upgrades-images-unsigned", "test-upgrades-local"]
steps:
- name: Install Go
uses: actions/setup-go@v2
Expand Down
3 changes: 3 additions & 0 deletions make/Makefile.test
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ test-upgrades-images-signed: $(GINKGO)
test-upgrades-images-unsigned: $(GINKGO)
cd $(ROOT_DIR)/tests && $(GINKGO) $(GINKGO_ARGS) ./upgrades-images-unsigned

test-upgrades-local: $(GINKGO)
cd $(ROOT_DIR)/tests && $(GINKGO) $(GINKGO_ARGS) ./upgrades-local

test-smoke: $(GINKGO)
cd $(ROOT_DIR)/tests && $(GINKGO) $(GINKGO_ARGS) ./smoke

Expand Down
4 changes: 2 additions & 2 deletions packages/cos/collection.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
packages:
- name: "cos"
category: "system"
version: 0.5.3+5
version: "0.5.4"
brand_name: "cOS"
labels:
autobump.revdeps: "true"
autobump.revbump_related: "recovery/cos-img recovery/cos-squash"
- name: "cos"
category: "recovery"
version: 0.5.3+5
version: "0.5.4"
brand_name: "cOS recovery"
labels:
autobump.revdeps: "true"
Expand Down
2 changes: 1 addition & 1 deletion packages/installer/definition.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name: "installer"
category: "utils"
version: 0.7.4+2
version: "0.7.5"
21 changes: 14 additions & 7 deletions packages/installer/upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -159,22 +159,25 @@ upgrade() {
export TMPDIR=$temp_upgrade
export LUET_PRIVILEGED_EXTRACT=true

args=""
if [ -z "$VERIFY" ]; then
args="--enable-logfile --logfile /tmp/luet.log --plugin image-mtree-check"
fi
if [ -n "$CHANNEL_UPGRADES" ] && [ "$CHANNEL_UPGRADES" == true ]; then
if [ -z "$VERIFY" ]; then
args="--enable-logfile --logfile /tmp/luet.log --plugin luet-mtree"
fi
echo "Upgrading from release channel"
luet install $args --system-target $TARGET --system-engine memory -y $UPGRADE_IMAGE
luet cleanup
elif [ "$DIRECTORY" == true ]; then
echo "Upgrading from local folder: $UPGRADE_IMAGE"
rsync -axq --exclude='host' --exclude='mnt' --exclude='proc' --exclude='sys' --exclude='dev' --exclude='tmp' ${UPGRADE_IMAGE}/ $TARGET
else
args=""
if [ -z "$VERIFY" ]; then
args="--enable-logfile --logfile /tmp/luet.log --plugin luet-mtree"
fi
echo "Upgrading from container image: $UPGRADE_IMAGE"
luet util unpack $args $UPGRADE_IMAGE /usr/local/tmp/rootfs
rsync -aqzAX --exclude='mnt' --exclude='proc' --exclude='sys' --exclude='dev' --exclude='tmp' /usr/local/tmp/rootfs/ $TARGET
rm -rf /usr/local/tmp/rootfs
fi

chmod 755 $TARGET
SELinux_relabel

rm -rf $temp_upgrade
Expand Down Expand Up @@ -263,6 +266,10 @@ while [ "$#" -gt 0 ]; do
--docker-image)
CHANNEL_UPGRADES=false
;;
--directory)
CHANNEL_UPGRADES=false
DIRECTORY=true
;;
--recovery)
UPGRADE_RECOVERY=true
;;
Expand Down
2 changes: 1 addition & 1 deletion packages/recovery-img/definition.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "cos-img"
category: "recovery"
version: 0.5.3+5
version: "0.5.4"
brand_name: "cOS"
2 changes: 1 addition & 1 deletion packages/recovery-img/squash/definition.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name: "cos-squash"
category: "recovery"
version: "0.5.3+5"
version: "0.5.4"
2 changes: 1 addition & 1 deletion packages/toolchain/luet-mtree/definition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ labels:
github.repo: "luet-mtree"
github.owner: "rancher-sandbox"
autobump.revdeps: "true"
autobump.revbump_related: "system/cos"
autobump.revbump_related: "system/cos recovery/cos recovery/cos-img recovery/cos-squash"
2 changes: 1 addition & 1 deletion packages/toolchain/luet/definition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ labels:
github.repo: "luet"
github.owner: "mudler"
autobump.revdeps: "true"
autobump.revbump_related: "system/cos"
autobump.revbump_related: "system/cos recovery/cos recovery/cos-img recovery/cos-squash"
2 changes: 1 addition & 1 deletion packages/toolchain/yip/definition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ labels:
github.repo: "yip"
github.owner: "mudler"
autobump.revdeps: "true"
autobump.revbump_related: "system/cos"
autobump.revbump_related: "system/cos recovery/cos recovery/cos-img recovery/cos-squash"
3 changes: 3 additions & 0 deletions packages/toolchain/yq/definition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ arch: "amd64"
uri:
- https://github.com/mikefarah/yq
license: "MIT"
labels:
autobump.revdeps: "true"
autobump.revbump_related: "system/cos recovery/cos recovery/cos-img recovery/cos-squash"
2 changes: 1 addition & 1 deletion tests/upgrades-images-unsigned/tests_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ import (

func TestTests(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "cOS Upgrate test Suite - Images unsugned")
RunSpecs(t, "cOS Upgrate test Suite - Images unsigned")
}
5 changes: 3 additions & 2 deletions tests/upgrades-images-unsigned/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cos_test

import (
"fmt"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/rancher-sandbox/cOS/tests/sut"
Expand Down Expand Up @@ -41,14 +42,14 @@ var _ = Describe("cOS Upgrade tests - Images unsigned", func() {
})
Context("After install", func() {
When("images are not signed", func() {
It("upgrades to latest available (master) with --no-verify and reset", func() {
It("upgrades to latest available (master) with --no-verify", func() {
out, err := s.Command("source /etc/os-release && echo $VERSION")
Expect(err).ToNot(HaveOccurred())
Expect(out).ToNot(Equal(""))

version := out
out, err = s.Command("cos-upgrade --no-verify --docker-image quay.io/costoolkit/releases-opensuse:cos-system-0.5.1")
if err != nil{
if err != nil {
fmt.Fprintf(GinkgoWriter, "Error from cos-upgrade: %v\n", err)
}
Expect(err).ToNot(HaveOccurred())
Expand Down
13 changes: 13 additions & 0 deletions tests/upgrades-local/tests_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package cos_test

import (
"testing"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)

func TestTests(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "cOS Upgrate test Suite - local upgrades")
}
62 changes: 62 additions & 0 deletions tests/upgrades-local/upgrade_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package cos_test

import (
"fmt"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/rancher-sandbox/cOS/tests/sut"
)

var _ = Describe("cOS Upgrade tests - local upgrades", func() {
var s *sut.SUT

BeforeEach(func() {
s = sut.NewSUT()
s.EventuallyConnects(360)
})

Context("After install can upgrade and reset", func() {
When("specifying a directory to upgrade from", func() {
It("upgrades from the specified path", func() {
out, err := s.Command("source /etc/os-release && echo $VERSION")
Expect(err).ToNot(HaveOccurred())
Expect(out).ToNot(Equal(""))

version := out

out, err = s.Command("mkdir /run/update && luet util unpack quay.io/costoolkit/releases-opensuse:cos-system-0.5.1 /run/update")
if err != nil{
fmt.Fprintf(GinkgoWriter, "Error from luet util unpack: %v\n", err)
}
Expect(err).ToNot(HaveOccurred())
Expect(out).ToNot(Equal(""))

out, err = s.Command("cos-upgrade --no-verify --directory /run/update")
if err != nil{
fmt.Fprintf(GinkgoWriter, "Error from cos-upgrade: %v\n", err)
}
Expect(err).ToNot(HaveOccurred())
Expect(out).Should(ContainSubstring("Upgrade done, now you might want to reboot"))
Expect(out).Should(ContainSubstring("Upgrade target: active.img"))
By("rebooting")
s.Reboot()
Expect(s.BootFrom()).To(Equal(sut.Active))

out, err = s.Command("source /etc/os-release && echo $VERSION")
Expect(err).ToNot(HaveOccurred())
Expect(out).ToNot(Equal(""))
Expect(out).ToNot(Equal(version))
Expect(out).To(Equal("0.5.1\n"))

By("rollbacking state")
s.Reset()

out, err = s.Command("source /etc/os-release && echo $VERSION")
Expect(err).ToNot(HaveOccurred())
Expect(out).ToNot(Equal(""))
Expect(out).ToNot(Equal("0.5.1\n"))
Expect(out).To(Equal(version))
})
})
})
})

0 comments on commit ff5b2c7

Please sign in to comment.