Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 489: Added support for custom storage option in long term storage #585

Merged
merged 7 commits into from
Oct 25, 2021

Conversation

anishakj
Copy link
Contributor

@anishakj anishakj commented Oct 20, 2021

Signed-off-by: anishakj [email protected]

Change log description

Adding a new field for custom storage in longtermstoragespec

Purpose of the change

Fixes #489

What the code does

Currently, operator supports HDFS, ECS and filesystem as longtermstorage options, added support for custom storage so that users can provide required options and env variables based on the storage type selected.

We can also pass env varaibles via segmentStoreEnvVars. But in case,if we do not set longtermstorage type, it can cause conflicts

How to verify it

Example of helm charts with s3 as custom storage

storage:
  longtermStorage:
    type: custom
    custom:
      options:
        pravegaservice.storage.layout: "CHUNKED_STORAGE"
        pravegaservice.storage.impl.name: "S3"
        s3.bucket: bucketname
        s3.prefix: "10-11-1"
        s3.connect.config.uri.override: "false"
        s3.connect.config.uri: uri
        s3.connect.config.access.key: keyname
        s3.connect.config.secret.key: keyvalue
      env:
        TIER2_STORAGE: "S3"
        AWS_ACCESS_KEY_ID: "key"
        AWS_SECRET_ACCESS_KEY: "secret"

Verified that able to install pravega with S3 as custom storage, also ran system tests

@codecov-commenter
Copy link

codecov-commenter commented Oct 20, 2021

Codecov Report

Merging #585 (437b7fd) into master (7af939a) will increase coverage by 0.17%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #585      +/-   ##
==========================================
+ Coverage   74.17%   74.35%   +0.17%     
==========================================
  Files          16       16              
  Lines        4229     4258      +29     
==========================================
+ Hits         3137     3166      +29     
  Misses        962      962              
  Partials      130      130              
Impacted Files Coverage Δ
pkg/apis/pravega/v1beta1/pravega.go 98.34% <100.00%> (ø)
pkg/apis/pravega/v1beta1/zz_generated.deepcopy.go 99.47% <100.00%> (+0.03%) ⬆️
pkg/controller/pravega/pravega_segmentstore.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7af939a...437b7fd. Read the comment docs.

@@ -511,3 +514,8 @@ type HDFSSpec struct {
// +optional
ReplicationFactor int32 `json:"replicationFactor"`
}

type CustomSpec struct {
Options map[string]string `json:"options"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Options map[string]string `json:"options"`
Options map[string]string `json:"options,omitempty"`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anishakj @nishant-yt Is there a use case when only one of options,env blocks would have to be supplied?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, if custom option is mentioned both params needs to be provided

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anishakj looking at pravega_segmentstore.go code, the Options map here *can` be optional. Please, take the change suggested by @nishant-yt here and make it not required on the CRD.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


type CustomSpec struct {
Options map[string]string `json:"options"`
Env map[string]string `json:"env"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Env map[string]string `json:"env"`
Env map[string]string `json:"env,omitempty"`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This spec is actually needed to override the TIER2_STORAGE env variable (though it would be better to have a separate required parameter for exactly this value).

Copy link
Collaborator

@nishant-yt nishant-yt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested changes

@jkhalack
Copy link

@anishakj Could you add some (commented out) example on how this issue might be used to the helm chart (https://github.com/pravega/pravega-operator/blob/master/charts/pravega/values.yaml#L107), please?

@anishakj
Copy link
Contributor Author

@anishakj Could you add some (commented out) example on how this issue might be used to the helm chart (https://github.com/pravega/pravega-operator/blob/master/charts/pravega/values.yaml#L107), please?

have to create separate PR for that in Pravega/charts repo. Charts repo here is deprecated

@jkhalack
Copy link

@anishakj Could you add some (commented out) example on how this issue might be used to the helm chart (https://github.com/pravega/pravega-operator/blob/master/charts/pravega/values.yaml#L107), please?

have to create separate PR for that in Pravega/charts repo. Charts repo here is deprecated

Would you at least add it to the PR description?

@anishakj
Copy link
Contributor Author

@anishakj Could you add some (commented out) example on how this issue might be used to the helm chart (https://github.com/pravega/pravega-operator/blob/master/charts/pravega/values.yaml#L107), please?

have to create separate PR for that in Pravega/charts repo. Charts repo here is deprecated

Would you at least add it to the PR description?

Values need to be used in helm chart are added in PR description.

@jkhalack
Copy link

@anishakj would you please amend the PR description to elaborate on the use of TIER2_STORAGE env variable and why we cannot use the pre-existing segmentStoreEnvVars field and add the custom options under the common options block on PravegaCluster resource.

Apparently, the existing code would set TIER2_STORAGE to one of the three hard-coded values (FILESYSTEM, EXTENDEDS3, or HDFS) along with adding some extra options and env variables.
The primary purpose of this PR (if I understand it correctly) is to not set any of the above three storage option and allow the user to configure something different, for example set TIER2_STORAGE to S3 when deploying on AWS.

@@ -362,6 +367,13 @@ func getTier2StorageOptions(pravegaSpec *api.PravegaSpec) map[string]string {
}
}

if pravegaSpec.LongTermStorage.Custom != nil {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be an indentation issue within getTier2StorageOptions() function.
if pravegaSpec.LongTermStorage.Custom != nil has a different indentation as compared to the above three if blocks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -284,6 +284,12 @@ func MakeSegmentstoreConfigMap(p *api.PravegaCluster) *corev1.ConfigMap {
javaOpts = append(javaOpts, fmt.Sprintf("-D%v=%v", name, value))
}

if p.Spec.Pravega.LongTermStorage.Custom != nil {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... There is nothing saying that the storage options cannot be included by the customer into p.Spec.Pravega.Options (the current practice is to include both controller and segment store java options there, and if needed only in the segment store, the option is ignored by the controller).
So p.Spec.Pravega.LongTermStorage.Custom.Options can be optional.

@@ -511,3 +514,8 @@ type HDFSSpec struct {
// +optional
ReplicationFactor int32 `json:"replicationFactor"`
}

type CustomSpec struct {
Options map[string]string `json:"options"`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anishakj looking at pravega_segmentstore.go code, the Options map here *can` be optional. Please, take the change suggested by @nishant-yt here and make it not required on the CRD.


type CustomSpec struct {
Options map[string]string `json:"options"`
Env map[string]string `json:"env"`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This spec is actually needed to override the TIER2_STORAGE env variable (though it would be better to have a separate required parameter for exactly this value).

type: object
required:
- env
- options

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, remove the options block from the list of required parameters.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Signed-off-by: anishakj <[email protected]>
Signed-off-by: anishakj <[email protected]>
Signed-off-by: anishakj <[email protected]>
Copy link

@jkhalack jkhalack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -238,3 +238,34 @@ spec:
root: /example
replicationFactor: 3
```

### Use Custom Storage as LongTermStorage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add the heading of this section to the contents in the beginning of the doc too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -362,6 +367,13 @@ func getTier2StorageOptions(pravegaSpec *api.PravegaSpec) map[string]string {
}
}

if pravegaSpec.LongTermStorage.Custom != nil {
if pravegaSpec.LongTermStorage.Custom.Env != nil {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Can we remove the extra line here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Contributor

@SrishT SrishT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@nishant-yt nishant-yt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@anishakj anishakj merged commit f833dc5 into master Oct 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot configure AWS S3 Tier2 storage in Helm chart
5 participants