Skip to content

Commit

Permalink
feat: add a new field dataDirectory to specify the directory directly (
Browse files Browse the repository at this point in the history
…#400)

Signed-off-by: arkbriar <[email protected]>
  • Loading branch information
arkbriar authored Apr 12, 2023
1 parent 1862c9d commit 6b05647
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 0 deletions.
3 changes: 3 additions & 0 deletions apis/risingwave/v1alpha1/risingwave_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,9 @@ type RisingWaveObjectStorageHDFS struct {

// RisingWaveObjectStorage is the object storage for compute and compactor components.
type RisingWaveObjectStorage struct {
// DataDirectory is the directory to store the data in the object storage. It is an optional field.
DataDirectory string `json:"dataDirectory,omitempty"`

// Memory indicates to store the data in memory. It's only for test usage and strongly discouraged to
// be used in production.
// +optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10200,6 +10200,10 @@ spec:
- bucket
- secret
type: object
dataDirectory:
description: DataDirectory is the directory to store the data
in the object storage. It is an optional field.
type: string
hdfs:
description: HDFS storage spec.
properties:
Expand Down
4 changes: 4 additions & 0 deletions config/risingwave-operator-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17360,6 +17360,10 @@ spec:
- bucket
- secret
type: object
dataDirectory:
description: DataDirectory is the directory to store the data
in the object storage. It is an optional field.
type: string
hdfs:
description: HDFS storage spec.
properties:
Expand Down
4 changes: 4 additions & 0 deletions config/risingwave-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17360,6 +17360,10 @@ spec:
- bucket
- secret
type: object
dataDirectory:
description: DataDirectory is the directory to store the data
in the object storage. It is an optional field.
type: string
hdfs:
description: HDFS storage spec.
properties:
Expand Down
11 changes: 11 additions & 0 deletions docs/general/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2459,6 +2459,17 @@ MetaStorageType
<tbody>
<tr>
<td>
<code>dataDirectory</code><br/>
<em>
string
</em>
</td>
<td>
<p>DataDirectory is the directory to store the data in the object storage. It is an optional field.</p>
</td>
</tr>
<tr>
<td>
<code>memory</code><br/>
<em>
bool
Expand Down
5 changes: 5 additions & 0 deletions pkg/factory/risingwave_object_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ func (f *RisingWaveObjectFactory) envsForEtcd() []corev1.EnvVar {
func (f *RisingWaveObjectFactory) envsForMetaArgs() []corev1.EnvVar {
metaPorts := &f.risingwave.Spec.Components.Meta.Ports
metaStorage := &f.risingwave.Spec.Storages.Meta
objectStorage := f.risingwave.Spec.Storages.Object

connectorPorts := f.getConnectorPorts()
envVars := []corev1.EnvVar{
Expand All @@ -460,6 +461,10 @@ func (f *RisingWaveObjectFactory) envsForMetaArgs() []corev1.EnvVar {
Name: envs.RWStateStore,
Value: f.hummockConnectionStr(),
},
{
Name: envs.RWDataDirectory,
Value: objectStorage.DataDirectory,
},
{
Name: envs.RWDashboardHost,
Value: fmt.Sprintf("0.0.0.0:%d", metaPorts.DashboardPort),
Expand Down
24 changes: 24 additions & 0 deletions pkg/factory/risingwave_object_factory_testcases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2487,6 +2487,30 @@ type objectStoragesTestCase struct {

func objectStorageTestCases() map[string]objectStoragesTestCase {
return map[string]objectStoragesTestCase{
"empty_data_directory": {
objectStorage: risingwavev1alpha1.RisingWaveObjectStorage{
DataDirectory: "",
Memory: pointer.Bool(true),
},
envs: []corev1.EnvVar{
{
Name: "RW_DATA_DIRECTORY",
Value: "",
},
},
},
"some_data_directory": {
objectStorage: risingwavev1alpha1.RisingWaveObjectStorage{
DataDirectory: "1234",
Memory: pointer.Bool(true),
},
envs: []corev1.EnvVar{
{
Name: "RW_DATA_DIRECTORY",
Value: "1234",
},
},
},
"memory": {
objectStorage: risingwavev1alpha1.RisingWaveObjectStorage{
Memory: pointer.Bool(true),
Expand Down

0 comments on commit 6b05647

Please sign in to comment.