Skip to content

Commit

Permalink
chore(webui): change language to English, code style and minor fixes
Browse files Browse the repository at this point in the history
Signed-off-by: xiayu.lyt <xiayu.lyt@alibaba-inc.com>
  • Loading branch information
Lyt99 committed Jan 17, 2024
1 parent d9970b1 commit c436454
Show file tree
Hide file tree
Showing 78 changed files with 510 additions and 504 deletions.
10 changes: 5 additions & 5 deletions deploy/skoopbundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ spec:
dnsPolicy: ClusterFirstWithHostNet
initContainers:
- name: inspector-prepare
image: "kubeskoop/kubeskoop:latest"
image: kubeskoop/kubeskoop:v1.0.0
volumeMounts:
- name: btf-rawdata
mountPath: /etc/net-exporter/btf
- mountPath: /boot/
name: boot
command: [btfhack, discover, -p, /etc/net-exporter/btf/]
containers:
- image: "kubeskoop/kubeskoop:latest"
- image: kubeskoop/kubeskoop:v1.0.0
name: inspector
env:
- name: INSPECTOR_NODENAME
Expand Down Expand Up @@ -383,7 +383,7 @@ spec:
name: grafana-datasources
readOnly: false
- name: register-dashboard
image: kubeskoop/kubeskoop:latest
image: kubeskoop/kubeskoop:v1.0.0
env:
- name: GRAFANA_PASSWORD
value: "kubeskoop"
Expand Down Expand Up @@ -579,7 +579,7 @@ spec:
spec:
containers:
- name: controller
image: registry.aliyuncs.com/wangbs/kubeskoop:latest
image: kubeskoop/kubeskoop:v1.0.0
command: ["/bin/controller"]
env:
- name: PROMETHEUS_ENDPOINT
Expand Down Expand Up @@ -627,7 +627,7 @@ spec:
spec:
containers:
- name: controller
image: registry.aliyuncs.com/wangbs/kubeskoop:latest
image: kubeskoop/kubeskoop:v1.0.0
command: ["/bin/webconsole"]
env:
- name: CONTROLLER_ENDPOINT
Expand Down
7 changes: 3 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/alibaba/kubeskoop
go 1.19

