You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by "aliyasirnac (via GitHub)" <gi...@apache.org> on 2026/03/09 15:47:49 UTC

[PR] Support relative paths in configuration [skywalking-banyandb]

aliyasirnac opened a new pull request, #996:
URL: https://github.com/apache/skywalking-banyandb/pull/996

   ### Support relative paths in configuration
   This PR adds support for relative paths across all core BanyanDB components (Measure, Stream, Trace, Metadata, Gossip) using a new `banyandbpath.Get` centralized helper. Configuration paths like root data directories, TLS certs, and keys can now be defined relatively, improving environment portability.
   
   - [ ] If this is non-trivial feature, paste the links/URLs to the design doc.
   - [ ] Update the documentation to include this new feature.
   - [x] Tests(including UT, IT, E2E) are added to verify the new feature.
   - [ ] If it's UI related, attach the screenshots below.
   
   - [x] If this pull request closes/resolves/fixes an existing issue, replace the issue number. Fixes apache/skywalking#13698.
   - [x] Update the [`CHANGES` log](https://github.com/apache/skywalking-banyandb/blob/main/CHANGES.md).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support relative paths in configuration [skywalking-banyandb]

Posted by "hanahmily (via GitHub)" <gi...@apache.org>.
hanahmily commented on PR #996:
URL: https://github.com/apache/skywalking-banyandb/pull/996#issuecomment-4027741895

   @aliyasirnac CI check failed.  You can use the "make lint" task to check the linting errors locally. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support relative paths in configuration [skywalking-banyandb]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #996:
URL: https://github.com/apache/skywalking-banyandb/pull/996#discussion_r2906380431


##########
pkg/path/path_test.go:
##########
@@ -0,0 +1,82 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you under
+// the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package path
+
+import (
+	"os"
+	"path/filepath"
+	"testing"
+)
+
+func TestGet(t *testing.T) {
+	wd, err := os.Getwd()
+	if err != nil {
+		t.Fatalf("failed to get working directory: %v", err)
+	}
+
+	tests := []struct {
+		name    string
+		input   string
+		want    string
+		wantErr bool
+	}{
+		{
+			name:    "empty string",
+			input:   "",
+			want:    "",
+			wantErr: false,
+		},
+		{
+			name:    "absolute path",
+			input:   "/tmp/test",
+			want:    filepath.Clean("/tmp/test"),
+			wantErr: false,
+		},

Review Comment:
   This test hard-codes a Unix-style absolute path (`/tmp/test`), which can behave differently or fail on Windows (volume-less rooted paths, path semantics). Consider generating an OS-appropriate absolute path (e.g., based on `t.TempDir()` and `filepath.Join`) so the test is cross-platform.



##########
pkg/path/path.go:
##########
@@ -0,0 +1,34 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you under
+// the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// Package path provides utilities to resolve relative paths to absolute paths.
+package path
+
+import (
+	"path/filepath"
+)
+
+// Get resolves the given path to an absolute path.
+// If the path is empty, it returns an empty string.
+// If the path is already absolute, it returns the path as is.
+// Otherwise, it returns the absolute path relative to the current working directory.
+func Get(p string) (string, error) {
+	if p == "" {
+		return "", nil
+	}
+	return filepath.Abs(p)
+}

Review Comment:
   `filepath.Abs` will `Clean` the path (even when already absolute), so the comment 'returns the path as is' is not strictly accurate. Update the doc to reflect that it returns a cleaned absolute path (or implement the exact behavior described).



##########
banyand/trace/svc_standalone.go:
##########
@@ -136,6 +137,15 @@ func (s *standalone) PreRun(ctx context.Context) error {
 	s.l = logger.GetLogger(s.Name())
 	s.l.Info().Msg("memory protector is initialized in PreRun")
 	s.lfs = fs.NewLocalFileSystemWithLoggerAndLimit(s.l, s.pm.GetLimit())
+	var err error
+	if s.root, err = banyandbpath.Get(s.root); err != nil {
+		return err
+	}
+	if s.dataPath != "" {
+		if s.dataPath, err = banyandbpath.Get(s.dataPath); err != nil {
+			return err
+		}

Review Comment:
   `banyandbpath.Get` already treats an empty string as a no-op (`\"\" → \"\"` with nil error), so the `if s.dataPath != \"\"` guard is redundant. You can simplify and standardize these call sites to always call `Get` for optional paths, which reduces boilerplate across services.
   ```suggestion
   	if s.dataPath, err = banyandbpath.Get(s.dataPath); err != nil {
   		return err
   ```



##########
banyand/metadata/client.go:
##########
@@ -263,6 +264,40 @@ func (s *clientService) PreRun(ctx context.Context) error {
 		}
 	}()
 
+	var err error
+	if s.etcdTLSCAFile != "" {
+		if s.etcdTLSCAFile, err = banyandbpath.Get(s.etcdTLSCAFile); err != nil {
+			return err
+		}
+	}
+	if s.etcdTLSCertFile != "" {
+		if s.etcdTLSCertFile, err = banyandbpath.Get(s.etcdTLSCertFile); err != nil {
+			return err
+		}
+	}
+	if s.etcdTLSKeyFile != "" {
+		if s.etcdTLSKeyFile, err = banyandbpath.Get(s.etcdTLSKeyFile); err != nil {
+			return err
+		}
+	}
+	if s.propertySchemaClientCACert != "" {
+		if s.propertySchemaClientCACert, err = banyandbpath.Get(s.propertySchemaClientCACert); err != nil {
+			return err
+		}
+	}
+	if s.filePath != "" {
+		if s.filePath, err = banyandbpath.Get(s.filePath); err != nil {
+			return err

Review Comment:
   Returning the raw error here loses field-level context (which path failed to resolve). Wrap the error with a message including the specific config field (e.g., `etcdTLSCAFile`) so operators can diagnose misconfiguration more quickly.
   ```suggestion
   			return errors.Wrapf(err, "failed to resolve path for etcdTLSCAFile %q", s.etcdTLSCAFile)
   		}
   	}
   	if s.etcdTLSCertFile != "" {
   		if s.etcdTLSCertFile, err = banyandbpath.Get(s.etcdTLSCertFile); err != nil {
   			return errors.Wrapf(err, "failed to resolve path for etcdTLSCertFile %q", s.etcdTLSCertFile)
   		}
   	}
   	if s.etcdTLSKeyFile != "" {
   		if s.etcdTLSKeyFile, err = banyandbpath.Get(s.etcdTLSKeyFile); err != nil {
   			return errors.Wrapf(err, "failed to resolve path for etcdTLSKeyFile %q", s.etcdTLSKeyFile)
   		}
   	}
   	if s.propertySchemaClientCACert != "" {
   		if s.propertySchemaClientCACert, err = banyandbpath.Get(s.propertySchemaClientCACert); err != nil {
   			return errors.Wrapf(err, "failed to resolve path for propertySchemaClientCACert %q", s.propertySchemaClientCACert)
   		}
   	}
   	if s.filePath != "" {
   		if s.filePath, err = banyandbpath.Get(s.filePath); err != nil {
   			return errors.Wrapf(err, "failed to resolve path for filePath %q", s.filePath)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support relative paths in configuration [skywalking-banyandb]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #996:
URL: https://github.com/apache/skywalking-banyandb/pull/996#issuecomment-4027944422

   ## [Codecov](https://app.codecov.io/gh/apache/skywalking-banyandb/pull/996?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 30.03%. Comparing base ([`3530dd9`](https://app.codecov.io/gh/apache/skywalking-banyandb/commit/3530dd9b5cefaa4fef60eec91ecbfbdfcaf243c5?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`5ab4040`](https://app.codecov.io/gh/apache/skywalking-banyandb/commit/5ab4040ecd5d0c895351be05004be66848b7463b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 147 commits behind head on main.
   > :exclamation:  There is a different number of reports uploaded between BASE (3530dd9) and HEAD (5ab4040). Click for more details.
   > 
   > <details><summary>HEAD has 1 upload less than BASE</summary>
   >
   >| Flag | BASE (3530dd9) | HEAD (5ab4040) |
   >|------|------|------|
   >||1|0|
   ></details>
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff             @@
   ##             main     #996       +/-   ##
   ===========================================
   - Coverage   45.97%   30.03%   -15.95%     
   ===========================================
     Files         328      123      -205     
     Lines       55505    12850    -42655     
   ===========================================
   - Hits        25520     3859    -21661     
   + Misses      27909     8619    -19290     
   + Partials     2076      372     -1704     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/skywalking-banyandb/pull/996/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [pkg](https://app.codecov.io/gh/apache/skywalking-banyandb/pull/996/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `30.03% <100.00%> (?)` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/skywalking-banyandb/pull/996?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Support relative paths in configuration [skywalking-banyandb]

Posted by "hanahmily (via GitHub)" <gi...@apache.org>.
hanahmily merged PR #996:
URL: https://github.com/apache/skywalking-banyandb/pull/996


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org