Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Commit

Permalink
v2.0.2-rc2
Browse files Browse the repository at this point in the history
* Include NFS client to console
* Support command "ros engine switch latest"
* Use long term branch v2.0.x for os-services
* Use docker-compose/docker compose from CLI container
  • Loading branch information
olljanat committed Oct 19, 2024
1 parent 5d298d5 commit b20e1e4
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 23 deletions.
27 changes: 17 additions & 10 deletions cmd/control/console_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,20 +183,27 @@ func consoleInitFunc() error {
})
}

// create placeholder for docker-compose binary
const ComposePlaceholder = `
#!/bin/bash
echo 'INFO: System service "docker-compose" is not yet enabled'
sudo ros service enable docker-compose
sudo ros service up docker-compose
// create placeholder for docker binary with "docker compose" support
const DockerPlaceholder = `#!/bin/bash
if [ "$1" == "compose" ]; then
/usr/bin/docker-compose "${@:2}"
else
/usr/bin/docker "$@"
fi
`
if _, err := os.Stat("/var/lib/rancher/compose"); os.IsNotExist(err) {
if err := os.MkdirAll("/var/lib/rancher/compose", 0555); err != nil {
if _, err := os.Stat("/usr/local/bin/docker"); os.IsNotExist(err) {
if err := ioutil.WriteFile("/usr/local/bin/docker", []byte(DockerPlaceholder), 0755); err != nil {
log.Error(err)
}
}
if _, err := os.Stat("/var/lib/rancher/compose/docker-compose"); os.IsNotExist(err) {
if err := ioutil.WriteFile("/var/lib/rancher/compose/docker-compose", []byte(ComposePlaceholder), 0755); err != nil {

// create placeholder for docker-compose binary
const ComposePlaceholder = `#!/bin/bash
DOCKER_VERSION=$(sudo system-docker inspect --format "{{.Config.Image}}" docker | cut -d ":" -f 2)
docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock -w /compose -v $PWD:/compose docker:$DOCKER_VERSION-cli docker compose "$@"
`
if _, err := os.Stat("/usr/local/bin/docker-compose"); os.IsNotExist(err) {
if err := ioutil.WriteFile("/usr/local/bin/docker-compose", []byte(ComposePlaceholder), 0755); err != nil {
log.Error(err)
}
}
Expand Down
34 changes: 30 additions & 4 deletions cmd/control/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,19 @@ func engineSwitch(c *cli.Context) error {
newEngine := c.Args()[0]

cfg := config.LoadConfig()
validateEngine(newEngine, cfg)

if newEngine == "latest" {
engines := availableEngines(cfg, c.Bool("update"))
newEngine = engines[len(engines)-1]
currentEngine := CurrentEngine()
if newEngine == currentEngine {
log.Infof("Latest engine %s is already running", newEngine)
return nil
}
log.Infof("Switching to engine %s", newEngine)
} else {
validateEngine(newEngine, cfg)
}

project, err := compose.GetProject(cfg, true, false)
if err != nil {
Expand Down Expand Up @@ -282,14 +294,28 @@ func engineList(c *cli.Context) error {
engines := availableEngines(cfg, c.Bool("update"))
currentEngine := CurrentEngine()

i := 1
for _, engine := range engines {
if engine == currentEngine {
fmt.Printf("current %s\n", engine)
if i == len(engines) {
fmt.Printf("current %s (latest)\n", engine)
} else {
fmt.Printf("current %s\n", engine)
}
} else if engine == cfg.Rancher.Docker.Engine {
fmt.Printf("enabled %s\n", engine)
if i == len(engines) {
fmt.Printf("enabled %s (latest)\n", engine)
} else {
fmt.Printf("enabled %s\n", engine)
}
} else {
fmt.Printf("disabled %s\n", engine)
if i == len(engines) {
fmt.Printf("disabled %s (latest)\n", engine)
} else {
fmt.Printf("disabled %s\n", engine)
}
}
i++
}

// check the dind container
Expand Down
5 changes: 0 additions & 5 deletions cmd/control/user_docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const (
sourceDirectory = "/engine"
destDirectory = "/var/lib/rancher/engine"
dockerCompletionFName = "completion"
dockerComposeFName = "docker-compose"
)

var (
Expand Down Expand Up @@ -100,10 +99,6 @@ func copyBinaries(source, dest string) error {
if err := os.Chmod(destFile, 0644); err != nil {
return err
}
} else if file.Name() == dockerComposeFName {
if err := os.Chmod(destFile, 0755); err != nil {
return err
}
} else {
if err := os.Chmod(destFile, 0751); err != nil {
return err
Expand Down
2 changes: 0 additions & 2 deletions cmd/control/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ func symLinkEngineBinary() []symlink {
{"/var/lib/rancher/engine/docker-containerd-ctr", "/usr/bin/docker-containerd-ctr"},
{"/var/lib/rancher/engine/docker-containerd-shim", "/usr/bin/docker-containerd-shim"},
{"/var/lib/rancher/engine/docker-runc", "/usr/bin/docker-runc"},

{"/var/lib/rancher/compose/docker-compose", "/usr/bin/docker-compose"},
}
return baseSymlink
}
Expand Down
2 changes: 1 addition & 1 deletion images/02-console/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN apt-get update \
sudo less curl ca-certificates psmisc htop kmod iproute2 \
net-tools bash-completion wget \
nano open-iscsi iputils-ping nvi \
apparmor \
apparmor nfs-common \
&& update-alternatives --set iptables /usr/sbin/iptables-legacy \
&& update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy \
&& rm -rf /var/lib/apt/lists/* \
Expand Down
2 changes: 1 addition & 1 deletion os-config.tpl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ rancher:
- configdrive:/media/config-2
repositories:
core:
url: {{.OS_SERVICES_REPO}}/{{.REPO_VERSION}}
url: {{.OS_SERVICES_REPO}}/v2.0.x
state:
fstype: auto
oem_fstype: auto
Expand Down

0 comments on commit b20e1e4

Please sign in to comment.