Skip to content

Commit

Permalink
chore: update prow
Browse files Browse the repository at this point in the history
  • Loading branch information
danilo-gemoli committed Jun 24, 2024
1 parent 59dbd6c commit db838f1
Show file tree
Hide file tree
Showing 15 changed files with 194 additions and 192 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ CONTROLLER_GEN := $(TOOLS_BIN_DIR)/$(CONTROLLER_GEN_BIN)-$(CONTROLLER_GEN_VER)

CMDS = $(notdir $(shell find ./cmd/ -maxdepth 1 -type d | sort))

export GO_VERSION=1.19.12
export GO_VERSION=1.22.3
export GO111MODULE=on
export DOCKER_REPO
export DOCKER_TAG
Expand Down
2 changes: 1 addition & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ import (
"github.com/sirupsen/logrus"
utilerrors "k8s.io/apimachinery/pkg/util/errors"

"k8s.io/test-infra/prow/config/secret"
"sigs.k8s.io/boskos/common"
"sigs.k8s.io/boskos/storage"
"sigs.k8s.io/prow/pkg/config/secret"
)

var (
Expand Down
13 changes: 6 additions & 7 deletions cmd/aws-janitor-boskos/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/sirupsen/logrus"

"k8s.io/test-infra/pkg/flagutil"
"k8s.io/test-infra/prow/config"
prowflagutil "k8s.io/test-infra/prow/flagutil"
"k8s.io/test-infra/prow/logrusutil"
prowmetrics "k8s.io/test-infra/prow/metrics"
"sigs.k8s.io/prow/pkg/config"
prowflagutil "sigs.k8s.io/prow/pkg/flagutil"
"sigs.k8s.io/prow/pkg/logrusutil"
prowmetrics "sigs.k8s.io/prow/pkg/metrics"

"sigs.k8s.io/boskos/aws-janitor/account"
"sigs.k8s.io/boskos/aws-janitor/regions"
Expand Down Expand Up @@ -100,7 +99,7 @@ func init() {

func main() {
logrusutil.ComponentInit()
for _, o := range []flagutil.OptionGroup{&instrumentationOptions} {
for _, o := range []prowflagutil.OptionGroup{&instrumentationOptions} {
o.AddFlags(flag.CommandLine)
}
flag.Parse()
Expand All @@ -111,7 +110,7 @@ func main() {
}
logrus.SetLevel(level)

for _, o := range []flagutil.OptionGroup{&instrumentationOptions} {
for _, o := range []prowflagutil.OptionGroup{&instrumentationOptions} {
if err := o.Validate(false); err != nil {
logrus.Fatalf("Invalid options: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/aws-janitor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/prometheus/client_golang/prometheus/push"
"github.com/sirupsen/logrus"

"k8s.io/test-infra/prow/logrusutil"
"sigs.k8s.io/prow/pkg/logrusutil"

"sigs.k8s.io/boskos/aws-janitor/account"
"sigs.k8s.io/boskos/aws-janitor/regions"
Expand Down
25 changes: 12 additions & 13 deletions cmd/boskos/boskos.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,13 @@ import (
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"

"k8s.io/test-infra/pkg/flagutil"
"k8s.io/test-infra/prow/config"
prowflagutil "k8s.io/test-infra/prow/flagutil"
"k8s.io/test-infra/prow/interrupts"
"k8s.io/test-infra/prow/logrusutil"
prowmetrics "k8s.io/test-infra/prow/metrics"
"k8s.io/test-infra/prow/pjutil"
"k8s.io/test-infra/prow/pjutil/pprof"
"sigs.k8s.io/prow/pkg/config"
prowflagutil "sigs.k8s.io/prow/pkg/flagutil"
"sigs.k8s.io/prow/pkg/interrupts"
"sigs.k8s.io/prow/pkg/logrusutil"
prowmetrics "sigs.k8s.io/prow/pkg/metrics"
"sigs.k8s.io/prow/pkg/pjutil"
"sigs.k8s.io/prow/pkg/pjutil/pprof"

"sigs.k8s.io/boskos/common"
"sigs.k8s.io/boskos/crds"
Expand Down Expand Up @@ -90,7 +89,7 @@ func init() {

func main() {
logrusutil.ComponentInit()
for _, o := range []flagutil.OptionGroup{&kubeClientOptions, &instrumentationOptions} {
for _, o := range []prowflagutil.OptionGroup{&kubeClientOptions, &instrumentationOptions} {
o.AddFlags(flag.CommandLine)
}
flag.Parse()
Expand All @@ -100,7 +99,7 @@ func main() {
logrus.WithError(err).Fatal("invalid log level specified")
}
logrus.SetLevel(level)
for _, o := range []flagutil.OptionGroup{&kubeClientOptions, &instrumentationOptions} {
for _, o := range []prowflagutil.OptionGroup{&kubeClientOptions, &instrumentationOptions} {
if err := o.Validate(false); err != nil {
logrus.Fatalf("Invalid options: %v", err)
}
Expand Down Expand Up @@ -239,9 +238,9 @@ func constHandler() handler.EventHandler {

// resourceUpdatePredicate prevents the config reconciler from reacting to resource update events
// except if:
// * The new status is tombstone, because then we have to delete is
// * The new owner is empty, because then we have to delete it if it got deleted from the config but
// was not deleted from the api to let the current owner finish its work.
// - The new status is tombstone, because then we have to delete is
// - The new owner is empty, because then we have to delete it if it got deleted from the config but
// was not deleted from the api to let the current owner finish its work.
func resourceUpdatePredicate() predicate.Predicate {
return predicate.Funcs{
CreateFunc: func(_ event.CreateEvent) bool { return true },
Expand Down
23 changes: 12 additions & 11 deletions cmd/cleaner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,21 @@ import (

"github.com/sirupsen/logrus"
corev1 "k8s.io/api/core/v1"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/metrics/server"

"k8s.io/test-infra/pkg/flagutil"
"k8s.io/test-infra/prow/config"
prowflagutil "k8s.io/test-infra/prow/flagutil"
"k8s.io/test-infra/prow/interrupts"
"k8s.io/test-infra/prow/logrusutil"
prowmetrics "k8s.io/test-infra/prow/metrics"
"k8s.io/test-infra/prow/pjutil/pprof"
"sigs.k8s.io/boskos/cleaner"
cleanerv2 "sigs.k8s.io/boskos/cleaner/v2"
"sigs.k8s.io/boskos/client"
"sigs.k8s.io/boskos/crds"
"sigs.k8s.io/boskos/ranch"
"sigs.k8s.io/prow/pkg/config"
prowflagutil "sigs.k8s.io/prow/pkg/flagutil"
"sigs.k8s.io/prow/pkg/interrupts"
"sigs.k8s.io/prow/pkg/logrusutil"
prowmetrics "sigs.k8s.io/prow/pkg/metrics"
"sigs.k8s.io/prow/pkg/pjutil/pprof"
)

const (
Expand Down Expand Up @@ -74,7 +75,7 @@ func init() {

func main() {
logrusutil.ComponentInit()
for _, o := range []flagutil.OptionGroup{&kubeClientOptions, &instrumentationOptions} {
for _, o := range []prowflagutil.OptionGroup{&kubeClientOptions, &instrumentationOptions} {
o.AddFlags(flag.CommandLine)
}
flag.Parse()
Expand All @@ -84,7 +85,7 @@ func main() {
logrus.WithError(err).Fatal("invalid log level specified")
}
logrus.SetLevel(level)
for _, o := range []flagutil.OptionGroup{&kubeClientOptions, &instrumentationOptions} {
for _, o := range []prowflagutil.OptionGroup{&kubeClientOptions, &instrumentationOptions} {
if err := o.Validate(false); err != nil {
logrus.Fatalf("Invalid options: %v", err)
}
Expand Down Expand Up @@ -133,8 +134,8 @@ func v2Main(client *client.Client) {
LeaderElection: true,
LeaderElectionNamespace: namespace,
LeaderElectionID: "boskos-cleaner-leaderlock",
Namespace: namespace,
MetricsBindAddress: "0",
Cache: cache.Options{DefaultNamespaces: map[string]cache.Config{namespace: {}}},
Metrics: server.Options{BindAddress: "0"},
})
if err != nil {
logrus.WithError(err).Fatal("failed to construct manager.")
Expand Down
2 changes: 1 addition & 1 deletion cmd/fake-mason/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

"github.com/sirupsen/logrus"
corev1 "k8s.io/api/core/v1"
"k8s.io/test-infra/prow/logrusutil"
"sigs.k8s.io/prow/pkg/logrusutil"

"sigs.k8s.io/boskos/client"
"sigs.k8s.io/boskos/common"
Expand Down
2 changes: 1 addition & 1 deletion cmd/ibmcloud-janitor-boskos/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/pkg/errors"
"github.com/sirupsen/logrus"

"k8s.io/test-infra/prow/logrusutil"
"sigs.k8s.io/prow/pkg/logrusutil"

boskosClient "sigs.k8s.io/boskos/client"
"sigs.k8s.io/boskos/common"
Expand Down
2 changes: 1 addition & 1 deletion cmd/janitor/janitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/sirupsen/logrus"
flag "github.com/spf13/pflag"
"k8s.io/test-infra/prow/logrusutil"
"sigs.k8s.io/prow/pkg/logrusutil"

"sigs.k8s.io/boskos/client"
"sigs.k8s.io/boskos/common"
Expand Down
12 changes: 6 additions & 6 deletions cmd/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/sirupsen/logrus"

"k8s.io/test-infra/prow/config"
"k8s.io/test-infra/prow/flagutil"
"k8s.io/test-infra/prow/logrusutil"
prowmetrics "k8s.io/test-infra/prow/metrics"
"sigs.k8s.io/boskos/client"
"sigs.k8s.io/boskos/common"
"sigs.k8s.io/boskos/metrics"
"sigs.k8s.io/prow/pkg/config"
"sigs.k8s.io/prow/pkg/flagutil"
"sigs.k8s.io/prow/pkg/logrusutil"
prowmetrics "sigs.k8s.io/prow/pkg/metrics"
)

var (
Expand Down Expand Up @@ -108,8 +108,8 @@ func updateResourcesMetric(boskos *client.Client) error {
return nil
}

// handleMetric: Handler for /
// Method: GET
// handleMetric: Handler for /
// Method: GET
func handleMetric(boskos *client.Client) http.HandlerFunc {
return func(res http.ResponseWriter, req *http.Request) {
log := logrus.WithField("handler", "handleMetric")
Expand Down
2 changes: 1 addition & 1 deletion cmd/reaper/reaper.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import (

"github.com/sirupsen/logrus"

"k8s.io/test-infra/prow/logrusutil"
"sigs.k8s.io/boskos/client"
"sigs.k8s.io/boskos/common"
"sigs.k8s.io/prow/pkg/logrusutil"
)

var (
Expand Down
15 changes: 8 additions & 7 deletions crds/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ import (
ctrlruntimeclient "sigs.k8s.io/controller-runtime/pkg/client"
fakectrlruntimeclient "sigs.k8s.io/controller-runtime/pkg/client/fake"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/metrics/server"

"k8s.io/test-infra/prow/interrupts"
"sigs.k8s.io/prow/pkg/interrupts"
)

// KubernetesClientOptions are flag options used to create a kube client.
// It implements the k8s.io/test-infra/pkg/flagutil.OptionGroup interface.
// It implements the sigs.k8s.io/prow/pkg/flagutil.OptionGroup interface.
type KubernetesClientOptions struct {
inMemory bool
kubeConfig string
Expand Down Expand Up @@ -86,9 +87,9 @@ func (o *KubernetesClientOptions) Client() (ctrlruntimeclient.Client, error) {
func (o *KubernetesClientOptions) Manager(namespace string, enableLeaderElection bool, startCacheFor ...ctrlruntimeclient.Object) (manager.Manager, error) {
if o.inMemory {
return manager.New(&rest.Config{}, manager.Options{
LeaderElection: false,
MapperProvider: func(_ *rest.Config, _ *http.Client) (meta.RESTMapper, error) { return &fakeRESTMapper{}, nil },
MetricsBindAddress: "0",
LeaderElection: false,
MapperProvider: func(_ *rest.Config, _ *http.Client) (meta.RESTMapper, error) { return &fakeRESTMapper{}, nil },
Metrics: server.Options{BindAddress: "0"},
NewCache: func(_ *rest.Config, _ cache.Options) (cache.Cache, error) {
return &informertest.FakeInformers{}, nil
},
Expand All @@ -111,8 +112,8 @@ func (o *KubernetesClientOptions) Manager(namespace string, enableLeaderElection
LeaderElectionReleaseOnCancel: true,
LeaderElectionResourceLock: "leases",
LeaderElectionID: "boskos-server",
Namespace: namespace,
MetricsBindAddress: "0",
Cache: cache.Options{DefaultNamespaces: map[string]cache.Config{namespace: {}}},
Metrics: server.Options{BindAddress: "0"},
})
if err != nil {
return nil, fmt.Errorf("failed to construct manager: %v", err)
Expand Down
Loading

0 comments on commit db838f1

Please sign in to comment.