Something.

This commit is contained in:
rony5394
2026-02-23 15:39:57 +01:00
parent 136bb4c5b8
commit 9751a602cc
6 changed files with 67 additions and 11 deletions

View File

@@ -7,6 +7,7 @@ import (
"fmt"
"io"
"net/http"
"os"
"time"
"github.com/docker/docker/api/types/container"
@@ -46,16 +47,37 @@ func Run(Config cfg.Config) {
fmt.Println("Preparing: " + service.ServiceId + " volume: " + volume);
if !prepareService(Config, service, volume) {continue}
fmt.Println("Done!");
time.Sleep(5*time.Second);
fmt.Println("Cleaning Up: " + service.ServiceId + " volume: " + volume);
command := `apk add --no-cache rsync openssh-client && \
echo "It Works Under Water!"`;
//rsync -avz --delete -e "ssh -i /ssh-key -p 2222 -o StrictHostKeyChecking=no" \
//root@`+Config.Nodes[service.Node].Ip+`:/volume/ /tmp`
time.Sleep(15*time.Second);
exec, err := DockerClient.ContainerExecCreate(context.Background(), "BlazenaStorage", container.ExecOptions{
Cmd: []string{"sh", "-c", command},
AttachStdout: true,
AttachStderr: true,
Tty: false,
});
if err != nil {
panic("Failed to create rsync exec!"+err.Error());
}
resp, err := DockerClient.ContainerExecAttach(context.Background(), exec.ID, container.ExecStartOptions{});
defer resp.Close();
io.Copy(os.Stdout, resp.Reader)
fmt.Println("Cleaning Up: " + service.ServiceId);
cleanupService(Config, service);
fmt.Println("Done!");
}
}
time.Sleep(15*time.Second);
DockerClient.ContainerRemove(context.Background(), "BlazenaStorage", container.RemoveOptions{
Force: true,
});
@@ -169,7 +191,7 @@ func createStorageContainer(Config cfg.Config, DockerClient *client.Client){
Labels: map[string]string{
"blazena.storage": "true",
},
Cmd: strslice.StrSlice{"sleep", "infinity"},
Cmd: strslice.StrSlice{"sleep", "1h"},
}, &container.HostConfig{
Mounts: []mount.Mount{
mount.Mount{
@@ -180,7 +202,7 @@ func createStorageContainer(Config cfg.Config, DockerClient *client.Client){
},
},
//AutoRemove: true,
NetworkMode: "blazena",
NetworkMode: "blazenaPohar",
}, &network.NetworkingConfig{
}, &v1.Platform{}, "BlazenaStorage");
@@ -194,4 +216,21 @@ func createStorageContainer(Config cfg.Config, DockerClient *client.Client){
panic("Failed to start BlazenaStorage container!"+err.Error());
}
reader, err := os.Open("./ssh-key.tar");
if err != nil {
panic("Failed To open ssh key file for reading!"+err.Error());
}
defer reader.Close();
err = DockerClient.CopyToContainer(context.Background(), "BlazenaStorage", "/", reader, container.CopyToContainerOptions{
AllowOverwriteDirWithFile: true,
});
if err != nil {
panic("Failed to copy ssh key to container!"+err.Error());
}
}