fix: sql scan error on remote bucket id when replication to 1.x (#23826)
parent
3ac7a10aa9
commit
55b7d29e4f
|
@ -107,11 +107,11 @@ func (r *UpdateReplicationRequest) OK() error {
|
|||
// ReplicationHTTPConfig contains all info needed by a client to make HTTP requests against the
|
||||
// remote bucket targeted by a replication.
|
||||
type ReplicationHTTPConfig struct {
|
||||
RemoteURL string `db:"remote_url"`
|
||||
RemoteToken string `db:"remote_api_token"`
|
||||
RemoteOrgID platform.ID `db:"remote_org_id"`
|
||||
AllowInsecureTLS bool `db:"allow_insecure_tls"`
|
||||
RemoteBucketID platform.ID `db:"remote_bucket_id"`
|
||||
RemoteBucketName string `db:"remote_bucket_name"`
|
||||
DropNonRetryableData bool `db:"drop_non_retryable_data"`
|
||||
RemoteURL string `db:"remote_url"`
|
||||
RemoteToken string `db:"remote_api_token"`
|
||||
RemoteOrgID platform.ID `db:"remote_org_id"`
|
||||
AllowInsecureTLS bool `db:"allow_insecure_tls"`
|
||||
RemoteBucketID *platform.ID `db:"remote_bucket_id"`
|
||||
RemoteBucketName string `db:"remote_bucket_name"`
|
||||
DropNonRetryableData bool `db:"drop_non_retryable_data"`
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ var (
|
|||
RemoteToken: replication.RemoteID.String(),
|
||||
RemoteOrgID: platform.ID(888888),
|
||||
AllowInsecureTLS: true,
|
||||
RemoteBucketID: *replication.RemoteBucketID,
|
||||
RemoteBucketID: replication.RemoteBucketID,
|
||||
}
|
||||
newRemoteID = platform.ID(200)
|
||||
newQueueSize = influxdb.MinReplicationMaxQueueSizeBytes
|
||||
|
|
|
@ -208,9 +208,11 @@ func PostWrite(ctx context.Context, config *influxdb.ReplicationHTTPConfig, data
|
|||
conf.HTTPClient.Timeout = timeout
|
||||
client := api.NewAPIClient(conf).WriteApi
|
||||
|
||||
bucket := config.RemoteBucketID.String()
|
||||
if config.RemoteBucketName != "" {
|
||||
var bucket string
|
||||
if config.RemoteBucketID == nil || config.RemoteBucketName != "" {
|
||||
bucket = config.RemoteBucketName
|
||||
} else {
|
||||
bucket = config.RemoteBucketID.String()
|
||||
}
|
||||
|
||||
req := client.PostWrite(ctx).
|
||||
|
|
|
@ -170,7 +170,7 @@ func (s *service) ValidateNewReplication(ctx context.Context, request influxdb.C
|
|||
return errLocalBucketNotFound(request.LocalBucketID, err)
|
||||
}
|
||||
|
||||
config := influxdb.ReplicationHTTPConfig{RemoteBucketID: request.RemoteBucketID}
|
||||
config := influxdb.ReplicationHTTPConfig{RemoteBucketID: &request.RemoteBucketID}
|
||||
if err := s.store.PopulateRemoteHTTPConfig(ctx, request.RemoteID, &config); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ func (s *service) ValidateUpdatedReplication(ctx context.Context, id platform.ID
|
|||
return err
|
||||
}
|
||||
if request.RemoteBucketID != nil {
|
||||
baseConfig.RemoteBucketID = *request.RemoteBucketID
|
||||
baseConfig.RemoteBucketID = request.RemoteBucketID
|
||||
}
|
||||
|
||||
if request.RemoteID != nil {
|
||||
|
|
|
@ -94,7 +94,7 @@ var (
|
|||
RemoteToken: replication1.RemoteID.String(),
|
||||
RemoteOrgID: platform.ID(888888),
|
||||
AllowInsecureTLS: true,
|
||||
RemoteBucketID: *replication1.RemoteBucketID,
|
||||
RemoteBucketID: replication1.RemoteBucketID,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -295,7 +295,7 @@ func TestValidateNewReplication(t *testing.T) {
|
|||
|
||||
mocks.bucketSvc.EXPECT().FindBucketByID(gomock.Any(), tt.req.LocalBucketID).Return(nil, tt.bucketErr)
|
||||
|
||||
testConfig := &influxdb.ReplicationHTTPConfig{RemoteBucketID: tt.req.RemoteBucketID}
|
||||
testConfig := &influxdb.ReplicationHTTPConfig{RemoteBucketID: &tt.req.RemoteBucketID}
|
||||
if tt.bucketErr == nil {
|
||||
mocks.serviceStore.EXPECT().PopulateRemoteHTTPConfig(gomock.Any(), tt.req.RemoteID, testConfig).Return(tt.storeErr)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue