Skip to content

Commit

Permalink
Extract parts of boskos into this repo and remove client-go's replace…
Browse files Browse the repository at this point in the history
… directive
  • Loading branch information
munnerz committed Jul 29, 2022
1 parent 491fec3 commit d3b2dfe
Show file tree
Hide file tree
Showing 11 changed files with 1,439 additions and 8 deletions.
2 changes: 1 addition & 1 deletion config/prow/cluster/build/boskos-resources/boskos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package cluster
import (
"testing"

"sigs.k8s.io/boskos/common"
"k8s.io/test-infra/boskos/third_party/common"
)

func TestConfig(t *testing.T) {
Expand Down
7 changes: 3 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ replace (

golang.org/x/lint => golang.org/x/lint v0.0.0-20190409202823-959b441ac422
gopkg.in/yaml.v3 => gopkg.in/yaml.v3 v3.0.0-20190709130402-674ba3eaed22
k8s.io/client-go => k8s.io/client-go v0.24.2
)

require (
Expand Down Expand Up @@ -64,6 +63,7 @@ require (
github.com/gorilla/securecookie v1.1.1
github.com/gorilla/sessions v1.2.0
github.com/gregjones/httpcache v0.0.0-20190212212710-3befbb6ad0cc
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/go-retryablehttp v0.7.0
github.com/hashicorp/golang-lru v0.5.4
github.com/klauspost/pgzip v1.2.1
Expand Down Expand Up @@ -102,13 +102,12 @@ require (
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.24.2
k8s.io/apimachinery v0.24.2
k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible
k8s.io/client-go v0.24.2
k8s.io/code-generator v0.24.2
k8s.io/klog/v2 v2.70.0
k8s.io/utils v0.0.0-20220725171434-9bab9ef40391
knative.dev/pkg v0.0.0-20220329144915-0a1ec2e0d46c
mvdan.cc/xurls/v2 v2.0.0
sigs.k8s.io/boskos v0.0.0-20220725190635-b0ffc2fcc06a
sigs.k8s.io/controller-runtime v0.12.3
sigs.k8s.io/controller-tools v0.9.2
sigs.k8s.io/yaml v1.3.0
Expand Down Expand Up @@ -153,6 +152,7 @@ require (
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.6 // indirect
github.com/go-openapi/swag v0.21.1 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/gobuffalo/flect v0.2.5 // indirect
github.com/gofrs/uuid v4.2.0+incompatible // indirect
github.com/gogo/protobuf v1.3.2 // indirect
Expand All @@ -173,7 +173,6 @@ require (
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
Expand Down
3 changes: 1 addition & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ github.com/go-openapi/swag v0.21.1/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/e
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw=
github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4=
github.com/go-test/deep v1.0.7 h1:/VSMRlnY/JSyqxQUzQLKVMAskpY/NZKFA5j2P+0pP2M=
github.com/go-test/deep v1.0.7/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8=
github.com/gobuffalo/flect v0.2.5 h1:H6vvsv2an0lalEaCDRThvtBfmg44W/QHXBCYUXf/6S4=
Expand Down Expand Up @@ -1483,8 +1484,6 @@ rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.30/go.mod h1:fEO7lRTdivWO2qYVCVG7dEADOMo/MLDCVr8So2g88Uw=
sigs.k8s.io/boskos v0.0.0-20220725190635-b0ffc2fcc06a h1:9db2GyAD64pp7HCeXRL2SOrsXrV7PFvtjxDtHkKoAvo=
sigs.k8s.io/boskos v0.0.0-20220725190635-b0ffc2fcc06a/go.mod h1:0WpgO6LPSKTpy+RxOjihwWNSouVatRalWe+uauJVt68=
sigs.k8s.io/controller-runtime v0.12.3 h1:FCM8xeY/FI8hoAfh/V4XbbYMY20gElh9yh+A98usMio=
sigs.k8s.io/controller-runtime v0.12.3/go.mod h1:qKsk4WE6zW2Hfj0G4v10EnNB2jMG1C+NTb8h+DwCoU0=
sigs.k8s.io/controller-tools v0.9.2 h1:AkTE3QAdz9LS4iD3EJvHyYxBkg/g9fTbgiYsrcsFCcM=
Expand Down
10 changes: 10 additions & 0 deletions kubetest/boskos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Boskos client package

**If you are building something outside test-infra that relies on the Boskos client library, do not use this package! Use `sigs.k8s.io/boskos` directly instead.**

This package has been copied across from https://github.com/kubernetes-sigs/boskos to avoid a dependency cycle between this repository and the Boskos repository.
This is a temporary stop-gap measure until Boskos has moved it's `k8s.io/client-go` dependency off of the old `v11` version.

More details on this problem can be read in the issue [#20421](https://github.com/kubernetes/test-infra/issues/20421).

Once Boskos no longer requires client-go@v11, we can delete this whole directory and once again depend directly on `sigs.k8s.io/boskos/*`.
69 changes: 69 additions & 0 deletions kubetest/boskos/client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Boskos Client Library

Boskos client is a go client library interfaces [boskos server](../README.md).

Users of boskos need to use boskos client to communicate with the deployed boskos service.

# Initialize

A boskos client instance is initialized with the URL of target boskos server accompanied with owner of the client.

The client object looks like:

```
type Client struct {
// RetryCount is the number of times an HTTP request issued by this client
// is retried when the initial request fails due an inaccessible endpoint.
RetryCount uint
// RetryDuration is the interval to wait before retrying an HTTP operation
// that failed due to an inaccessible endpoint.
RetryWait time.Duration
url string
resources []string
owner string
}
```

To create a boskos client, use `NewClient` and specify the Boskos endpoint URL and resource owner.
The `NewClient` function also sets the client's `RetryCount` to `3` and `RetryWait` interval to `10s`.
```
func NewClient(url string, owner string) *Client
```


# API Reference

```
// Acquire asks boskos for a resource of certain type in certain state, and set the resource to dest state.
func (c *Client) Acquire(rtype string, state string, dest string) (string, error)
// AcquireWait blocks until Acquire returns the specified resource or the
// provided context is cancelled or its deadline exceeded.
func (c *Client) AcquireWait(rtype string, state string, dest string) (string, error)
// AcquireByState asks boskos for a resources of certain type, and set the resource to dest state.
// Returns a list of resources on success.
func (c *Client) AcquireByState(state, dest string, names []string) ([]common.Resource, error)
// AcquireByStateWait blocks until AcquireByState returns the specified
// resource(s) or the provided context is cancelled or its deadline exceeded.
func (c *Client) AcquireByStateWait(ctx context.Context, state, dest string, names []string) ([]common.Resource, error)
// ReleaseAll returns all resources hold by the client back to boskos and set them to dest state.
func (c *Client) ReleaseAll(dest string) error
// ReleaseOne returns one of owned resources back to boskos and set it to dest state.
func (c *Client) ReleaseOne(name string, dest string) error
// UpdateAll signals update for all resources hold by the client.
func (c *Client) UpdateAll(state string) error
// UpdateOne signals update for one of the resources hold by the client.
func (c *Client) UpdateOne(name string, state string) error
// Reset will scan all boskos resources of type, in state, last updated before expire, and set them to dest state.
// Returns a map of {resourceName:owner} for further actions.
func (c *Client) Reset(rtype string, state string, expire time.Duration, dest string) (map[string]string, error)
```
Loading

0 comments on commit d3b2dfe

Please sign in to comment.