Skip to content
Merged
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
6 changes: 6 additions & 0 deletions cmd/zoekt-sourcegraph-indexserver/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/sourcegraph/zoekt"
"github.com/sourcegraph/zoekt/index"
"golang.org/x/sys/unix"
)

// mergeMeta updates the .meta files for the shards on disk for o.
Expand Down Expand Up @@ -110,3 +111,8 @@ func jsonMarshalTmpFile(v interface{}, p string) (_ string, err error) {

// respect process umask. build does this.
var umask os.FileMode

func init() {
umask = os.FileMode(unix.Umask(0))
unix.Umask(int(umask))
}
14 changes: 0 additions & 14 deletions cmd/zoekt-sourcegraph-indexserver/meta_unix.go

This file was deleted.

6 changes: 0 additions & 6 deletions cmd/zoekt-sourcegraph-indexserver/meta_windows.go

This file was deleted.

28 changes: 5 additions & 23 deletions cmd/zoekt-webserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
"os"
"os/signal"
"path/filepath"
"runtime"
"strconv"
"strings"
"sync"
Expand All @@ -45,6 +44,7 @@ import (
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"golang.org/x/net/http2"
"golang.org/x/net/http2/h2c"
"golang.org/x/sys/unix"
"google.golang.org/grpc"

"github.com/opentracing/opentracing-go"
Expand Down Expand Up @@ -374,8 +374,8 @@ func addProxyHandler(mux *http.ServeMux, socket string) {
// times you will read the channel (used as buffer for signal.Notify).
func shutdownSignalChan(maxReads int) <-chan os.Signal {
c := make(chan os.Signal, maxReads)
signal.Notify(c, os.Interrupt) // terminal C-c and goreman
signal.Notify(c, PLATFORM_SIGTERM) // Kubernetes
signal.Notify(c, os.Interrupt) // terminal C-c and goreman
signal.Notify(c, unix.SIGTERM) // Kubernetes
return c
}

Expand Down Expand Up @@ -484,28 +484,13 @@ Possible remediations:
}
}

func diskUsage(path string) (*disk.UsageStat, error) {
duPath := path
if runtime.GOOS == "windows" {
duPath = filepath.VolumeName(duPath)
}
usage, err := disk.Usage(duPath)
if err != nil {
return nil, fmt.Errorf("diskUsage: %w", err)
}
return usage, err
}

func mustRegisterDiskMonitor(path string) {
prometheus.MustRegister(prometheus.NewGaugeFunc(prometheus.GaugeOpts{
Name: "src_disk_space_available_bytes",
Help: "Amount of free space disk space.",
ConstLabels: prometheus.Labels{"path": path},
}, func() float64 {
// I know there is no error handling here, and I don't like it
// but there was no error handling in the previous version
// that used Statfs, either, so I'm assuming there's no need for it
usage, _ := diskUsage(path)
usage, _ := disk.Usage(path)
return float64(usage.Free)
}))

Expand All @@ -514,10 +499,7 @@ func mustRegisterDiskMonitor(path string) {
Help: "Amount of total disk space.",
ConstLabels: prometheus.Labels{"path": path},
}, func() float64 {
// I know there is no error handling here, and I don't like it
// but there was no error handling in the previous version
// that used Statfs, either, so I'm assuming there's no need for it
usage, _ := diskUsage(path)
usage, _ := disk.Usage(path)
return float64(usage.Total)
}))
}
Expand Down
9 changes: 0 additions & 9 deletions cmd/zoekt-webserver/main_unix.go

This file was deleted.

18 changes: 0 additions & 18 deletions cmd/zoekt-webserver/main_unsupported.go

This file was deleted.

7 changes: 0 additions & 7 deletions cmd/zoekt-webserver/main_windows.go

This file was deleted.

File renamed without changes.
12 changes: 9 additions & 3 deletions index/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"github.com/dustin/go-humanize"
"github.com/go-enry/go-enry/v2"
"github.com/rs/xid"
"golang.org/x/sys/unix"

"github.com/sourcegraph/zoekt"
"github.com/sourcegraph/zoekt/internal/ctags"
Expand Down Expand Up @@ -1090,9 +1091,6 @@ func (e *deltaIndexOptionsMismatchError) Error() string {
return fmt.Sprintf("one or more index options for shard %q do not match Builder's index options. These index option updates are incompatible with delta build. New index options: %+v", e.shardName, e.newOptions)
}

// umask holds the Umask of the current process
var umask os.FileMode

// Document holds a document (file) to index.
type Document struct {
Name string
Expand All @@ -1113,3 +1111,11 @@ type Document struct {
type DocumentSection struct {
Start, End uint32
}

// umask holds the Umask of the current process
var umask os.FileMode

func init() {
umask = os.FileMode(unix.Umask(0))
unix.Umask(int(umask))
}
29 changes: 0 additions & 29 deletions index/builder_unix.go

This file was deleted.

File renamed without changes.
62 changes: 0 additions & 62 deletions index/indexfile_other.go

This file was deleted.

14 changes: 0 additions & 14 deletions index/tombstones_unix.go

This file was deleted.

6 changes: 0 additions & 6 deletions index/tombstones_windows.go

This file was deleted.

Loading