require (
github.com/afiskon/promtail-client v0.0.0-20190305142237-506f3f921e9c
github.com/alibabacloud-go/darabonba-openapi v0.2.1
github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.2
github.com/alibabacloud-go/ecs-20140526/v2 v2.1.3
Expand All @@ -22,6 +21,7 @@ require (
github.com/gorilla/mux v1.8.0
github.com/hashicorp/golang-lru/v2 v2.0.6
github.com/jmoiron/sqlx v1.3.5
github.com/json-iterator/go v1.1.12
github.com/mattn/go-sqlite3 v1.14.6
github.com/mdlayher/netlink v1.7.1
github.com/mitchellh/mapstructure v1.5.0
Expand All @@ -32,6 +32,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/projectcalico/api v0.0.0-20220722155641-439a754a988b
github.com/prometheus/client_golang v1.15.1
github.com/prometheus/common v0.42.0
github.com/prometheus/procfs v0.9.0
github.com/samber/lo v1.37.0
github.com/sirupsen/logrus v1.9.0
Expand All @@ -48,6 +49,7 @@ require (
golang.org/x/sys v0.8.0
google.golang.org/grpc v1.56.2
google.golang.org/protobuf v1.31.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.26.0
k8s.io/apimachinery v0.26.0
k8s.io/client-go v0.25.2
Expand Down Expand Up @@ -133,7 +135,6 @@ require (
github.com/intel/goresctrl v0.2.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/josharian/native v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.11.13 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
Expand Down Expand Up @@ -164,7 +165,6 @@ require (
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/rivo/uniseg v0.4.3 // indirect
github.com/rogpeppe/go-internal v1.8.0 // indirect
github.com/spf13/afero v1.9.3 // indirect
Expand Down Expand Up @@ -200,7 +200,6 @@ require (
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiserver v0.22.5 // indirect
k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a // indirect
oss.terrastruct.com/util-go v0.0.0-20230604222829-11c3c60fec14 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbt
github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ=
github.com/afiskon/promtail-client v0.0.0-20190305142237-506f3f921e9c h1:AMDVOKGaiqse4qiRXSzRgpC9DCNTHCx6zpzdtXXrKM4=
github.com/afiskon/promtail-client v0.0.0-20190305142237-506f3f921e9c/go.mod h1:p/7Wos+jcfrnwLqqzJMZ0s323kfVtJPW+HUvAANklVQ=
github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b h1:slYM766cy2nI3BwyRiyQj/Ud48djTMtMebDqepE95rw=
github.com/alecthomas/assert/v2 v2.2.1 h1:XivOgYcduV98QCahG8T5XTezV5bylXe+lBxLG2K2ink=
github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek=
Expand Down Expand Up @@ -730,6 +728,7 @@ github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8Hm
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/josharian/native v1.0.0 h1:Ts/E8zCSEsG17dUqv7joXJFybuMLjQfWE04tsBODTxk=
github.com/josharian/native v1.0.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA=
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
github.com/jsimonetti/rtnetlink v0.0.0-20190606172950-9527aa82566a/go.mod h1:Oz+70psSo5OFh8DBl0Zv2ACw7Esh6pPUphlvZG9x7uw=
github.com/jsimonetti/rtnetlink v0.0.0-20200117123717-f846d4f6c1f4/go.mod h1:WGuG/smIU4J/54PblvSbh+xvCZmpJnFgr3ds6Z55XMQ=
Expand Down Expand Up @@ -871,6 +870,7 @@ github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8m
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
github.com/ncw/swift v1.0.47/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM=
Expand Down
5 changes: 3 additions & 2 deletions pkg/controller/cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package cmd

import (
"os"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"os"
)

// rootCmd represents the base command when called without any subcommands
Expand Down Expand Up @@ -40,5 +41,5 @@ func Execute() {
func init() {
rootCmd.PersistentFlags().BoolVarP(&debug, "debug", "d", false, "Enable debug log information")
rootCmd.PersistentFlags().IntVarP(&agentPort, "agent-port", "a", defaultAgentPort, "Controller Port For Agent Registration")
rootCmd.PersistentFlags().IntVarP(&httpPort, "http-port", "p", defaultHttpPort, "Controller Port For Agent Registration")
rootCmd.PersistentFlags().IntVarP(&httpPort, "http-port", "p", defaultHTTPPort, "Controller Port For Agent Registration")
}
21 changes: 11 additions & 10 deletions pkg/controller/cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@ package cmd

import (
"fmt"
"github.com/alibaba/kubeskoop/pkg/controller/graph"
"github.com/alibaba/kubeskoop/pkg/controller/rpc"
"github.com/alibaba/kubeskoop/pkg/controller/service"
exporter "github.com/alibaba/kubeskoop/pkg/exporter/cmd"
skoopContext "github.com/alibaba/kubeskoop/pkg/skoop/context"
"github.com/gin-gonic/gin"
"github.com/prometheus/common/model"
"google.golang.org/grpc"
"io"
"log"
"net"
Expand All @@ -21,11 +13,20 @@ import (
"strings"
"syscall"
"time"

"github.com/alibaba/kubeskoop/pkg/controller/graph"
"github.com/alibaba/kubeskoop/pkg/controller/rpc"
"github.com/alibaba/kubeskoop/pkg/controller/service"
exporter "github.com/alibaba/kubeskoop/pkg/exporter/cmd"
skoopContext "github.com/alibaba/kubeskoop/pkg/skoop/context"
"github.com/gin-gonic/gin"
"github.com/prometheus/common/model"
"google.golang.org/grpc"
)

const (
defaultAgentPort = 10263
defaultHttpPort = 10264
defaultHTTPPort = 10264
)

type Server struct {
Expand Down Expand Up @@ -75,7 +76,7 @@ func (s *Server) RunAgentServer(port int, done <-chan struct{}) {

func (s *Server) RunHTTPServer(port int, done <-chan struct{}) {
if port == 0 {
port = defaultHttpPort
port = defaultHTTPPort
}
r := gin.New()
r.Use(gin.Logger())
Expand Down
9 changes: 6 additions & 3 deletions pkg/controller/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ package db
import (
"bytes"
"database/sql"
_ "database/sql"

// import for go:embed
_ "embed"
"fmt"
"github.com/jmoiron/sqlx"
_ "github.com/mattn/go-sqlite3"
"text/template"
"time"

"github.com/jmoiron/sqlx"
// import for sqlite
_ "github.com/mattn/go-sqlite3"
)

//go:embed db_schema_v1.sql.tpl
Expand Down
9 changes: 5 additions & 4 deletions pkg/controller/diagnose/diagnose.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ package diagnose
import (
"context"
"fmt"
skoopContext "github.com/alibaba/kubeskoop/pkg/skoop/context"
"os"
"os/exec"
"strconv"

skoopContext "github.com/alibaba/kubeskoop/pkg/skoop/context"
)

type DiagnoseController interface {
type Controller interface {
Diagnose(ctx context.Context, taskConfig *skoopContext.TaskConfig) (string, error)
}

func NewDiagnoseController() DiagnoseController {
func NewDiagnoseController() Controller {
// 1. build skoop global context
return &diagnoser{}
}
Expand All @@ -29,7 +30,7 @@ func (d *diagnoser) Diagnose(ctx context.Context, taskConfig *skoopContext.TaskC
defer os.RemoveAll(tempDir)

resultStorage := fmt.Sprintf("%v/result.json", tempDir)
cmd := exec.Command("skoop", "--output", resultStorage, "--format", "json",
cmd := exec.CommandContext(ctx, "skoop", "--output", resultStorage, "--format", "json",
"-s", taskConfig.Source,
"-d", taskConfig.Destination.Address,
"--dport", strconv.FormatUint(uint64(taskConfig.Destination.Port), 10))
Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/graph/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package graph

import (
"fmt"
"strconv"

jsoniter "github.com/json-iterator/go"
"github.com/prometheus/common/model"
"github.com/samber/lo"
"strconv"
)

type Node struct {
Expand Down
5 changes: 3 additions & 2 deletions pkg/controller/rpc/controller.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/controller/rpc/controller_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions pkg/controller/service/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@ package service
import (
"context"
"fmt"
"sync/atomic"

"github.com/alibaba/kubeskoop/pkg/controller/rpc"
"github.com/samber/lo"
log "k8s.io/klog/v2"
"sync/atomic"
)

type taskWatcher struct {
taskChan chan *rpc.ServerTask
filter *rpc.TaskFilter
}

func (c *controller) RegisterAgent(ctx context.Context, info *rpc.AgentInfo) (*rpc.ControllerInfo, error) {
func (c *controller) RegisterAgent(_ context.Context, _ *rpc.AgentInfo) (*rpc.ControllerInfo, error) {
return nil, nil
}

func (c *controller) ReportEvents(server rpc.ControllerRegisterService_ReportEventsServer) error {
func (c *controller) ReportEvents(_ rpc.ControllerRegisterService_ReportEventsServer) error {
return nil
}

Expand Down Expand Up @@ -71,7 +72,7 @@ func (c *controller) GetAgentList() []*rpc.AgentInfo {
}

var (
taskIdx int64 = 0
taskIdx int64
)

func getTaskIdx() int64 {
Expand All @@ -97,9 +98,9 @@ func (c *controller) commitTask(node string, task *rpc.Task) ([]string, error) {
})
if len(commitedNode) > 0 {
return commitedNode, nil
} else {
return nil, fmt.Errorf("there is no client to process task: %v", task)
}

return nil, fmt.Errorf("there is no client to process task: %v", task)
}

func (c *controller) waitTaskResult(ctx context.Context, id string) (*rpc.TaskResult, error) {
Expand Down
Loading

0 comments on commit c436454

Please sign in to comment.