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 lib/cache/inventory/inventory_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ func (ic *InventoryCache) parseFilter(filter *inventoryv1.ListUnifiedInstancesFi
func (ic *InventoryCache) ListUnifiedInstances(ctx context.Context, req *inventoryv1.ListUnifiedInstancesRequest) (*inventoryv1.ListUnifiedInstancesResponse, error) {
if !ic.IsHealthy() {
// This returns HTTP error 503. Keep in sync with web/packages/teleport/src/Instances/Instances.tsx (isCacheInitializing)
return nil, trace.ConnectionProblem(nil, "inventory cache is not yet healthy")
return nil, trace.ConnectionProblem(nil, "inventory cache is not yet healthy, please try again in a few minutes'")
}

if req.PageSize <= 0 {
Expand Down
6 changes: 4 additions & 2 deletions lib/web/ui/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
package ui

import (
"strings"

inventoryv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/inventory/v1"
machineidv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/machineid/v1"
"github.com/gravitational/teleport/api/types"
Expand Down Expand Up @@ -85,7 +87,7 @@ func makeInstanceUnifiedItem(instance *types.InstanceV1) UnifiedInstance {

instanceData := &InstanceData{
Name: instance.Spec.Hostname,
Version: instance.Spec.Version,
Version: strings.TrimPrefix(instance.Spec.Version, "v"),
Services: services,
}

Expand Down Expand Up @@ -114,7 +116,7 @@ func makeBotInstanceUnifiedItem(botInstance *machineidv1.BotInstance) UnifiedIns

if botInstance.Status != nil && len(botInstance.Status.LatestHeartbeats) > 0 {
heartbeat := botInstance.Status.LatestHeartbeats[0]
botData.Version = heartbeat.Version
botData.Version = strings.TrimPrefix(heartbeat.Version, "v")
}

return UnifiedInstance{
Expand Down
7 changes: 6 additions & 1 deletion web/packages/teleport/src/Instances/Instances.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ export const Loaded: Story = {
export const CacheInitializing: Story = {
parameters: {
msw: {
handlers: [listInstancesError(503, 'inventory cache is not yet healthy')],
handlers: [
listInstancesError(
503,
'inventory cache is not yet healthy, please try again in a few minutes'
Comment thread
rudream marked this conversation as resolved.
),
],
},
},
};
Expand Down
27 changes: 18 additions & 9 deletions web/packages/teleport/src/Instances/Instances.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ it('having only instances permissions should show warning banner', async () => {
});

it('cache still initializing error should show correct error', async () => {
server.use(listInstancesError(503, 'inventory cache is not yet healthy'));
server.use(
listInstancesError(
503,
'inventory cache is not yet healthy, please try again in a few minutes'
)
);
renderComponent();

await waitFor(() => {
Expand Down Expand Up @@ -239,11 +244,12 @@ it('selecting a version filter should append the version predicate expression to
await user.type(searchInput, 'name == "teleport-auth-01"{Enter}');

await waitFor(() => {
expect(lastRequestUrl).toBeDefined();
const url = new URL(lastRequestUrl);
const query = url.searchParams.get('query');
expect(query).toBe('name == "teleport-auth-01"');
expect(lastRequestUrl).toContain('query=');
});
{
const url = new URL(lastRequestUrl);
expect(url.searchParams.get('query')).toBe('name == "teleport-auth-01"');
}

// Select a version filter
const versionButton = screen.getByRole('button', { name: /Version/i });
Expand All @@ -257,11 +263,14 @@ it('selecting a version filter should append the version predicate expression to

// Verify that the request made combines both predicates
await waitFor(() => {
expect(lastRequestUrl).toBeDefined();
const url = new URL(lastRequestUrl);
const query = url.searchParams.get('query');
expect(query).toBe('(name == "teleport-auth-01") && (version == "18.2.4")');
expect(lastRequestUrl).toContain('version');
});
{
const url = new URL(lastRequestUrl);
expect(url.searchParams.get('query')).toBe(
'(name == "teleport-auth-01") && (version == "18.2.4")'
);
}
}, 15000);

function renderComponent(options?: {
Expand Down
Loading