Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

feat: support macos, also open macos acitons #160

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
name: test
strategy:
matrix:
os: [ubuntu-latest]
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Check out code
Expand Down
5 changes: 1 addition & 4 deletions mdz/pkg/server/agentd_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package server
import (
"fmt"
"os/exec"
"syscall"
)

type agentDRunStep struct {
Expand All @@ -15,9 +14,7 @@ type agentDRunStep struct {
func (s *agentDRunStep) Run() error {
fmt.Fprintf(s.options.OutputStream, "🚧 Running the agent for docker runtime...\n")
cmd := exec.Command("/bin/sh", "-c", "mdz local-agent &")
cmd.SysProcAttr = &syscall.SysProcAttr{
Pdeathsig: syscall.SIGKILL,
}
sysProcAttr(cmd)
if s.options.Verbose {
cmd.Stderr = s.options.OutputStream
cmd.Stdout = s.options.OutputStream
Expand Down
5 changes: 1 addition & 4 deletions mdz/pkg/server/gpu_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"os/exec"
"path/filepath"
"regexp"
"syscall"
)

//go:embed gpu-resource.yaml
Expand Down Expand Up @@ -60,9 +59,7 @@ func (s *gpuInstallStep) Run() error {
fmt.Fprintf(s.options.OutputStream, "🚧 Initializing the GPU resource...\n")

cmd := exec.Command("/bin/sh", "-c", "sudo k3s kubectl apply -f -")
cmd.SysProcAttr = &syscall.SysProcAttr{
Pdeathsig: syscall.SIGKILL,
}
sysProcAttr(cmd)

stdin, err := cmd.StdinPipe()
if err != nil {
Expand Down
5 changes: 1 addition & 4 deletions mdz/pkg/server/k3s_destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package server
import (
"fmt"
"os/exec"
"syscall"
)

// k3sDestroyAllStep installs k3s and related tools.
Expand All @@ -15,9 +14,7 @@ func (s *k3sDestroyAllStep) Run() error {
fmt.Fprintf(s.options.OutputStream, "🚧 Destroy the OpenModelz Cluster...\n")
// TODO(gaocegege): Embed the script into the binary.
cmd := exec.Command("/bin/sh", "-c", "/usr/local/bin/k3s-uninstall.sh")
cmd.SysProcAttr = &syscall.SysProcAttr{
Pdeathsig: syscall.SIGKILL,
}
sysProcAttr(cmd)
if s.options.Verbose {
cmd.Stderr = s.options.OutputStream
cmd.Stdout = s.options.OutputStream
Expand Down
9 changes: 2 additions & 7 deletions mdz/pkg/server/k3s_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"io"
"os/exec"
"syscall"
)

//go:embed k3s-install.sh
Expand All @@ -18,9 +17,7 @@ type k3sInstallStep struct {

func (s *k3sInstallStep) Run() error {
checkCmd := exec.Command("/bin/sh", "-c", "sudo k3s kubectl get nodes")
checkCmd.SysProcAttr = &syscall.SysProcAttr{
Pdeathsig: syscall.SIGKILL,
}
sysProcAttr(checkCmd)
checkCmd.Stdout = nil
checkCmd.Stderr = nil
err := checkCmd.Run()
Expand All @@ -33,10 +30,8 @@ func (s *k3sInstallStep) Run() error {
// TODO(gaocegege): Embed the script into the binary.
// Always run start, do not check the hash to decide.
cmd := exec.Command("/bin/sh", "-c", "INSTALL_K3S_VERSION=v1.27.3+k3s1 INSTALL_K3S_EXEC='--disable=traefik' INSTALL_K3S_FORCE_RESTART=true K3S_KUBECONFIG_MODE=644 K3S_TOKEN=openmodelz sh -")
cmd.SysProcAttr = &syscall.SysProcAttr{
Pdeathsig: syscall.SIGKILL,
}

sysProcAttr(cmd)
stdin, err := cmd.StdinPipe()
if err != nil {
return err
Expand Down
5 changes: 1 addition & 4 deletions mdz/pkg/server/k3s_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"io"
"os/exec"
"syscall"
)

// k3sJoinStep installs k3s and related tools.
Expand All @@ -18,9 +17,7 @@ func (s *k3sJoinStep) Run() error {
cmdStr := fmt.Sprintf("INSTALL_K3S_FORCE_RESTART=true K3S_KUBECONFIG_MODE=644 K3S_TOKEN=openmodelz K3S_URL=https://%s:6443 sh -", s.options.ServerIP)

cmd := exec.Command("/bin/sh", "-c", cmdStr)
cmd.SysProcAttr = &syscall.SysProcAttr{
Pdeathsig: syscall.SIGKILL,
}
sysProcAttr(cmd)
if s.options.Verbose {
cmd.Stderr = s.options.OutputStream
cmd.Stdout = s.options.OutputStream
Expand Down
5 changes: 1 addition & 4 deletions mdz/pkg/server/k3s_killall.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package server
import (
"fmt"
"os/exec"
"syscall"
)

// k3sKillAllStep installs k3s and related tools.
Expand All @@ -15,9 +14,7 @@ func (s *k3sKillAllStep) Run() error {
fmt.Fprintf(s.options.OutputStream, "🚧 Stopping the OpenModelz Cluster...\n")
// TODO(gaocegege): Embed the script into the binary.
cmd := exec.Command("/bin/sh", "-c", "/usr/local/bin/k3s-killall.sh")
cmd.SysProcAttr = &syscall.SysProcAttr{
Pdeathsig: syscall.SIGKILL,
}
sysProcAttr(cmd)
if s.options.Verbose {
cmd.Stderr = s.options.OutputStream
cmd.Stdout = s.options.OutputStream
Expand Down
5 changes: 1 addition & 4 deletions mdz/pkg/server/k3s_prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"os/exec"
"path/filepath"
"strings"
"syscall"
"text/template"
)

Expand Down Expand Up @@ -43,9 +42,7 @@ func (s *k3sPrepare) Run() error {
filepath.Join(mirrorPath, mirrorFile),
buf.String(),
))
cmd.SysProcAttr = &syscall.SysProcAttr{
Pdeathsig: syscall.SIGKILL,
}
sysProcAttr(cmd)
if s.options.Verbose {
cmd.Stderr = s.options.OutputStream
cmd.Stdout = s.options.OutputStream
Expand Down
5 changes: 1 addition & 4 deletions mdz/pkg/server/nginx_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"io"
"os/exec"
"syscall"
)

//go:embed nginx-dep.yaml
Expand All @@ -20,9 +19,7 @@ func (s *nginxInstallStep) Run() error {
fmt.Fprintf(s.options.OutputStream, "🚧 Initializing the load balancer...\n")

cmd := exec.Command("/bin/sh", "-c", "sudo k3s kubectl apply -f -")
cmd.SysProcAttr = &syscall.SysProcAttr{
Pdeathsig: syscall.SIGKILL,
}
sysProcAttr(cmd)

stdin, err := cmd.StdinPipe()
if err != nil {
Expand Down
9 changes: 2 additions & 7 deletions mdz/pkg/server/openmodelz_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"os/exec"
"regexp"
"strings"
"syscall"

"github.com/sirupsen/logrus"
)
Expand All @@ -27,9 +26,7 @@ func (s *openModelZInstallStep) Run() error {
fmt.Fprintf(s.options.OutputStream, "🚧 Initializing the server...\n")

cmd := exec.Command("/bin/sh", "-c", "sudo k3s kubectl apply -f -")
cmd.SysProcAttr = &syscall.SysProcAttr{
Pdeathsig: syscall.SIGKILL,
}
sysProcAttr(cmd)

stdin, err := cmd.StdinPipe()
if err != nil {
Expand Down Expand Up @@ -92,9 +89,7 @@ func (s *openModelZInstallStep) Run() error {
func (s *openModelZInstallStep) Verify() error {
fmt.Fprintf(s.options.OutputStream, "🚧 Verifying the load balancer...\n")
cmd := exec.Command("/bin/sh", "-c", "sudo k3s kubectl get svc -n ingress-nginx ingress-nginx-controller -o jsonpath={@.status.loadBalancer.ingress}")
cmd.SysProcAttr = &syscall.SysProcAttr{
Pdeathsig: syscall.SIGKILL,
}
sysProcAttr(cmd)
output, err := cmd.CombinedOutput()
if err != nil {
logrus.Debugf("failed to get the ingress ip: %v", err)
Expand Down
15 changes: 15 additions & 0 deletions mdz/pkg/server/proc_attr_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//go:build linux

package server

import (
"os/exec"
"syscall"
)

func sysProcAttr(cmd *exec.Cmd) {
cmd.SysProcAttr = &syscall.SysProcAttr{
Setpgid: true,
Pdeathsig: syscall.SIGINT,
}
}
14 changes: 14 additions & 0 deletions mdz/pkg/server/proc_attr_other.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//go:build !linux

package server

import (
"os/exec"
"syscall"
)

func sysProcAttr(cmd *exec.Cmd) {
cmd.SysProcAttr = &syscall.SysProcAttr{
Setpgid: true,
}
}