fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

Fully revert windows support (#909)

We added support for Windows in https://github.com/sourcegraph/zoekt/pull/535. We then partially reverted the change, specifically the parts related to mmap (#706). This was okay because we no longer build for Windows.

This PR fully removes support to avoid being in a partially-implemented state.

+20 -191
+6
cmd/zoekt-sourcegraph-indexserver/meta.go
··· 8 8 9 9 "github.com/sourcegraph/zoekt" 10 10 "github.com/sourcegraph/zoekt/index" 11 + "golang.org/x/sys/unix" 11 12 ) 12 13 13 14 // mergeMeta updates the .meta files for the shards on disk for o. ··· 110 111 111 112 // respect process umask. build does this. 112 113 var umask os.FileMode 114 + 115 + func init() { 116 + umask = os.FileMode(unix.Umask(0)) 117 + unix.Umask(int(umask)) 118 + }
-14
cmd/zoekt-sourcegraph-indexserver/meta_unix.go
··· 1 - //go:build !windows 2 - 3 - package main 4 - 5 - import ( 6 - "os" 7 - 8 - "golang.org/x/sys/unix" 9 - ) 10 - 11 - func init() { 12 - umask = os.FileMode(unix.Umask(0)) 13 - unix.Umask(int(umask)) 14 - }
-6
cmd/zoekt-sourcegraph-indexserver/meta_windows.go
··· 1 - package main 2 - 3 - func init() { 4 - // no setting of file permissions on Windows 5 - umask = 0 6 - }
+5 -23
cmd/zoekt-webserver/main.go
··· 32 32 "os" 33 33 "os/signal" 34 34 "path/filepath" 35 - "runtime" 36 35 "strconv" 37 36 "strings" 38 37 "sync" ··· 45 44 "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc" 46 45 "golang.org/x/net/http2" 47 46 "golang.org/x/net/http2/h2c" 47 + "golang.org/x/sys/unix" 48 48 "google.golang.org/grpc" 49 49 50 50 "github.com/opentracing/opentracing-go" ··· 374 374 // times you will read the channel (used as buffer for signal.Notify). 375 375 func shutdownSignalChan(maxReads int) <-chan os.Signal { 376 376 c := make(chan os.Signal, maxReads) 377 - signal.Notify(c, os.Interrupt) // terminal C-c and goreman 378 - signal.Notify(c, PLATFORM_SIGTERM) // Kubernetes 377 + signal.Notify(c, os.Interrupt) // terminal C-c and goreman 378 + signal.Notify(c, unix.SIGTERM) // Kubernetes 379 379 return c 380 380 } 381 381 ··· 484 484 } 485 485 } 486 486 487 - func diskUsage(path string) (*disk.UsageStat, error) { 488 - duPath := path 489 - if runtime.GOOS == "windows" { 490 - duPath = filepath.VolumeName(duPath) 491 - } 492 - usage, err := disk.Usage(duPath) 493 - if err != nil { 494 - return nil, fmt.Errorf("diskUsage: %w", err) 495 - } 496 - return usage, err 497 - } 498 - 499 487 func mustRegisterDiskMonitor(path string) { 500 488 prometheus.MustRegister(prometheus.NewGaugeFunc(prometheus.GaugeOpts{ 501 489 Name: "src_disk_space_available_bytes", 502 490 Help: "Amount of free space disk space.", 503 491 ConstLabels: prometheus.Labels{"path": path}, 504 492 }, func() float64 { 505 - // I know there is no error handling here, and I don't like it 506 - // but there was no error handling in the previous version 507 - // that used Statfs, either, so I'm assuming there's no need for it 508 - usage, _ := diskUsage(path) 493 + usage, _ := disk.Usage(path) 509 494 return float64(usage.Free) 510 495 })) 511 496 ··· 514 499 Help: "Amount of total disk space.", 515 500 ConstLabels: prometheus.Labels{"path": path}, 516 501 }, func() float64 { 517 - // I know there is no error handling here, and I don't like it 518 - // but there was no error handling in the previous version 519 - // that used Statfs, either, so I'm assuming there's no need for it 520 - usage, _ := diskUsage(path) 502 + usage, _ := disk.Usage(path) 521 503 return float64(usage.Total) 522 504 })) 523 505 }
cmd/zoekt-webserver/main_linux.go cmd/zoekt-webserver/metrics.go
-9
cmd/zoekt-webserver/main_unix.go
··· 1 - //go:build !windows 2 - 3 - package main 4 - 5 - import ( 6 - platform "golang.org/x/sys/unix" 7 - ) 8 - 9 - const PLATFORM_SIGTERM = platform.SIGTERM
-18
cmd/zoekt-webserver/main_unsupported.go
··· 1 - //go:build !linux 2 - 3 - package main 4 - 5 - import ( 6 - sglog "github.com/sourcegraph/log" 7 - ) 8 - 9 - func mustRegisterMemoryMapMetrics(logger sglog.Logger) { 10 - // The memory map metrics are collected via /proc, which 11 - // is only available on linux-based operating systems. 12 - 13 - // as far as I can tell, Windows does not have the same 14 - // virtual memory statistics as Linux. 15 - // For example, Windows does not have the concept of 16 - // a count of memory maps, and a max number of memory maps 17 - return 18 - }
-7
cmd/zoekt-webserver/main_windows.go
··· 1 - package main 2 - 3 - import ( 4 - platform "golang.org/x/sys/windows" 5 - ) 6 - 7 - const PLATFORM_SIGTERM = platform.SIGTERM
+9 -3
index/builder.go
··· 40 40 "github.com/dustin/go-humanize" 41 41 "github.com/go-enry/go-enry/v2" 42 42 "github.com/rs/xid" 43 + "golang.org/x/sys/unix" 43 44 44 45 "github.com/sourcegraph/zoekt" 45 46 "github.com/sourcegraph/zoekt/internal/ctags" ··· 1090 1091 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) 1091 1092 } 1092 1093 1093 - // umask holds the Umask of the current process 1094 - var umask os.FileMode 1095 - 1096 1094 // Document holds a document (file) to index. 1097 1095 type Document struct { 1098 1096 Name string ··· 1113 1111 type DocumentSection struct { 1114 1112 Start, End uint32 1115 1113 } 1114 + 1115 + // umask holds the Umask of the current process 1116 + var umask os.FileMode 1117 + 1118 + func init() { 1119 + umask = os.FileMode(unix.Umask(0)) 1120 + unix.Umask(int(umask)) 1121 + }
-29
index/builder_unix.go
··· 1 - // Copyright 2018 Google Inc. All rights reserved. 2 - // 3 - // Licensed under the Apache License, Version 2.0 (the "License"); 4 - // you may not use this file except in compliance with the License. 5 - // You may obtain a copy of the License at 6 - // 7 - // http://www.apache.org/licenses/LICENSE-2.0 8 - // 9 - // Unless required by applicable law or agreed to in writing, software 10 - // distributed under the License is distributed on an "AS IS" BASIS, 11 - // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 - // See the License for the specific language governing permissions and 13 - // limitations under the License. 14 - // 15 - //go:build !windows && !wasm 16 - // +build !windows,!wasm 17 - 18 - package index 19 - 20 - import ( 21 - "os" 22 - 23 - "golang.org/x/sys/unix" 24 - ) 25 - 26 - func init() { 27 - umask = os.FileMode(unix.Umask(0)) 28 - unix.Umask(int(umask)) 29 - }
-62
index/indexfile_other.go
··· 1 - // Copyright 2016 Google Inc. All rights reserved. 2 - // 3 - // Licensed under the Apache License, Version 2.0 (the "License"); 4 - // you may not use this file except in compliance with the License. 5 - // You may obtain a copy of the License at 6 - // 7 - // http://www.apache.org/licenses/LICENSE-2.0 8 - // 9 - // Unless required by applicable law or agreed to in writing, software 10 - // distributed under the License is distributed on an "AS IS" BASIS, 11 - // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 - // See the License for the specific language governing permissions and 13 - // limitations under the License. 14 - 15 - //go:build !linux && !darwin 16 - // +build !linux,!darwin 17 - 18 - package index 19 - 20 - import ( 21 - "fmt" 22 - "os" 23 - ) 24 - 25 - // NewIndexFile returns a new index file. The index file takes 26 - // ownership of the passed in file, and may close it. 27 - func NewIndexFile(f *os.File) (IndexFile, error) { 28 - return &indexFileFromOS{f}, nil 29 - } 30 - 31 - type indexFileFromOS struct { 32 - f *os.File 33 - } 34 - 35 - func (f *indexFileFromOS) Read(off, sz uint32) ([]byte, error) { 36 - r := make([]byte, sz) 37 - _, err := f.f.ReadAt(r, int64(off)) 38 - return r, err 39 - } 40 - 41 - func (f indexFileFromOS) Size() (uint32, error) { 42 - fi, err := f.f.Stat() 43 - if err != nil { 44 - return 0, err 45 - } 46 - 47 - sz := fi.Size() 48 - 49 - if sz >= maxUInt32 { 50 - return 0, fmt.Errorf("overflow") 51 - } 52 - 53 - return uint32(sz), nil 54 - } 55 - 56 - func (f indexFileFromOS) Close() { 57 - f.f.Close() 58 - } 59 - 60 - func (f indexFileFromOS) Name() string { 61 - return f.f.Name() 62 - }
index/indexfile_unix.go index/indexfile.go
-14
index/tombstones_unix.go
··· 1 - //go:build !windows && !wasm 2 - 3 - package index 4 - 5 - import ( 6 - "os" 7 - 8 - "golang.org/x/sys/unix" 9 - ) 10 - 11 - func init() { 12 - umask = os.FileMode(unix.Umask(0)) 13 - unix.Umask(int(umask)) 14 - }
-6
index/tombstones_windows.go
··· 1 - package index 2 - 3 - func init() { 4 - // no setting of file permissions on Windows 5 - umask = 0 6 - }