Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ GOINSTALL=$(GOCMD) install
GOSEC=gosec

# Third party tools
ARTIFACT_GOLINT=github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.8
ARTIFACT_GOLINT=github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.0
ARTIFACT_GOSEC=github.com/securego/gosec/v2/cmd/gosec@v2.22.8
ARTIFACT_GOFUMPT=mvdan.cc/gofumpt@v0.9.2

Expand Down
46 changes: 31 additions & 15 deletions v1/providers/nebius/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -693,22 +693,38 @@ func (c *NebiusClient) ListInstances(ctx context.Context, args v1.ListInstancesA
// Collect instances from all projects
allNebiusInstances := make([]*compute.Instance, 0)
for projectID := range projectToRegion {
response, err := c.sdk.Services().Compute().V1().Instance().List(ctx, &compute.ListInstancesRequest{
ParentId: projectID,
})
if err != nil {
c.logger.Error(ctx, fmt.Errorf("failed to list instances in project %s: %w", projectID, err),
v1.LogField("projectID", projectID))
// Continue to next project instead of failing completely
continue
}
var pageToken string
for {
response, err := c.sdk.Services().Compute().V1().Instance().List(ctx, &compute.ListInstancesRequest{
ParentId: projectID,
PageSize: 100,
PageToken: pageToken,
})
if err != nil {
c.logger.Error(ctx, fmt.Errorf("failed to list instances in project %s: %w", projectID, err),
v1.LogField("projectID", projectID))
// Continue to next project instead of failing completely
break
}

if response != nil && response.Items != nil {
c.logger.Info(ctx, "found instances in project",
v1.LogField("projectID", projectID),
v1.LogField("region", projectToRegion[projectID]),
v1.LogField("count", len(response.Items)))
allNebiusInstances = append(allNebiusInstances, response.Items...)
// If the response is nil, we've reached the end of the list
if response == nil {
break
}

if len(response.Items) > 0 {
c.logger.Info(ctx, "found instances in project",
Copy link
Contributor

Choose a reason for hiding this comment

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

nonblocking: should we make this debug?

v1.LogField("projectID", projectID),
v1.LogField("region", projectToRegion[projectID]),
v1.LogField("count", len(response.Items)),
v1.LogField("page", pageToken))
allNebiusInstances = append(allNebiusInstances, response.Items...)
}

pageToken = response.GetNextPageToken()
if pageToken == "" {
break
}
}
}

Expand Down
20 changes: 13 additions & 7 deletions v1/providers/nebius/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,16 +332,22 @@ func TestIntegration_InstanceLifecycle(t *testing.T) {
t.Log("WARNING: No public IP available, skipping SSH connectivity test")
}

// Step 3: List instances (currently not implemented)
// Step 3: List instances and verify the created instance is present
t.Log("Listing instances...")
instances, err := client.ListInstances(ctx, v1.ListInstancesArgs{})
// This is expected to fail with current implementation
if err != nil {
t.Logf("ListInstances failed as expected: %v", err)
assert.Contains(t, err.Error(), "implementation pending")
} else {
t.Logf("Found %d instances", len(instances))
require.NoError(t, err, "ListInstances should succeed")
t.Logf("Found %d instances", len(instances))

// Verify the instance we just created is in the list
var foundCreatedInstance bool
for _, inst := range instances {
if inst.CloudID == instanceCloudID {
foundCreatedInstance = true
t.Logf("✓ Found created instance %s in list", instanceCloudID)
break
}
}
assert.True(t, foundCreatedInstance, "Created instance should be found in ListInstances result")

// Step 4: Stop instance
t.Logf("Stopping instance: %s", instanceCloudID)
Expand Down
Loading