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

SDKQE-3419: Support load-sample buckets for cloud columnar and clusters #66

Merged
merged 2 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions deployment/clouddeploy/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,12 @@ func (p *Deployer) listClusters(ctx context.Context) ([]*clusterInfo, error) {
continue
}

clusters := getColumnarsForProject(project.Data.ID)
columnars := getColumnarsForProject(project.Data.ID)

if len(clusters) == 0 {
out = append(out, &clusterInfo{
Meta: meta,
Project: project.Data,
Cluster: nil,
IsCorrupted: false,
})
if len(columnars) == 0 {
// Operational cluster
continue
} else if len(clusters) > 1 {
} else if len(columnars) > 1 {
out = append(out, &clusterInfo{
Meta: meta,
Project: project.Data,
Expand All @@ -197,12 +192,12 @@ func (p *Deployer) listClusters(ctx context.Context) ([]*clusterInfo, error) {
continue
}

cluster := clusters[0]
columnar := columnars[0]

out = append(out, &clusterInfo{
Meta: meta,
Project: project.Data,
Columnar: cluster,
Columnar: columnar,
IsCorrupted: false,
})
}
Expand Down Expand Up @@ -1797,7 +1792,16 @@ func (p *Deployer) DeleteBucket(ctx context.Context, clusterID string, bucketNam
}

func (d *Deployer) LoadSampleBucket(ctx context.Context, clusterID string, bucketName string) error {
return errors.New("clouddeploy does not support loading sample buckets")
clusterInfo, err := d.getCluster(ctx, clusterID)
if err != nil {
return err
}
if clusterInfo.Columnar == nil {
req := &capellacontrol.LoadSampleBucketRequest{Name: bucketName}
return d.mgr.Client.LoadClusterSampleBucket(ctx, clusterInfo.Cluster.TenantId, clusterInfo.Cluster.Project.Id, clusterInfo.Cluster.Id, req)
}
req := &capellacontrol.LoadColumnarSampleBucketRequest{SampleName: bucketName}
return d.mgr.Client.LoadColumnarSampleBucket(ctx, clusterInfo.Columnar.TenantID, clusterInfo.Columnar.ProjectID, clusterInfo.Columnar.ID, req)
}

func (p *Deployer) GetCertificate(ctx context.Context, clusterID string) (string, error) {
Expand Down
38 changes: 38 additions & 0 deletions utils/capellacontrol/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1600,3 +1600,41 @@ func (c *Controller) RedeployCluster(

return err
}

type LoadColumnarSampleBucketRequest struct {
SampleName string `url:"sampleName"`
}

func (c *Controller) LoadColumnarSampleBucket(
ctx context.Context,
tenantID, projectID, clusterID string,
req *LoadColumnarSampleBucketRequest,
) error {

form, _ := query.Values(req)
path := fmt.Sprintf("/v2/organizations/%s/projects/%s/instance/%s/proxy/api/v1/samples?%s", tenantID, projectID, clusterID, form.Encode())
err := c.doBasicReq(ctx, false, "POST", path, req, nil)
if err != nil {
return err
}

return err
}

type LoadSampleBucketRequest struct {
Name string `json:"name"`
}

func (c *Controller) LoadClusterSampleBucket(
ctx context.Context,
tenantID, projectID, clusterID string,
req *LoadSampleBucketRequest,
) error {
path := fmt.Sprintf("/v2/organizations/%s/projects/%s/clusters/%s/buckets/samples", tenantID, projectID, clusterID)
err := c.doBasicReq(ctx, false, "POST", path, req, nil)
if err != nil {
return err
}

return err
}
2 changes: 1 addition & 1 deletion utils/capellacontrol/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (m *Manager) WaitForClusterState(
continue
}

break
return nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rather than having this function try and be a 'generic solution' for all types of clusters, we should probably modify this function to either take the type of cluster its dealing with as input, or alternatively have it perform both ListClusters and ListAllColumnars as part of a single loop. I think there are some edge-cases where it could fall into the wrong loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, it was a bit messy. I've added a columnar param and made into 1 for loop.

}

for {
Expand Down
Loading