Skip to content

Commit

Permalink
- Incremented version to 0.8.1
Browse files Browse the repository at this point in the history
- Handle too-deply nested paths
- Improving logging and output
- Don't connect KubeClient until ready
  • Loading branch information
hour23 committed Jul 28, 2020
1 parent a469caa commit 5f62741
Show file tree
Hide file tree
Showing 12 changed files with 108 additions and 17 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
**/bindata.go
/out
internal/ruckstack/builder/resources/new-project/example/out
TODO.txt
TODO.txt
**/__debug_bin
/workspace
10 changes: 10 additions & 0 deletions .vscode/dlv-sudo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

export PATH="${GOPATH}/bin:$PATH"

if [ "$DEBUG_AS_ROOT" = "true" ]; then
DLV=$(which dlv)
exec sudo "PATH=$PATH" -E "$DLV" --only-same-user=false "$@"
else
exec dlv "$@"
fi
52 changes: 52 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "ruckstack new-project",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/cmd/ruckstack/ruckstack.go",
"env": {},
"args": [
"new-project",
"--out",
"/tmp/ruckstack/projects/1",
"--type",
"example"
]
},
{
"name": "ruckstack build",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/cmd/ruckstack/ruckstack.go",
"env": {},
"args": [
"build",
"--project",
"/tmp/ruckstack/projects/1/ruckstack.conf",
"--out",
"/tmp/ruckstack/projects/1/out"
]
},
{
"name": "system-control start",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/cmd/system-control/system-control.go",
"env": {
"DEBUG_AS_ROOT": "true",
"RUCKSTACK_HOME": "/tmp/ruckstack/servers/1/"
},
"args": [
"start"
],
}
]
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"go.alternateTools": {
"dlv": "dlv-sudo.sh"
},
"go.useLanguageServer": true
}
2 changes: 1 addition & 1 deletion BUILD.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if "%OS%" == "Windows_NT" setlocal
setlocal enabledelayedexpansion

REM ##Ideally this comes from $(out/linux/bin/ruckstack --version)
set VERSION=0.8.0
set VERSION=0.8.1

echo "Building ruckstack %VERSION%..."

Expand Down
2 changes: 1 addition & 1 deletion BUILD.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e

##Ideally this comes from $(out/linux/bin/ruckstack --version)
VERSION=0.8.0
VERSION=0.8.1

build() {
echo "Building ruckstack ${VERSION}..."
Expand Down
5 changes: 3 additions & 2 deletions cmd/ruckstack/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package cmd

import (
"fmt"
"github.com/spf13/cobra"
"os"

"github.com/spf13/cobra"

homedir "github.com/mitchellh/go-homedir"
"github.com/spf13/viper"
)
Expand All @@ -16,7 +17,7 @@ var rootCmd = &cobra.Command{
Use: "ruckstack",
Short: "Ruckstack CLI",
Long: `Ruckstack CLI`,
Version: "0.8.0",
Version: "0.8.1",
}

func init() {
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ require (
k8s.io/apimachinery v0.17.2
k8s.io/client-go v0.17.2
k8s.io/helm v2.16.1+incompatible // indirect
k8s.io/klog v1.0.0
k8s.io/kubectl v0.17.2
)
15 changes: 11 additions & 4 deletions internal/installer/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import (
"bytes"
"encoding/base64"
"fmt"
"github.com/ruckstack/ruckstack/internal"
"github.com/ruckstack/ruckstack/internal/system-control/files"
"github.com/ruckstack/ruckstack/internal/system-control/util"
"gopkg.in/yaml.v2"
"io"
"io/ioutil"
"net"
Expand All @@ -19,6 +15,11 @@ import (
"path/filepath"
"strings"
"time"

"github.com/ruckstack/ruckstack/internal"
"github.com/ruckstack/ruckstack/internal/system-control/files"
"github.com/ruckstack/ruckstack/internal/system-control/util"
"gopkg.in/yaml.v2"
)

func Install(packageConfig *internal.PackageConfig, installerArgs *InstallerArgs, zipReader *zip.ReadCloser) {
Expand Down Expand Up @@ -115,6 +116,12 @@ func getInstallPath(ui *bufio.Scanner, packageConfig *internal.PackageConfig, in

absInstallPath, err := filepath.Abs(installPath)

if len(absInstallPath) > 50 {
//if install path is too long, socket paths get longer than the 107 chars linux supports
fmt.Println(absInstallPath + " is too deeply nested. Choose a different directory.")
return getInstallPath(ui, nil, nil)
}

stat, err := os.Stat(absInstallPath)
if os.IsNotExist(err) {
//that is what we want
Expand Down
11 changes: 10 additions & 1 deletion internal/system-control/kubeclient/kubeclient.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
package kubeclient

import (
"flag"
"fmt"
"os"
"path/filepath"

"github.com/ruckstack/ruckstack/internal/system-control/util"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"
"os"
"k8s.io/klog"
)

func KubeClient() *kubernetes.Clientset {

klogFlags := flag.NewFlagSet("klog", flag.ExitOnError)
klogFlags.Set("logtostderr", "false")
klogFlags.Set("log_file", filepath.Join(util.InstallDir(), "logs", "k3s-client.log"))
klog.InitFlags(klogFlags)

if !ConfigExists() {
panic(fmt.Sprintf("%s does not exist", KubeconfigFile()))
}
Expand Down
9 changes: 5 additions & 4 deletions internal/system-control/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ package server

import (
"fmt"
"github.com/ruckstack/ruckstack/internal/system-control/k3s"
"github.com/ruckstack/ruckstack/internal/system-control/server/monitor"
"github.com/ruckstack/ruckstack/internal/system-control/server/webserver"
"github.com/ruckstack/ruckstack/internal/system-control/util"
"io/ioutil"
"log"
"os"
"os/signal"
"path/filepath"
"strconv"
"syscall"

"github.com/ruckstack/ruckstack/internal/system-control/k3s"
"github.com/ruckstack/ruckstack/internal/system-control/server/monitor"
"github.com/ruckstack/ruckstack/internal/system-control/server/webserver"
"github.com/ruckstack/ruckstack/internal/system-control/util"
)

func Start() {
Expand Down
8 changes: 5 additions & 3 deletions internal/system-control/status/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ package status

import (
"fmt"
"sort"
"sync"

"github.com/ruckstack/ruckstack/internal/system-control/kubeclient"
"github.com/ruckstack/ruckstack/internal/system-control/util"
apps "k8s.io/api/apps/v1"
core "k8s.io/api/core/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/cache"
"sort"
"sync"
)

type serviceInfo struct {
Expand All @@ -21,7 +23,7 @@ type serviceInfo struct {
pods []string
}

var kubeClient = kubeclient.KubeClient()
var kubeClient *kubernetes.Client
var lastPodStatus = map[string]string{}
var ownerTree = map[string]*meta.OwnerReference{}
var allServices = map[string]*serviceInfo{}
Expand Down

0 comments on commit 5f62741

Please sign in to comment.