Skip to content

Commit

Permalink
cloudpb: move configuration protos
Browse files Browse the repository at this point in the history
A previous version of external connections persisted the
External Storage protos. Now we just persist the raw URI, and
so we can move these protos back.

Release note: None
  • Loading branch information
adityamaru committed Aug 10, 2022
1 parent c1d005c commit 62b625c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 29 deletions.
39 changes: 19 additions & 20 deletions pkg/cloud/cloudpb/external_storage.proto
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,14 @@ enum ExternalStorageProvider {
external = 9;
}

message LocalFileConfig {
string path = 1;
uint32 node_id = 2 [(gogoproto.customname) = "NodeID",
(gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/roachpb.NodeID"];
}

// ExternalConnectionConfig is the ExternalStorage configuration for the
// `external` provider.
message ExternalConnectionConfig {
// Name identifies the External Connection object.
string name = 1;
// User interacting with the external storage. This is used to check access
// privileges of the external connection object.
string user = 2;
// Path will be appended to the endpoint of the resource represented by the
// external connection object. It is used to access subdirectories/buckets of
// the external resource.
string path = 3;
}

message ExternalStorage {
ExternalStorageProvider provider = 1;

message LocalFileConfig {
string path = 1;
uint32 node_id = 2 [(gogoproto.customname) = "NodeID",
(gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/roachpb.NodeID"];
}
message Http {
string baseUri = 1;
}
Expand Down Expand Up @@ -127,6 +112,20 @@ message ExternalStorage {
// Path is the filename being read/written to via the FileTableSystem.
string path = 3;
}
// ExternalConnectionConfig is the ExternalStorage configuration for the
// `external` provider.
message ExternalConnectionConfig {
// Name identifies the External Connection object.
string name = 1;
// User interacting with the external storage. This is used to check access
// privileges of the external connection object.
string user = 2;
// Path will be appended to the endpoint of the resource represented by the
// external connection object. It is used to access subdirectories/buckets of
// the external resource.
string path = 3;
}

LocalFileConfig local_file_config = 2 [(gogoproto.nullable) = false];
Http HttpPath = 3 [(gogoproto.nullable) = false];
GCS GoogleCloudConfig = 4;
Expand Down
4 changes: 2 additions & 2 deletions pkg/cloud/externalconn/connection_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const scheme = "external"

func makeExternalConnectionConfig(
uri *url.URL, args cloud.ExternalStorageURIContext,
) (cloudpb.ExternalConnectionConfig, error) {
externalConnCfg := cloudpb.ExternalConnectionConfig{}
) (cloudpb.ExternalStorage_ExternalConnectionConfig, error) {
externalConnCfg := cloudpb.ExternalStorage_ExternalConnectionConfig{}
if uri.Host == "" {
return externalConnCfg, errors.Newf("host component of an external URI must refer to an "+
"existing External Connection object: %s", uri.String())
Expand Down
14 changes: 7 additions & 7 deletions pkg/cloud/nodelocal/nodelocal_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ func validateLocalFileURI(uri *url.URL) error {
return nil
}

func makeLocalFileConfig(uri *url.URL) (cloudpb.LocalFileConfig, error) {
localCfg := cloudpb.LocalFileConfig{}
func makeLocalFileConfig(uri *url.URL) (cloudpb.ExternalStorage_LocalFileConfig, error) {
localCfg := cloudpb.ExternalStorage_LocalFileConfig{}
nodeID, err := strconv.Atoi(uri.Host)
if err != nil {
return localCfg, errors.Errorf("host component of nodelocal URI must be a node ID: %s", uri.String())
Expand All @@ -85,11 +85,11 @@ func parseLocalFileURI(
}

type localFileStorage struct {
cfg cloudpb.LocalFileConfig // contains un-prefixed filepath -- DO NOT use for I/O ops.
ioConf base.ExternalIODirConfig // server configurations for the ExternalStorage
base string // relative filepath prefixed with externalIODir, for I/O ops on this node.
blobClient blobs.BlobClient // inter-node file sharing service
settings *cluster.Settings // cluster settings for the ExternalStorage
cfg cloudpb.ExternalStorage_LocalFileConfig // contains un-prefixed filepath -- DO NOT use for I/O ops.
ioConf base.ExternalIODirConfig // server configurations for the ExternalStorage
base string // relative filepath prefixed with externalIODir, for I/O ops on this node.
blobClient blobs.BlobClient // inter-node file sharing service
settings *cluster.Settings // cluster settings for the ExternalStorage
}

var _ cloud.ExternalStorage = &localFileStorage{}
Expand Down

0 comments on commit 62b625c

Please sign in to comment.