Switched to overlay network transport.

This commit is contained in:
rony5394
2026-02-23 20:32:15 +01:00
parent 0175847e89
commit 44f533bd43
3 changed files with 12 additions and 17 deletions

View File

@@ -57,7 +57,7 @@ func cleanup(w http.ResponseWriter, r *http.Request){
if err != nil { if err != nil {
panic("Failed to remove helper service."+ err.Error()); panic("Failed to remove helper service."+ err.Error());
} }
time.Sleep(15*time.Second); time.Sleep(7*time.Second);
fmt.Fprint(w, bodyDecoded.ServiceId); fmt.Fprint(w, bodyDecoded.ServiceId);
} }

View File

@@ -45,14 +45,16 @@ func prepare(w http.ResponseWriter, r *http.Request){
maxConcurrent := uint64(1); maxConcurrent := uint64(1);
totalCompletions := uint64(1); totalCompletions := uint64(1);
stopGracePeriod := time.Second * 5;
targetNode := labels["blazena.node"]; targetNode := labels["blazena.node"];
helperCommand := `ssh-keygen -t ed25519 -f /host_key && \ helperCommand := `ssh-keygen -t ed25519 -f /host_key && \
echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIByYbl8vu946LPycSO5pBohq3vMvvl+wX7snu1Bqpd7p test" > /root/.ssh/authorized_keys && \ echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIByYbl8vu946LPycSO5pBohq3vMvvl+wX7snu1Bqpd7p test" > /root/.ssh/authorized_keys && \
/usr/sbin/sshd -h /host_key -p 22 -D`; /usr/sbin/sshd -h /host_key -p 2222 -D`;
_, err = ApiClient.ServiceCreate(context.Background(), swarm.ServiceSpec{ _, err = ApiClient.ServiceCreate(context.Background(), swarm.ServiceSpec{
Annotations: swarm.Annotations{ Annotations: swarm.Annotations{
Name: "BlazenaHelper",
Labels: map[string]string{"blazena.helper": "true"}, Labels: map[string]string{"blazena.helper": "true"},
}, },
Mode: swarm.ServiceMode{ Mode: swarm.ServiceMode{
@@ -72,20 +74,14 @@ func prepare(w http.ResponseWriter, r *http.Request){
Type: "volume", Type: "volume",
}, },
}, },
StopGracePeriod: &stopGracePeriod,
}, },
Placement: &swarm.Placement{ Placement: &swarm.Placement{
Constraints: []string{"node.hostname=="+targetNode}, Constraints: []string{"node.hostname=="+targetNode},
}, },
}, Networks: []swarm.NetworkAttachmentConfig{swarm.NetworkAttachmentConfig{
EndpointSpec: &swarm.EndpointSpec{ Target: "blazenaPohar",
Ports: []swarm.PortConfig{ }},
swarm.PortConfig{
Protocol: swarm.PortConfigProtocolTCP,
TargetPort: uint32(22),
PublishedPort: uint32(2222),
PublishMode: swarm.PortConfigPublishModeHost,
},
},
}, },
}, swarm.ServiceCreateOptions{}); }, swarm.ServiceCreateOptions{});
@@ -93,7 +89,7 @@ func prepare(w http.ResponseWriter, r *http.Request){
panic("Failed to create helper service."+ err.Error()); panic("Failed to create helper service."+ err.Error());
} }
time.Sleep(15*time.Second); time.Sleep(7*time.Second);
fmt.Fprint(w, bodyDecoded.ServiceId); fmt.Fprint(w, bodyDecoded.ServiceId);
} }

View File

@@ -52,12 +52,11 @@ func Run(Config cfg.Config) {
fmt.Println("Done!"); fmt.Println("Done!");
command := `apk add --no-cache rsync openssh-client && \ command := `apk add --no-cache rsync openssh-client && \
echo "It Works Under Water!"`; ping -c 10 BlazenaHelper`;
//rsync -avz --delete -e "ssh -i /ssh-key -p 2222 -o StrictHostKeyChecking=no" \ //rsync -avz --delete -e "ssh -i /ssh-key -p 2222 -o StrictHostKeyChecking=no" \
//root@`+Config.Nodes[service.Node].Ip+`:/volume/ /tmp` //root@`+Config.Nodes[service.Node].Ip+`:/volume/ /tmp`
time.Sleep(15*time.Second);
exec, err := DockerClient.ContainerExecCreate(context.Background(), "BlazenaStorage", container.ExecOptions{ exec, err := DockerClient.ContainerExecCreate(context.Background(), "BlazenaStorage", container.ExecOptions{
Cmd: []string{"sh", "-c", command}, Cmd: []string{"sh", "-c", command},
AttachStdout: true, AttachStdout: true,
@@ -72,8 +71,9 @@ func Run(Config cfg.Config) {
resp, err := DockerClient.ContainerExecAttach(context.Background(), exec.ID, container.ExecStartOptions{}); resp, err := DockerClient.ContainerExecAttach(context.Background(), exec.ID, container.ExecStartOptions{});
defer resp.Close(); defer resp.Close();
//io.Copy(os.Stdout, resp.Reader) io.Copy(os.Stdout, resp.Reader)
time.Sleep(30*time.Second);
fmt.Println("Cleaning Up: " + service.ServiceId); fmt.Println("Cleaning Up: " + service.ServiceId);
cleanupService(Config, service); cleanupService(Config, service);
fmt.Println("Done!"); fmt.Println("Done!");
@@ -83,7 +83,6 @@ func Run(Config cfg.Config) {
fmt.Println("Done!"); fmt.Println("Done!");
} }
time.Sleep(15*time.Second);
DockerClient.ContainerRemove(context.Background(), "BlazenaStorage", container.RemoveOptions{ DockerClient.ContainerRemove(context.Background(), "BlazenaStorage", container.RemoveOptions{
Force: true, Force: true,
}); });