Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Update pkg/app/discovery.go

Co-authored-by: Pranshu Srivastava <[email protected]>

Update internal/discovery/types.go

Co-authored-by: Pranshu Srivastava <[email protected]>

Update internal/discovery/types.go

Co-authored-by: Pranshu Srivastava <[email protected]>

Update pkg/customresourcestate/config.go

Co-authored-by: Pranshu Srivastava <[email protected]>

Update pkg/customresourcestate/config.go

Co-authored-by: Pranshu Srivastava <[email protected]>
  • Loading branch information
CatherineF-dev and rexagod committed Sep 26, 2023
1 parent fff8c1a commit e134ac9
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions internal/discovery/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
)

// GroupVersionKindPlural embeds schema.GroupVersionKind, in addition to the plural representation of the Kind.
type GroupVersionKindPlural struct {
schema.GroupVersionKind
Plural string
Expand All @@ -28,6 +29,7 @@ func (g GroupVersionKindPlural) String() string {
return fmt.Sprintf("%s/%s, Kind=%s, Plural=%s", g.Group, g.Version, g.Kind, g.Plural)
}

// KindPlural entails the Kind and its plural representation.
type KindPlural struct {
Kind string
Plural string
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package discovery provides a discovery and resolution logic for GVKs.
package app

import (
Expand Down Expand Up @@ -40,6 +39,7 @@ import (
const Interval = 3 * time.Second

// CRDiscoverer provides a cache of the collected GVKs, along with helper utilities.
// It implements customresourcestate.GVKToGVKP.
type CRDiscoverer struct {
// m is a mutex to protect the cache.
m sync.RWMutex
Expand Down
1 change: 1 addition & 0 deletions pkg/app/discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"testing"

"k8s.io/apimachinery/pkg/runtime/schema"

"k8s.io/kube-state-metrics/v2/internal/discovery"
)

Expand Down
1 change: 1 addition & 0 deletions pkg/customresourcestate/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ type ConfigDecoder interface {
Decode(v interface{}) (err error)
}

// GVKToGVKP incorporates logic to resolve a given GVK, with variable version and/or kind, to it's []discovery.GroupVersionKindPlural representation.
type GVKToGVKP interface {
ResolveGVKToGVKPs(gvk schema.GroupVersionKind) (resolvedGVKPs []discovery.GroupVersionKindPlural, err error)
}
Expand Down
5 changes: 3 additions & 2 deletions tests/e2e/discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ import (
"k8s.io/klog/v2"

"k8s.io/kube-state-metrics/v2/internal"
"k8s.io/kube-state-metrics/v2/pkg/customresourcestate"
"k8s.io/kube-state-metrics/v2/pkg/options"
)

// PopulateTimeout is the timeout on populating the cache for the first time.
const PopulateTimeout = 10 * time.Second
const Interval = 3 * time.Second

func TestVariableVKsDiscoveryAndResolution(t *testing.T) {

Expand Down Expand Up @@ -140,7 +140,8 @@ func TestVariableVKsDiscoveryAndResolution(t *testing.T) {
// Wait for the metric to be available.
ch := make(chan bool, 1)
klog.InfoS("waiting for metrics to become available")
err = wait.PollUntilContextTimeout(context.TODO(), customresourcestate.Interval, PopulateTimeout, true, func(ctx context.Context) (bool, error) {

err = wait.PollUntilContextTimeout(context.TODO(), Interval, PopulateTimeout, true, func(ctx context.Context) (bool, error) {
out, err := exec.Command("curl", "localhost:8080/metrics").Output()
if err != nil {
return false, err
Expand Down

0 comments on commit e134ac9

Please sign in to comment.