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

Listing workflows by hardware without any workflows returns GRPC error #391

Closed
invidian opened this issue Dec 14, 2020 · 2 comments
Closed
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. priority/backlog Higher priority than priority/awaiting-more-evidence.

Comments

@invidian
Copy link
Contributor

Expected Behaviour

When listing workflows by hardware, which do not have any workflows assigned, empty list of workflows should be returned.

Current Behaviour

Currently server logs the following error and returns error to the client, when given hardware ID does not have any associated workflows:

tink-server_1  | ERROR: 2020/12/14 13:52:48 grpc: server failed to encode response: rpc error: code = Internal desc = grpc: error while marshaling: proto: Marshal called with nil
    main_test.go:38: listing workflows should succeed, got: rpc error: code = Internal desc = grpc: error while marshaling: proto: Marshal called with nil

Steps to Reproduce (for bugs)

  1. go mod init foo
  2. Create file called main_test.go with the following content:
package main

import (
  "context"
  "os"
  "testing"

  "github.com/google/uuid"
  "github.com/tinkerbell/tink/client"
  "github.com/tinkerbell/tink/protos/workflow"
)

func listWorkflowsByHardwareID(t *testing.T, hardwareID string) *workflow.WorkflowContextList {
  if hardwareID == "" {
    t.Fatalf("Hardware ID can't be empty")
  }

  envVars := map[string]string{
    "TINKERBELL_GRPC_AUTHORITY": "127.0.0.1:42113",
    "TINKERBELL_CERT_URL":       "http://127.0.0.1:42114/cert",
  }

  for k, v := range envVars {
    if err := os.Setenv(k, v); err != nil {
      t.Fatalf("setting %q environment variable: %v", k, err)
    }
  }

  conn, err := client.GetConnection()
  if err != nil {
    t.Fatalf("getting Tinkerbell connection: %v", err)
  }

  c := workflow.NewWorkflowSvcClient(conn)

  list, err := c.GetWorkflowContextList(context.TODO(), &workflow.WorkflowContextRequest{WorkerId: hardwareID})
  if err != nil {
    t.Fatalf("listing workflows should succeed, got: %v", err)
  }

  return list
}

func Test_Listing_workflows_by_non_existent_hardware_ID_does_return_empty_list(t *testing.T) {
  listWorkflowsByHardwareID(t, uuid.New().String())
}

func Test_Listing_workflows_for_existing_hardware_ID_does_return_empty_list(t *testing.T) {
  l := listWorkflowsByHardwareID(t, "9ef087c3-4d9f-16ed-777a-ae7583fc5030")

  if len(l.GetWorkflowContexts()) == 0 {
    t.Fatalf("list should not be empty")
  }
}
  1. Make sure values for env variables and hardware ID in Test_Listing_workflows_for_existing_hardware_ID_does_return_empty_list test are set correctly.
  2. Run go test -v.

Context

While working on https://github.com/tinkerbell/cluster-api-provider-tink, we want to find hardware IDs which do not have any workflows associated, to select them
as "available" workers.

Your Environment

Tinkerbell version 9c52cca.

@gianarb gianarb added the kind/bug Categorizes issue or PR as related to a bug. label Dec 14, 2020
@gianarb gianarb self-assigned this Dec 14, 2020
@gianarb gianarb removed their assignment Aug 25, 2021
@tstromberg tstromberg added priority/backlog Higher priority than priority/awaiting-more-evidence. good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. labels Aug 27, 2021
@tstromberg
Copy link
Contributor

Thank you for the detailed test case. This sounds like a fairly trivial issue to fix. Any volunteers?

swills added a commit to swills/tink that referenced this issue Dec 30, 2021
swills added a commit to swills/tink that referenced this issue Dec 30, 2021
swills added a commit to swills/tink that referenced this issue Dec 30, 2021
swills added a commit to swills/tink that referenced this issue Jan 3, 2022
@chrisdoherty4 chrisdoherty4 added the help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. label May 3, 2022
@chrisdoherty4
Copy link
Member

The Tink CLI has been deprecated and removed in #654. This issue is now obsolete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. priority/backlog Higher priority than priority/awaiting-more-evidence.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants