Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: update disk images #1179

Merged
merged 6 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ func (c colimaApp) Active() bool {
func (c *colimaApp) Update() error {
ctx := context.Background()
if !c.guest.Running(ctx) {
return fmt.Errorf("%s is not running", config.CurrentProfile().DisplayName)
return fmt.Errorf("runtime cannot be updated, %s is not running", config.CurrentProfile().DisplayName)
}

runtime, err := c.currentRuntime(ctx)
Expand All @@ -471,7 +471,23 @@ func (c *colimaApp) Update() error {
return err
}

return container.Update(ctx)
oldVersion := container.Version(ctx)

updated, err := container.Update(ctx)
if err != nil {
return err
}

if updated {
fmt.Println()
fmt.Println("Previous")
fmt.Println(oldVersion)
fmt.Println()
fmt.Println("Current")
fmt.Println(container.Version(ctx))
}

return nil
}

func generateSSHConfig(modifySSHConfig bool) error {
Expand Down
2 changes: 1 addition & 1 deletion embedded/defaults/colima.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ kubernetes:
# Kubernetes version to use.
# This needs to exactly match a k3s version https://github.com/k3s-io/k3s/releases
# Default: latest stable release
version: v1.30.2+k3s1
version: v1.31.2+k3s1

# Additional args to pass to k3s https://docs.k3s.io/cli/server
# Default: traefik is disabled
Expand Down
16 changes: 8 additions & 8 deletions embedded/images/images.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
arm64 none https://github.com/abiosoft/colima-core/releases/download/v0.7.6/ubuntu-24.04-minimal-cloudimg-arm64-none.qcow2 7e63afa385d4e4fd760e35367c61c521efaedf930ac93830e68beb635c2691d266495052d99fc76c56c8c5134a3c31c26b20797b6d6d96f426628aa191543ad3 ubuntu-24.04-minimal-cloudimg-arm64-none.qcow2
arm64 docker https://github.com/abiosoft/colima-core/releases/download/v0.7.6/ubuntu-24.04-minimal-cloudimg-arm64-docker.qcow2 c6d253678b449a6c17b44ca2dfa73ca9f3375c2d8c8f125bf32c74e0aaaa0534eb67c8c0d2bf5744344135b774359e96a6d058915d09b7b929a231c2bd31f038 ubuntu-24.04-minimal-cloudimg-arm64-docker.qcow2
arm64 containerd https://github.com/abiosoft/colima-core/releases/download/v0.7.6/ubuntu-24.04-minimal-cloudimg-arm64-containerd.qcow2 c731467c1cf2a6c84c1608005353c6e9f851e1c7985e99b4b112aed39be81226924f8af90e875ac3228397d4597136c585fc669e336785e9749824f1fc2acb48 ubuntu-24.04-minimal-cloudimg-arm64-containerd.qcow2
arm64 incus https://github.com/abiosoft/colima-core/releases/download/v0.7.6/ubuntu-24.04-minimal-cloudimg-arm64-incus.qcow2 dbd583b3385e3506aa161e17f3a368f4b5190365d9b73264ecbf09f285b38540ae8d52510159b037eb14bc83527a57d88eac53e88ecb7cc565cbef39928e5590 ubuntu-24.04-minimal-cloudimg-arm64-incus.qcow2
amd64 none https://github.com/abiosoft/colima-core/releases/download/v0.7.6/ubuntu-24.04-minimal-cloudimg-amd64-none.qcow2 a8cf07d803c2d89e120dffec9284a5ca079c4d3c7a7c9f5e80247d02685658d4ad804ef29e1cfa598c914cb966b96e7f4d7d9be94a2dca32018928b5516c906a ubuntu-24.04-minimal-cloudimg-amd64-none.qcow2
amd64 docker https://github.com/abiosoft/colima-core/releases/download/v0.7.6/ubuntu-24.04-minimal-cloudimg-amd64-docker.qcow2 50ed3755f16d2f709a4b18e1ddb2dbbe798570777c602b1103220783396362c6f6b0160f18336e27038628b1223ae59066d788b883e1b153053a01a9b42fe5f0 ubuntu-24.04-minimal-cloudimg-amd64-docker.qcow2
amd64 containerd https://github.com/abiosoft/colima-core/releases/download/v0.7.6/ubuntu-24.04-minimal-cloudimg-amd64-containerd.qcow2 b601ab51da7bd1a63d7d4926674105eab890ea36880c55c3f9795422734d206263d99c01242c8e61ad3e845ae673cfd7a968ea17007c596974b0b552513cdb16 ubuntu-24.04-minimal-cloudimg-amd64-containerd.qcow2
amd64 incus https://github.com/abiosoft/colima-core/releases/download/v0.7.6/ubuntu-24.04-minimal-cloudimg-amd64-incus.qcow2 7c8c6b5c14dc43c51c85fdcdfe5740c23051ea5c94643c7aacce704c708ec38c5247cc7c6dff216d1d928c4abfec6fd3eaae141ed35d31417145c42ea57894f5 ubuntu-24.04-minimal-cloudimg-amd64-incus.qcow2
arm64 none https://github.com/abiosoft/colima-core/releases/download/v0.7.6-1/ubuntu-24.04-minimal-cloudimg-arm64-none.qcow2 837236b93ef520ee63f559a893b212df93ba42098d2f7b384fcdc4d7f38b28701498023cac23d2197dd3ae4eb5c7104e7506cae3679d25e055c2127d8f1aece4 ubuntu-24.04-minimal-cloudimg-arm64-none.qcow2
arm64 docker https://github.com/abiosoft/colima-core/releases/download/v0.7.6-1/ubuntu-24.04-minimal-cloudimg-arm64-docker.qcow2 3a4e66446d953b5ab612c4ef8c2d7ca9d07c180216c436a4afe15cdcd94e0736de48e4779ce85f9190f22fa918719259710971dbb215c73d15addb6bf23b280c ubuntu-24.04-minimal-cloudimg-arm64-docker.qcow2
arm64 containerd https://github.com/abiosoft/colima-core/releases/download/v0.7.6-1/ubuntu-24.04-minimal-cloudimg-arm64-containerd.qcow2 6946bcc5829d5373cc6ce7777c618ee22dce27e4a57a1d7502b0e9053ad95bbe901065f60e487ded5d386f9cd8bc333fc91201958c0a5d0cf8a42741cf73ef77 ubuntu-24.04-minimal-cloudimg-arm64-containerd.qcow2
arm64 incus https://github.com/abiosoft/colima-core/releases/download/v0.7.6-1/ubuntu-24.04-minimal-cloudimg-arm64-incus.qcow2 2f0ba625799ddddd6d2112ed7a4c6d21c5d1d847af104a9ad723a7dba1ee5e04819c2a8c60b84549df96a01bc006a2b97c4dd3fd283de476ecfc16b394b8b1d8 ubuntu-24.04-minimal-cloudimg-arm64-incus.qcow2
amd64 none https://github.com/abiosoft/colima-core/releases/download/v0.7.6-1/ubuntu-24.04-minimal-cloudimg-amd64-none.qcow2 14075a7def430ef2632a93974b2cd8f7ba9e40cf96074d09b254ab9d4480c8be870922970ae72f236f0b14f5282a89d46d95b8eab89d8bef16d9b1d8d216a0d6 ubuntu-24.04-minimal-cloudimg-amd64-none.qcow2
amd64 docker https://github.com/abiosoft/colima-core/releases/download/v0.7.6-1/ubuntu-24.04-minimal-cloudimg-amd64-docker.qcow2 1e128da890e9d8b07a3c2556fe200ce3c724108d099eacce311b520507f6e2d114430991d1b68ecf9ad66a915eb315f433a950bdff09450224c34d9529b88890 ubuntu-24.04-minimal-cloudimg-amd64-docker.qcow2
amd64 containerd https://github.com/abiosoft/colima-core/releases/download/v0.7.6-1/ubuntu-24.04-minimal-cloudimg-amd64-containerd.qcow2 a3f2ed75afc52fbf769215ef2b87a5f75ef2ac96bf620c566c93305e5d3aca32a1be38ebf511b6edd9e15a96dc987d7c71e4c482d64f21134e335cad6da3c148 ubuntu-24.04-minimal-cloudimg-amd64-containerd.qcow2
amd64 incus https://github.com/abiosoft/colima-core/releases/download/v0.7.6-1/ubuntu-24.04-minimal-cloudimg-amd64-incus.qcow2 9e04ab8d61559267010dc6f5315020abbaf14bd4cee91a2021ad30178255cfa85a962c0ffeb8759afedbe88ba8cac90963cfa3756d56974c5db2e21eb21e0700 ubuntu-24.04-minimal-cloudimg-amd64-incus.qcow2
2 changes: 1 addition & 1 deletion embedded/images/images_sha.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -eux

BASE_URL=https://github.com/abiosoft/colima-core/releases/download
BASE_FILENAME=ubuntu-24.04-minimal-cloudimg
VERSION=v0.7.6
VERSION=v0.7.6-1
RUNTIMES="none docker containerd incus"
ARCHS="arm64 amd64"

Expand Down
2 changes: 1 addition & 1 deletion environment/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type Container interface {
// Teardown tears down/uninstall the container runtime.
Teardown(ctx context.Context) error
// Update the container runtime.
Update(ctx context.Context) error
Update(ctx context.Context) (bool, error)
// Version returns the container runtime version.
Version(ctx context.Context) string
// Running returns if the container runtime is currently running.
Expand Down
4 changes: 2 additions & 2 deletions environment/container/containerd/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,6 @@ func (c containerdRuntime) Version(ctx context.Context) string {
return version
}

func (c *containerdRuntime) Update(ctx context.Context) error {
return fmt.Errorf("update not supported for the %s runtime", Name)
func (c *containerdRuntime) Update(ctx context.Context) (bool, error) {
return false, fmt.Errorf("update not supported for the %s runtime", Name)
}
6 changes: 3 additions & 3 deletions environment/container/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,16 @@ func (d dockerRuntime) Dependencies() []string {
}

func (d dockerRuntime) Version(ctx context.Context) string {
version, _ := d.host.RunOutput("docker", "version", "--format", `client: v{{.Client.Version}}{{printf "\n"}}server: v{{.Server.Version}}`)
version, _ := d.host.RunOutput("docker", "--context", config.CurrentProfile().ID, "version", "--format", `client: v{{.Client.Version}}{{printf "\n"}}server: v{{.Server.Version}}`)
return version
}

func (d *dockerRuntime) Update(ctx context.Context) error {
func (d *dockerRuntime) Update(ctx context.Context) (bool, error) {
packages := []string{
"docker-ce",
"docker-ce-cli",
"containerd.io",
}

return debutil.UpdateRuntime(ctx, d.guest, d, Name, packages...)
return debutil.UpdateRuntime(ctx, d.guest, d, packages...)
}
6 changes: 3 additions & 3 deletions environment/container/incus/incus.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (c *incusRuntime) Teardown(ctx context.Context) error {

// Version implements environment.Container.
func (c *incusRuntime) Version(ctx context.Context) string {
version, _ := c.guest.RunOutput("incus", "version")
version, _ := c.host.RunOutput("incus", "version", config.CurrentProfile().ID+":")
return version
}

Expand Down Expand Up @@ -280,7 +280,7 @@ type networkInfo struct {
Type string `json:"type"`
}

func (c *incusRuntime) Update(ctx context.Context) error {
func (c *incusRuntime) Update(ctx context.Context) (bool, error) {
packages := []string{
"incus",
"incus-base",
Expand All @@ -289,5 +289,5 @@ func (c *incusRuntime) Update(ctx context.Context) error {
"incus-ui-canonical",
}

return debutil.UpdateRuntime(ctx, c.guest, c, Name, packages...)
return debutil.UpdateRuntime(ctx, c.guest, c, packages...)
}
7 changes: 3 additions & 4 deletions environment/container/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

const (
Name = "kubernetes"
DefaultVersion = "v1.30.2+k3s1"
DefaultVersion = "v1.31.2+k3s1"

ConfigKey = "kubernetes_config"
)
Expand Down Expand Up @@ -264,7 +264,6 @@ func (c kubernetesRuntime) Version(context.Context) string {
return version
}

func (c *kubernetesRuntime) Update(ctx context.Context) error {
// update not supported
return nil
func (c *kubernetesRuntime) Update(ctx context.Context) (bool, error) {
return false, fmt.Errorf("update not supported for the %s runtime", Name)
}
17 changes: 10 additions & 7 deletions util/debutil/debutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ func UpdateRuntime(
ctx context.Context,
guest environment.GuestActions,
chain cli.CommandChain,
runtime string,
packageNames ...string,
) error {
) (bool, error) {
a := chain.Init(ctx)
log := a.Logger()

packages := packages(packageNames)

updatesAvailable := false
hasUpdates := false
updated := false

a.Stage("refreshing package manager")
a.Add(func() error {
Expand All @@ -58,13 +58,13 @@ func UpdateRuntime(
"-c",
packages.Upgradable(),
)
updatesAvailable = err == nil
hasUpdates = err == nil
return nil
})

a.Add(func() (err error) {
if !updatesAvailable {
log.Warnf("no updates available for %s runtime", runtime)
if !hasUpdates {
log.Warnln("no updates available")
return
}

Expand All @@ -75,10 +75,13 @@ func UpdateRuntime(
packages.Install(),
)
if err == nil {
updated = true
log.Println("done")
}
return
})

return a.Exec()
// it is necessary to execute the chain here to get the correct value for `updated`.
err := a.Exec()
return updated, err
}
Loading