Skip to content

Commit

Permalink
fix(cloud): Add changes to allow switching to different OSes (#1832)
Browse files Browse the repository at this point in the history
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Alexander Jung <alex@unikraft.cloud>
Approved-by: Alexander Jung <alex@unikraft.cloud>
  • Loading branch information
nderjung authored Dec 19, 2024
2 parents ebeac08 + beb5aa2 commit 95e2a12
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
8 changes: 7 additions & 1 deletion internal/cli/kraft/cloud/tunnel/tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
type TunnelOptions struct {
TunnelProxyPorts []string `local:"true" long:"tunnel-proxy-port" short:"p" usage:"Remote port exposed by the tunnelling service(s). (default start port is 4444)"`
ProxyControlPort uint `local:"true" long:"tunnel-control-port" short:"P" usage:"Command-and-control port used by the tunneling service(s)." default:"4443"`
TunnelServiceImage string `local:"true" long:"tunnel-image" usage:"Tunnel service image" default:"official/utils/tunnel:latest"`
TunnelServiceImage string `local:"true" long:"tunnel-image" usage:"Tunnel service image" default:"official/utils/tunnel:1.0"`
Token string `noattribute:"true"`
Metro string `noattribute:"true"`

Expand All @@ -49,6 +49,8 @@ type TunnelOptions struct {
portIterator uint16
}

const tunnelImageOld string = "official/utils/tunnel:latest"

func NewCmd() *cobra.Command {
cmd, err := cmdfactory.New(&TunnelOptions{}, cobra.Command{
Short: "Forward a local port to an unexposed instance",
Expand Down Expand Up @@ -130,6 +132,10 @@ func NewCmd() *cobra.Command {
}

func (opts *TunnelOptions) Pre(cmd *cobra.Command, _ []string) error {
if opts.TunnelServiceImage == tunnelImageOld {
return fmt.Errorf("the image %q is deprecated, please use the default and update KraftKit to the latest version", tunnelImageOld)
}

if err := utils.PopulateMetroToken(cmd, &opts.Metro, &opts.Token); err != nil {
return fmt.Errorf("could not populate metro and token: %w", err)
}
Expand Down
11 changes: 9 additions & 2 deletions internal/cli/kraft/cloud/volume/import/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,18 @@ type ImportOptions struct {
Token string `noattribute:"true"`
Metro string `noattribute:"true"`

VolimportImage string `local:"true" long:"image" usage:"Volume import image to use" default:"official/utils/volimport:latest"`
VolimportImage string `local:"true" long:"image" usage:"Volume import image to use" default:"official/utils/volimport:1.0"`
Force bool `local:"true" long:"force" short:"f" usage:"Force import, even if it might fail"`
Source string `local:"true" long:"source" short:"s" usage:"Path to the data source (directory, Dockerfile, Docker link, cpio file)" default:"."`
Timeout uint64 `local:"true" long:"timeout" short:"t" usage:"Timeout for the import process in seconds when unresponsive" default:"10"`
VolID string `local:"true" long:"volume" short:"v" usage:"Identifier of an existing volume (name or UUID)"`
Workdir string `local:"true" long:"workdir" short:"w" usage:"Working directory for the import process"`
}

const volimportPort uint16 = 42069
const (
volimportImageOld string = "official/utils/volimport:latest"
volimportPort uint16 = 42069
)

func NewCmd() *cobra.Command {
cmd, err := cmdfactory.New(&ImportOptions{}, cobra.Command{
Expand Down Expand Up @@ -79,6 +82,10 @@ func (opts *ImportOptions) Pre(cmd *cobra.Command, _ []string) error {
return fmt.Errorf("must specify a value for the --volume flag")
}

if opts.VolimportImage == volimportImageOld {
return fmt.Errorf("the image %q is deprecated, please use the default and update KraftKit to the latest version", volimportImageOld)
}

if finfo, err := os.Stat(opts.Source); err == nil && (!finfo.IsDir() && !strings.HasSuffix(opts.Source, "Dockerfile")) {
return fmt.Errorf("local source path must be a directory or a Dockerfile")
}
Expand Down
3 changes: 2 additions & 1 deletion internal/cli/kraft/cloud/volume/import/volimport.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func volumeSanityCheck(ctx context.Context, cli kcvolumes.VolumesService, volID
// runVolimport spawns a volume data import instance with the given volume attached.
func runVolimport(ctx context.Context, cli kcinstances.InstancesService, image, volUUID, authStr string, timeoutS uint64) (instID, fqdn string, err error) {
args := []string{
"volimport",
"-p", strconv.FormatUint(uint64(volimportPort), 10),
"-a", authStr,
"-t", strconv.FormatUint(timeoutS, 10),
Expand All @@ -55,7 +56,7 @@ func runVolimport(ctx context.Context, cli kcinstances.InstancesService, image,
},
Volumes: []kcinstances.CreateRequestVolume{{
UUID: &volUUID,
At: ptr("/"),
At: ptr("/mnt"),
}},
Autostart: ptr(true),
WaitTimeoutMs: ptr(int((3 * time.Second).Milliseconds())),
Expand Down

0 comments on commit 95e2a12

Please sign in to comment.