Skip to content

Commit

Permalink
Added changes (#4173)
Browse files Browse the repository at this point in the history
Signed-off-by: Siddhartha Chowdhuri <[email protected]>
  • Loading branch information
siddhartha97 authored May 5, 2021
1 parent 222e6e7 commit 7d118f4
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion cmd/thanos/downsample.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func downsampleBucket(
dir string,
hashFunc metadata.HashFunc,
) (rerr error) {
if err := os.MkdirAll(dir, 0777); err != nil {
if err := os.MkdirAll(dir, 0750); err != nil {
return errors.Wrap(err, "create dir")
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/thanos/receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ func migrateLegacyStorage(logger log.Logger, dataDir, defaultTenantID string) er
return errors.Wrapf(err, "read legacy data dir: %v", dataDir)
}

if err := os.MkdirAll(defaultTenantDataDir, 0777); err != nil {
if err := os.MkdirAll(defaultTenantDataDir, 0750); err != nil {
return errors.Wrapf(err, "create default tenant data dir: %v", defaultTenantDataDir)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/block/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const (
// have a hash calculated in the meta file and it matches with what is in the destination path then
// we do not download it. We always re-download the meta file.
func Download(ctx context.Context, logger log.Logger, bucket objstore.Bucket, id ulid.ULID, dst string) error {
if err := os.MkdirAll(dst, 0777); err != nil {
if err := os.MkdirAll(dst, 0750); err != nil {
return errors.Wrap(err, "create dir")
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/block/indexheader/binary_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ type FileWriter struct {

// TODO(bwplotka): Added size to method, upstream this.
func NewFileWriter(name string, size int) (*FileWriter, error) {
f, err := os.OpenFile(filepath.Clean(name), os.O_CREATE|os.O_RDWR, 0666)
f, err := os.OpenFile(filepath.Clean(name), os.O_CREATE|os.O_RDWR, 0600)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/block/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func NewDiskWriter(ctx context.Context, logger log.Logger, bDir string) (_ *Disk
if err = os.RemoveAll(bTmp); err != nil {
return nil, err
}
if err = os.MkdirAll(bTmp, 0777); err != nil {
if err = os.MkdirAll(bTmp, 0750); err != nil {
return nil, err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/compact/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ func (cg *Group) Compact(ctx context.Context, dir string, planner Planner, comp
}
}()

if err := os.MkdirAll(subDir, 0777); err != nil {
if err := os.MkdirAll(subDir, 0750); err != nil {
return false, ulid.ULID{}, errors.Wrap(err, "create compaction group dir")
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/compact/downsample/downsample.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func Downsample(

// Create block directory to populate with chunks, meta and index files into.
blockDir := filepath.Join(dir, uid.String())
if err := os.MkdirAll(blockDir, 0777); err != nil {
if err := os.MkdirAll(blockDir, 0750); err != nil {
return id, errors.Wrap(err, "mkdir block dir")
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/objstore/filesystem/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (b *Bucket) GetRange(_ context.Context, name string, off, length int64) (io
return nil, errors.Wrapf(err, "stat %s", file)
}

f, err := os.OpenFile(filepath.Clean(file), os.O_RDONLY, 0666)
f, err := os.OpenFile(filepath.Clean(file), os.O_RDONLY, 0600)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/objstore/objstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func DownloadFile(ctx context.Context, logger log.Logger, bkt BucketReader, src,

// DownloadDir downloads all object found in the directory into the local directory.
func DownloadDir(ctx context.Context, logger log.Logger, bkt BucketReader, originalSrc, src, dst string, ignoredPaths ...string) error {
if err := os.MkdirAll(dst, 0777); err != nil {
if err := os.MkdirAll(dst, 0750); err != nil {
return errors.Wrap(err, "create dir")
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/receive/multitsdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (t *tenant) set(storeTSDB *store.TSDBStore, tenantTSDB *tsdb.DB, ship *ship
}

func (t *MultiTSDB) Open() error {
if err := os.MkdirAll(t.dataDir, 0777); err != nil {
if err := os.MkdirAll(t.dataDir, 0750); err != nil {
return err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/reloader/reloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func (r *Reloader) apply(ctx context.Context) error {
defer func() {
_ = os.Remove(tmpFile)
}()
if err := ioutil.WriteFile(tmpFile, b, 0666); err != nil {
if err := ioutil.WriteFile(tmpFile, b, 0600); err != nil {
return errors.Wrap(err, "write file")
}
if err := os.Rename(tmpFile, r.cfgOutputFile); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/shipper/shipper.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ func (s *Shipper) upload(ctx context.Context, meta *metadata.Meta) error {
if err := os.RemoveAll(updir); err != nil {
return errors.Wrap(err, "clean upload directory")
}
if err := os.MkdirAll(updir, 0777); err != nil {
if err := os.MkdirAll(updir, 0750); err != nil {
return errors.Wrap(err, "create upload dir")
}
defer func() {
Expand Down Expand Up @@ -408,7 +408,7 @@ func (s *Shipper) blockMetasFromOldest() (metas []*metadata.Meta, _ error) {
func hardlinkBlock(src, dst string) error {
chunkDir := filepath.Join(dst, block.ChunksDirname)

if err := os.MkdirAll(chunkDir, 0777); err != nil {
if err := os.MkdirAll(chunkDir, 0750); err != nil {
return errors.Wrap(err, "create chunks dir")
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/store/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ func NewBucketStore(
s.indexReaderPool = indexheader.NewReaderPool(s.logger, lazyIndexReaderEnabled, lazyIndexReaderIdleTimeout, extprom.WrapRegistererWithPrefix("thanos_bucket_store_", s.reg))
s.metrics = newBucketStoreMetrics(s.reg) // TODO(metalmatze): Might be possible via Option too

if err := os.MkdirAll(dir, 0777); err != nil {
if err := os.MkdirAll(dir, 0750); err != nil {
return nil, errors.Wrap(err, "create dir")
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/copyright/copyright.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func applyLicenseToProtoAndGo() error {
var bb bytes.Buffer
_, _ = bb.Write(license)
_, _ = bb.Write(b)
if err = ioutil.WriteFile(path, bb.Bytes(), 0666); err != nil {
if err = ioutil.WriteFile(path, bb.Bytes(), 0600); err != nil {
return err
}
}
Expand Down
24 changes: 12 additions & 12 deletions test/e2e/e2ethanos/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ func DefaultImage() string {
func NewPrometheus(sharedDir string, name string, config, promImage string) (*e2e.HTTPService, string, error) {
dir := filepath.Join(sharedDir, "data", "prometheus", name)
container := filepath.Join(e2e.ContainerSharedDir, "data", "prometheus", name)
if err := os.MkdirAll(dir, 0777); err != nil {
if err := os.MkdirAll(dir, 0750); err != nil {
return nil, "", errors.Wrap(err, "create prometheus dir")
}

if err := ioutil.WriteFile(filepath.Join(dir, "prometheus.yml"), []byte(config), 0666); err != nil {
if err := ioutil.WriteFile(filepath.Join(dir, "prometheus.yml"), []byte(config), 0600); err != nil {
return nil, "", errors.Wrap(err, "creating prom config failed")
}

Expand Down Expand Up @@ -152,7 +152,7 @@ func NewQuerier(sharedDir, name string, storeAddresses, fileSDStoreAddresses, ru
if len(fileSDStoreAddresses) > 0 {
queryFileSDDir := filepath.Join(sharedDir, "data", "querier", name)
container := filepath.Join(e2e.ContainerSharedDir, "data", "querier", name)
if err := os.MkdirAll(queryFileSDDir, 0777); err != nil {
if err := os.MkdirAll(queryFileSDDir, 0750); err != nil {
return nil, errors.Wrap(err, "create query dir failed")
}

Expand All @@ -166,7 +166,7 @@ func NewQuerier(sharedDir, name string, storeAddresses, fileSDStoreAddresses, ru
return nil, err
}

if err := ioutil.WriteFile(queryFileSDDir+"/filesd.yaml", b, 0666); err != nil {
if err := ioutil.WriteFile(queryFileSDDir+"/filesd.yaml", b, 0600); err != nil {
return nil, errors.Wrap(err, "creating query SD config failed")
}

Expand Down Expand Up @@ -206,7 +206,7 @@ func NewReceiver(sharedDir string, networkName string, name string, replicationF
dir := filepath.Join(sharedDir, "data", "receive", name)
dataDir := filepath.Join(dir, "data")
container := filepath.Join(e2e.ContainerSharedDir, "data", "receive", name)
if err := os.MkdirAll(dataDir, 0777); err != nil {
if err := os.MkdirAll(dataDir, 0750); err != nil {
return nil, errors.Wrap(err, "create receive dir")
}
b, err := json.Marshal(hashring)
Expand Down Expand Up @@ -251,15 +251,15 @@ func NewReceiverWithConfigWatcher(sharedDir string, networkName string, name str
dir := filepath.Join(sharedDir, "data", "receive", name)
dataDir := filepath.Join(dir, "data")
container := filepath.Join(e2e.ContainerSharedDir, "data", "receive", name)
if err := os.MkdirAll(dataDir, 0777); err != nil {
if err := os.MkdirAll(dataDir, 0750); err != nil {
return nil, errors.Wrap(err, "create receive dir")
}
b, err := json.Marshal(hashring)
if err != nil {
return nil, errors.Wrapf(err, "generate hashring file: %v", hashring)
}

if err := ioutil.WriteFile(filepath.Join(dir, "hashrings.json"), b, 0666); err != nil {
if err := ioutil.WriteFile(filepath.Join(dir, "hashrings.json"), b, 0600); err != nil {
return nil, errors.Wrap(err, "creating receive config")
}

Expand Down Expand Up @@ -295,7 +295,7 @@ func NewReceiverWithConfigWatcher(sharedDir string, networkName string, name str
func NewRuler(sharedDir string, name string, ruleSubDir string, amCfg []alert.AlertmanagerConfig, queryCfg []query.Config) (*Service, error) {
dir := filepath.Join(sharedDir, "data", "rule", name)
container := filepath.Join(e2e.ContainerSharedDir, "data", "rule", name)
if err := os.MkdirAll(dir, 0777); err != nil {
if err := os.MkdirAll(dir, 0750); err != nil {
return nil, errors.Wrap(err, "create rule dir")
}

Expand Down Expand Up @@ -343,7 +343,7 @@ func NewRuler(sharedDir string, name string, ruleSubDir string, amCfg []alert.Al
func NewAlertmanager(sharedDir string, name string) (*e2e.HTTPService, error) {
dir := filepath.Join(sharedDir, "data", "am", name)
container := filepath.Join(e2e.ContainerSharedDir, "data", "am", name)
if err := os.MkdirAll(dir, 0777); err != nil {
if err := os.MkdirAll(dir, 0750); err != nil {
return nil, errors.Wrap(err, "create am dir")
}
const config = `
Expand All @@ -355,7 +355,7 @@ route:
receivers:
- name: 'null'
`
if err := ioutil.WriteFile(filepath.Join(dir, "config.yaml"), []byte(config), 0666); err != nil {
if err := ioutil.WriteFile(filepath.Join(dir, "config.yaml"), []byte(config), 0600); err != nil {
return nil, errors.Wrap(err, "creating alertmanager config file failed")
}

Expand All @@ -382,7 +382,7 @@ receivers:
func NewStoreGW(sharedDir string, name string, bucketConfig client.BucketConfig, relabelConfig ...relabel.Config) (*Service, error) {
dir := filepath.Join(sharedDir, "data", "store", name)
container := filepath.Join(e2e.ContainerSharedDir, "data", "store", name)
if err := os.MkdirAll(dir, 0777); err != nil {
if err := os.MkdirAll(dir, 0750); err != nil {
return nil, errors.Wrap(err, "create store dir")
}

Expand Down Expand Up @@ -428,7 +428,7 @@ func NewCompactor(sharedDir string, name string, bucketConfig client.BucketConfi
dir := filepath.Join(sharedDir, "data", "compact", name)
container := filepath.Join(e2e.ContainerSharedDir, "data", "compact", name)

if err := os.MkdirAll(dir, 0777); err != nil {
if err := os.MkdirAll(dir, 0750); err != nil {
return nil, errors.Wrap(err, "create compact dir")
}

Expand Down

0 comments on commit 7d118f4

Please sign in to comment.