Skip to content

Commit

Permalink
fix: specify empty logDir when only log to stdout (#210)
Browse files Browse the repository at this point in the history
* fix: specify empty logDir when only log to stdout

* fix: e2e failed
  • Loading branch information
zyy17 authored Nov 11, 2024
1 parent b391b6e commit fb1137f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
13 changes: 10 additions & 3 deletions pkg/dbconfig/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,19 @@ func (c *LoggingConfig) ConfigureLogging(spec *v1alpha1.LoggingSpec) {
return
}

if spec.IsOnlyLogToStdout() {
c.Dir = nil
} else if spec.LogsDir != "" {
// Default to empty string.
c.Dir = pointer.String("")

// If logsDir is set, use it as the log directory.
if len(spec.LogsDir) > 0 {
c.Dir = pointer.String(spec.LogsDir)
}

// If only log to stdout, disable log to file even if logsDir is set.
if spec.IsOnlyLogToStdout() {
c.Dir = pointer.String("")
}

c.Level = pointer.String(c.levelWithFilters(string(spec.Level), spec.Filters))
c.LogFormat = pointer.String(string(spec.Format))

Expand Down
5 changes: 2 additions & 3 deletions tests/e2e/greptimedbcluster/test_cluster_enable_monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,9 @@ func TestClusterEnableMonitoring(ctx context.Context, h *helper.Helper) {

// Disable monitoring.
By("Disable monitoring")
originalCluster := testCluster.DeepCopy()
testCluster.Spec.Monitoring.Enabled = false
Eventually(func() error {
return h.Update(ctx, testCluster)
}, helper.DefaultTimeout, time.Second).ShouldNot(HaveOccurred(), "failed to update cluster")
Expect(h.Patch(ctx, testCluster, client.MergeFrom(originalCluster))).NotTo(HaveOccurred(), "failed to patch cluster")

By("Check the status of testCluster")
Eventually(func() error {
Expand Down

0 comments on commit fb1137f

Please sign in to comment.