From e14c3415c987881d82f4fbd19fdc37c76aeb5ca7 Mon Sep 17 00:00:00 2001 From: Laurentiu Bradin <109964136+z103cb@users.noreply.github.com> Date: Tue, 1 Aug 2023 15:16:07 +0300 Subject: [PATCH 1/5] Generate MCAD clients using clientgen tools Fixes #514 --- .gitignore | 1 + Makefile | 70 +++++++ hack/boilerplate/boilerplate.go.txt | 15 -- pkg/apis/controller/v1beta1/appwrapper.go | 1 + pkg/client/client_factory.go | 44 ++++ .../clientset/controller-versioned/doc.go | 7 + pkg/client/clientset/versioned/clientset.go | 97 +++++++++ pkg/client/clientset/versioned/doc.go | 20 ++ .../versioned/fake/clientset_generated.go | 82 ++++++++ pkg/client/clientset/versioned/fake/doc.go | 20 ++ .../clientset/versioned/fake/register.go | 56 +++++ pkg/client/clientset/versioned/scheme/doc.go | 20 ++ .../clientset/versioned/scheme/register.go | 56 +++++ .../typed/controller/v1beta1/appwrapper.go | 195 ++++++++++++++++++ .../controller/v1beta1/controller_client.go | 89 ++++++++ .../versioned/typed/controller/v1beta1/doc.go | 20 ++ .../typed/controller/v1beta1/fake/doc.go | 20 ++ .../v1beta1/fake/fake_appwrapper.go | 142 +++++++++++++ .../v1beta1/fake/fake_controller_client.go | 40 ++++ .../controller/v1beta1/generated_expansion.go | 21 ++ .../controller-externalversion/doc.go | 7 + .../internalinterfaces/doc.go | 5 + .../controller-externalversion/v1/doc.go | 7 + .../informers/externalversions/factory.go | 180 ++++++++++++++++ 24 files changed, 1200 insertions(+), 15 deletions(-) create mode 100644 pkg/client/client_factory.go create mode 100644 pkg/client/clientset/controller-versioned/doc.go create mode 100644 pkg/client/clientset/versioned/clientset.go create mode 100644 pkg/client/clientset/versioned/doc.go create mode 100644 pkg/client/clientset/versioned/fake/clientset_generated.go create mode 100644 pkg/client/clientset/versioned/fake/doc.go create mode 100644 pkg/client/clientset/versioned/fake/register.go create mode 100644 pkg/client/clientset/versioned/scheme/doc.go create mode 100644 pkg/client/clientset/versioned/scheme/register.go create mode 100644 pkg/client/clientset/versioned/typed/controller/v1beta1/appwrapper.go create mode 100644 pkg/client/clientset/versioned/typed/controller/v1beta1/controller_client.go create mode 100644 pkg/client/clientset/versioned/typed/controller/v1beta1/doc.go create mode 100644 pkg/client/clientset/versioned/typed/controller/v1beta1/fake/doc.go create mode 100644 pkg/client/clientset/versioned/typed/controller/v1beta1/fake/fake_appwrapper.go create mode 100644 pkg/client/clientset/versioned/typed/controller/v1beta1/fake/fake_controller_client.go create mode 100644 pkg/client/clientset/versioned/typed/controller/v1beta1/generated_expansion.go create mode 100644 pkg/client/informers/controller-externalversion/doc.go create mode 100644 pkg/client/informers/controller-externalversion/internalinterfaces/doc.go create mode 100644 pkg/client/informers/controller-externalversion/v1/doc.go create mode 100644 pkg/client/informers/externalversions/factory.go diff --git a/.gitignore b/.gitignore index d6a361a6d..705a399b1 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ /output*/ /_output*/ /_output +bin # Emacs save files *~ diff --git a/Makefile b/Makefile index 748391255..489eeb2db 100644 --- a/Makefile +++ b/Makefile @@ -13,9 +13,14 @@ $(LOCALBIN): ## Tool Versions CONTROLLER_TOOLS_VERSION ?= v0.9.2 +CODEGEN_VERSION ?= v0.20.15 ## Tool Binaries CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen +APPLYCONFIGURATION_GEN ?= $(LOCALBIN)/applyconfiguration-gen +CLIENT_GEN ?= $(LOCALBIN)/client-gen +LISTER_GEN ?= $(LOCALBIN)/lister-gen +INFORMER_GEN ?= $(LOCALBIN)/informer-gen # Reset branch name if this a Travis CI environment ifneq ($(strip $(TRAVIS_BRANCH)),) @@ -70,12 +75,77 @@ init: verify-tag-name: print-global-variables # Check for invalid tag name t=${TAG} && [ $${#t} -le 128 ] || { echo "Target name $$t has 128 or more chars"; false; } +.PHONY: generate-client ## Generate client packages +generate-client: code-generator + rm -rf pkg/client/clientset/versioned pkg/client/informers/externalversions pkg/client/listers/controller/v1beta1 +# TODO: add this back when the version of the tool has been updated and supports this executable +# $(APPLYCONFIGURATION_GEN) \ +# --input-dirs="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" \ +# --go-header-file="hack/boilerplate/boilerplate.go.txt" \ +# --output-package="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/applyconfiguration" \ +# --trim-path-prefix "github.com/project-codeflare/multi-cluster-app-dispatcher" + $(CLIENT_GEN) \ + --input="pkg/apis/controller/v1beta1" \ + --input-base="github.com/project-codeflare/multi-cluster-app-dispatcher" \ + --go-header-file="hack/boilerplate/boilerplate.go.txt" \ + --clientset-name "versioned" \ + --output-package="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset" \ + --output-base="." +# TODO: add the following line back once the tool has been upgraded +# --trim-path-prefix "github.com/project-codeflare/multi-cluster-app-dispatcher" + $(LISTER_GEN) \ + --input-dirs="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" \ + --go-header-file="hack/boilerplate/boilerplate.go.txt" \ + --output-base="." \ + --output-package="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers" +# TODO: add the following line back once the tool has been upgraded +# --trim-path-prefix "github.com/project-codeflare/multi-cluster-app-dispatcher" + $(INFORMER_GEN) \ + --input-dirs="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" \ + --versioned-clientset-package="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned" \ + --listers-package="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers" \ + --go-header-file="hack/boilerplate/boilerplate.go.txt" \ + --output-base="." \ + --output-package="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers" +# TODO: add the following line back once the tool has been upgraded +# --trim-path-prefix "github.com/project-codeflare/multi-cluster-app-dispatcher" +# TODO: remove the following lines once the tool has been upgraded and they are no longer needed. +# The `mv` and `rm` are necessary as the generators write to the gihub.com/... path. + mv -f github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned pkg/client/clientset/versioned + mv -f github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/externalversions pkg/client/informers/externalversions + mv -f github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers/controller/v1beta1 pkg/client/listers/controller/v1beta1 + rm -rf github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client .PHONY: controller-gen controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. $(CONTROLLER_GEN): $(LOCALBIN) test -s $(LOCALBIN)/controller-gen || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION) +.PHONY: code-generator +#TODO: add $(APPLYCONFIGURATION_GEN) as a dependency when the tool is supported +code-generator: $(CLIENT_GEN) $(LISTER_GEN) $(INFORMER_GEN) $(CONTROLLER_GEN) + +# TODO: enable this target once the tools is supported +#.PHONY: applyconfiguration-gen +#applyconfiguration-gen: $(APPLYCONFIGURATION_GEN) +#$(APPLYCONFIGURATION_GEN): $(LOCALBIN) +# test -s $(LOCALBIN)/applyconfiguration-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/applyconfiguration-gen@$(CODEGEN_VERSION) + +.PHONY: client-gen +client-gen: $(CLIENT_GEN) +$(CLIENT_GEN): $(LOCALBIN) + test -s $(LOCALBIN)/client-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/client-gen@$(CODEGEN_VERSION) + +.PHONY: lister-gen +lister-gen: $(LISTER_GEN) +$(LISTER_GEN): $(LOCALBIN) + test -s $(LOCALBIN)/lister-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/lister-gen@$(CODEGEN_VERSION) + +.PHONY: informer-gen +informer-gen: $(INFORMER_GEN) +$(INFORMER_GEN): $(LOCALBIN) + test -s $(LOCALBIN)/informer-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/informer-gen@$(CODEGEN_VERSION) + .PHONY: manifests manifests: controller-gen ## Generate CustomResourceDefinition objects. $(CONTROLLER_GEN) crd:allowDangerousTypes=true paths="./pkg/apis/..." output:crd:artifacts:config=config/crd/bases diff --git a/hack/boilerplate/boilerplate.go.txt b/hack/boilerplate/boilerplate.go.txt index 941e3a5ad..14eda2308 100644 --- a/hack/boilerplate/boilerplate.go.txt +++ b/hack/boilerplate/boilerplate.go.txt @@ -1,19 +1,4 @@ /* -Copyright YEAR The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -/* Copyright 2019, 2021, 2022, YEAR The Multi-Cluster App Dispatcher Authors. Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/pkg/apis/controller/v1beta1/appwrapper.go b/pkg/apis/controller/v1beta1/appwrapper.go index b7811e1ca..038737ce7 100644 --- a/pkg/apis/controller/v1beta1/appwrapper.go +++ b/pkg/apis/controller/v1beta1/appwrapper.go @@ -28,6 +28,7 @@ const AppWrapperPlural string = "appwrappers" // which AppWrapper it belongs to. const AppWrapperAnnotationKey = "appwrapper.mcad.ibm.com/appwrapper-name" +// +genclient // +kubebuilder:object:root=true // +kubebuilder:subresource:status // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/pkg/client/client_factory.go b/pkg/client/client_factory.go new file mode 100644 index 000000000..383d9ff7e --- /dev/null +++ b/pkg/client/client_factory.go @@ -0,0 +1,44 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +package client + +import ( + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/serializer" + "k8s.io/client-go/rest" + + arbv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" +) + +func NewClient(cfg *rest.Config) (*rest.RESTClient, *runtime.Scheme, error) { + scheme := runtime.NewScheme() + if err := arbv1.AddToScheme(scheme); err != nil { + return nil, nil, err + } + + config := *cfg + config.GroupVersion = &arbv1.SchemeGroupVersion + config.APIPath = "/apis" + config.ContentType = runtime.ContentTypeJSON + config.NegotiatedSerializer = serializer.WithoutConversionCodecFactory{CodecFactory: serializer.NewCodecFactory(scheme)} + + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, nil, err + } + + return client, scheme, nil +} diff --git a/pkg/client/clientset/controller-versioned/doc.go b/pkg/client/clientset/controller-versioned/doc.go new file mode 100644 index 000000000..0da431ac4 --- /dev/null +++ b/pkg/client/clientset/controller-versioned/doc.go @@ -0,0 +1,7 @@ +// Package controller_versioned provides a set of Appwrapper clients to be used with interacting with AppWrapper CRDS. +// RC4 +// Deprecated: controller_versioned has been replaced by the versioned as that package is generated using the client gen tool. +// controller_versioned interfaces and methods should not be used except for compatibility. It will be removed in future versions. +// +// This package is frozen and no new functionality will be added. +package controller_versioned diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go new file mode 100644 index 000000000..2cb2c8f7c --- /dev/null +++ b/pkg/client/clientset/versioned/clientset.go @@ -0,0 +1,97 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package versioned + +import ( + "fmt" + + mcadv1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned/typed/controller/v1beta1" + discovery "k8s.io/client-go/discovery" + rest "k8s.io/client-go/rest" + flowcontrol "k8s.io/client-go/util/flowcontrol" +) + +type Interface interface { + Discovery() discovery.DiscoveryInterface + McadV1beta1() mcadv1beta1.McadV1beta1Interface +} + +// Clientset contains the clients for groups. Each group has exactly one +// version included in a Clientset. +type Clientset struct { + *discovery.DiscoveryClient + mcadV1beta1 *mcadv1beta1.McadV1beta1Client +} + +// McadV1beta1 retrieves the McadV1beta1Client +func (c *Clientset) McadV1beta1() mcadv1beta1.McadV1beta1Interface { + return c.mcadV1beta1 +} + +// Discovery retrieves the DiscoveryClient +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + if c == nil { + return nil + } + return c.DiscoveryClient +} + +// NewForConfig creates a new Clientset for the given config. +// If config's RateLimiter is not set and QPS and Burst are acceptable, +// NewForConfig will generate a rate-limiter in configShallowCopy. +func NewForConfig(c *rest.Config) (*Clientset, error) { + configShallowCopy := *c + if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { + if configShallowCopy.Burst <= 0 { + return nil, fmt.Errorf("burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0") + } + configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) + } + var cs Clientset + var err error + cs.mcadV1beta1, err = mcadv1beta1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + + cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) + if err != nil { + return nil, err + } + return &cs, nil +} + +// NewForConfigOrDie creates a new Clientset for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *Clientset { + var cs Clientset + cs.mcadV1beta1 = mcadv1beta1.NewForConfigOrDie(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) + return &cs +} + +// New creates a new Clientset for the given RESTClient. +func New(c rest.Interface) *Clientset { + var cs Clientset + cs.mcadV1beta1 = mcadv1beta1.New(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClient(c) + return &cs +} diff --git a/pkg/client/clientset/versioned/doc.go b/pkg/client/clientset/versioned/doc.go new file mode 100644 index 000000000..bab04ec55 --- /dev/null +++ b/pkg/client/clientset/versioned/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated clientset. +package versioned diff --git a/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go new file mode 100644 index 000000000..2a0217675 --- /dev/null +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -0,0 +1,82 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + clientset "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned" + mcadv1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned/typed/controller/v1beta1" + fakemcadv1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned/typed/controller/v1beta1/fake" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/watch" + "k8s.io/client-go/discovery" + fakediscovery "k8s.io/client-go/discovery/fake" + "k8s.io/client-go/testing" +) + +// NewSimpleClientset returns a clientset that will respond with the provided objects. +// It's backed by a very simple object tracker that processes creates, updates and deletions as-is, +// without applying any validations and/or defaults. It shouldn't be considered a replacement +// for a real clientset and is mostly useful in simple unit tests. +func NewSimpleClientset(objects ...runtime.Object) *Clientset { + o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) + for _, obj := range objects { + if err := o.Add(obj); err != nil { + panic(err) + } + } + + cs := &Clientset{tracker: o} + cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake} + cs.AddReactor("*", "*", testing.ObjectReaction(o)) + cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { + gvr := action.GetResource() + ns := action.GetNamespace() + watch, err := o.Watch(gvr, ns) + if err != nil { + return false, nil, err + } + return true, watch, nil + }) + + return cs +} + +// Clientset implements clientset.Interface. Meant to be embedded into a +// struct to get a default implementation. This makes faking out just the method +// you want to test easier. +type Clientset struct { + testing.Fake + discovery *fakediscovery.FakeDiscovery + tracker testing.ObjectTracker +} + +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + return c.discovery +} + +func (c *Clientset) Tracker() testing.ObjectTracker { + return c.tracker +} + +var _ clientset.Interface = &Clientset{} + +// McadV1beta1 retrieves the McadV1beta1Client +func (c *Clientset) McadV1beta1() mcadv1beta1.McadV1beta1Interface { + return &fakemcadv1beta1.FakeMcadV1beta1{Fake: &c.Fake} +} diff --git a/pkg/client/clientset/versioned/fake/doc.go b/pkg/client/clientset/versioned/fake/doc.go new file mode 100644 index 000000000..b834d19f4 --- /dev/null +++ b/pkg/client/clientset/versioned/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated fake clientset. +package fake diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go new file mode 100644 index 000000000..ea2269452 --- /dev/null +++ b/pkg/client/clientset/versioned/fake/register.go @@ -0,0 +1,56 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + mcadv1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" +) + +var scheme = runtime.NewScheme() +var codecs = serializer.NewCodecFactory(scheme) + +var localSchemeBuilder = runtime.SchemeBuilder{ + mcadv1beta1.AddToScheme, +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(AddToScheme(scheme)) +} diff --git a/pkg/client/clientset/versioned/scheme/doc.go b/pkg/client/clientset/versioned/scheme/doc.go new file mode 100644 index 000000000..994ab232a --- /dev/null +++ b/pkg/client/clientset/versioned/scheme/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package contains the scheme of the automatically generated clientset. +package scheme diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go new file mode 100644 index 000000000..598c25cc7 --- /dev/null +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -0,0 +1,56 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package scheme + +import ( + mcadv1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" +) + +var Scheme = runtime.NewScheme() +var Codecs = serializer.NewCodecFactory(Scheme) +var ParameterCodec = runtime.NewParameterCodec(Scheme) +var localSchemeBuilder = runtime.SchemeBuilder{ + mcadv1beta1.AddToScheme, +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(AddToScheme(Scheme)) +} diff --git a/pkg/client/clientset/versioned/typed/controller/v1beta1/appwrapper.go b/pkg/client/clientset/versioned/typed/controller/v1beta1/appwrapper.go new file mode 100644 index 000000000..ba3453d98 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/controller/v1beta1/appwrapper.go @@ -0,0 +1,195 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "context" + "time" + + v1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" + scheme "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// AppWrappersGetter has a method to return a AppWrapperInterface. +// A group's client should implement this interface. +type AppWrappersGetter interface { + AppWrappers(namespace string) AppWrapperInterface +} + +// AppWrapperInterface has methods to work with AppWrapper resources. +type AppWrapperInterface interface { + Create(ctx context.Context, appWrapper *v1beta1.AppWrapper, opts v1.CreateOptions) (*v1beta1.AppWrapper, error) + Update(ctx context.Context, appWrapper *v1beta1.AppWrapper, opts v1.UpdateOptions) (*v1beta1.AppWrapper, error) + UpdateStatus(ctx context.Context, appWrapper *v1beta1.AppWrapper, opts v1.UpdateOptions) (*v1beta1.AppWrapper, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.AppWrapper, error) + List(ctx context.Context, opts v1.ListOptions) (*v1beta1.AppWrapperList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.AppWrapper, err error) + AppWrapperExpansion +} + +// appWrappers implements AppWrapperInterface +type appWrappers struct { + client rest.Interface + ns string +} + +// newAppWrappers returns a AppWrappers +func newAppWrappers(c *McadV1beta1Client, namespace string) *appWrappers { + return &appWrappers{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the appWrapper, and returns the corresponding appWrapper object, and an error if there is any. +func (c *appWrappers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.AppWrapper, err error) { + result = &v1beta1.AppWrapper{} + err = c.client.Get(). + Namespace(c.ns). + Resource("appwrappers"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of AppWrappers that match those selectors. +func (c *appWrappers) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.AppWrapperList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.AppWrapperList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("appwrappers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested appWrappers. +func (c *appWrappers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("appwrappers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a appWrapper and creates it. Returns the server's representation of the appWrapper, and an error, if there is any. +func (c *appWrappers) Create(ctx context.Context, appWrapper *v1beta1.AppWrapper, opts v1.CreateOptions) (result *v1beta1.AppWrapper, err error) { + result = &v1beta1.AppWrapper{} + err = c.client.Post(). + Namespace(c.ns). + Resource("appwrappers"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(appWrapper). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a appWrapper and updates it. Returns the server's representation of the appWrapper, and an error, if there is any. +func (c *appWrappers) Update(ctx context.Context, appWrapper *v1beta1.AppWrapper, opts v1.UpdateOptions) (result *v1beta1.AppWrapper, err error) { + result = &v1beta1.AppWrapper{} + err = c.client.Put(). + Namespace(c.ns). + Resource("appwrappers"). + Name(appWrapper.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(appWrapper). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *appWrappers) UpdateStatus(ctx context.Context, appWrapper *v1beta1.AppWrapper, opts v1.UpdateOptions) (result *v1beta1.AppWrapper, err error) { + result = &v1beta1.AppWrapper{} + err = c.client.Put(). + Namespace(c.ns). + Resource("appwrappers"). + Name(appWrapper.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(appWrapper). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the appWrapper and deletes it. Returns an error if one occurs. +func (c *appWrappers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("appwrappers"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *appWrappers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("appwrappers"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched appWrapper. +func (c *appWrappers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.AppWrapper, err error) { + result = &v1beta1.AppWrapper{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("appwrappers"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/controller/v1beta1/controller_client.go b/pkg/client/clientset/versioned/typed/controller/v1beta1/controller_client.go new file mode 100644 index 000000000..3309fdf2c --- /dev/null +++ b/pkg/client/clientset/versioned/typed/controller/v1beta1/controller_client.go @@ -0,0 +1,89 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +import ( + v1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" + "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type McadV1beta1Interface interface { + RESTClient() rest.Interface + AppWrappersGetter +} + +// McadV1beta1Client is used to interact with features provided by the mcad.ibm.com group. +type McadV1beta1Client struct { + restClient rest.Interface +} + +func (c *McadV1beta1Client) AppWrappers(namespace string) AppWrapperInterface { + return newAppWrappers(c, namespace) +} + +// NewForConfig creates a new McadV1beta1Client for the given config. +func NewForConfig(c *rest.Config) (*McadV1beta1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &McadV1beta1Client{client}, nil +} + +// NewForConfigOrDie creates a new McadV1beta1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *McadV1beta1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new McadV1beta1Client for the given RESTClient. +func New(c rest.Interface) *McadV1beta1Client { + return &McadV1beta1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1beta1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *McadV1beta1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/client/clientset/versioned/typed/controller/v1beta1/doc.go b/pkg/client/clientset/versioned/typed/controller/v1beta1/doc.go new file mode 100644 index 000000000..87525aa15 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/controller/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/pkg/client/clientset/versioned/typed/controller/v1beta1/fake/doc.go b/pkg/client/clientset/versioned/typed/controller/v1beta1/fake/doc.go new file mode 100644 index 000000000..8804eb10a --- /dev/null +++ b/pkg/client/clientset/versioned/typed/controller/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/pkg/client/clientset/versioned/typed/controller/v1beta1/fake/fake_appwrapper.go b/pkg/client/clientset/versioned/typed/controller/v1beta1/fake/fake_appwrapper.go new file mode 100644 index 000000000..6d998f201 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/controller/v1beta1/fake/fake_appwrapper.go @@ -0,0 +1,142 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + v1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeAppWrappers implements AppWrapperInterface +type FakeAppWrappers struct { + Fake *FakeMcadV1beta1 + ns string +} + +var appwrappersResource = schema.GroupVersionResource{Group: "mcad.ibm.com", Version: "v1beta1", Resource: "appwrappers"} + +var appwrappersKind = schema.GroupVersionKind{Group: "mcad.ibm.com", Version: "v1beta1", Kind: "AppWrapper"} + +// Get takes name of the appWrapper, and returns the corresponding appWrapper object, and an error if there is any. +func (c *FakeAppWrappers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.AppWrapper, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(appwrappersResource, c.ns, name), &v1beta1.AppWrapper{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.AppWrapper), err +} + +// List takes label and field selectors, and returns the list of AppWrappers that match those selectors. +func (c *FakeAppWrappers) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.AppWrapperList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(appwrappersResource, appwrappersKind, c.ns, opts), &v1beta1.AppWrapperList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta1.AppWrapperList{ListMeta: obj.(*v1beta1.AppWrapperList).ListMeta} + for _, item := range obj.(*v1beta1.AppWrapperList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested appWrappers. +func (c *FakeAppWrappers) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(appwrappersResource, c.ns, opts)) + +} + +// Create takes the representation of a appWrapper and creates it. Returns the server's representation of the appWrapper, and an error, if there is any. +func (c *FakeAppWrappers) Create(ctx context.Context, appWrapper *v1beta1.AppWrapper, opts v1.CreateOptions) (result *v1beta1.AppWrapper, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(appwrappersResource, c.ns, appWrapper), &v1beta1.AppWrapper{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.AppWrapper), err +} + +// Update takes the representation of a appWrapper and updates it. Returns the server's representation of the appWrapper, and an error, if there is any. +func (c *FakeAppWrappers) Update(ctx context.Context, appWrapper *v1beta1.AppWrapper, opts v1.UpdateOptions) (result *v1beta1.AppWrapper, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(appwrappersResource, c.ns, appWrapper), &v1beta1.AppWrapper{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.AppWrapper), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeAppWrappers) UpdateStatus(ctx context.Context, appWrapper *v1beta1.AppWrapper, opts v1.UpdateOptions) (*v1beta1.AppWrapper, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(appwrappersResource, "status", c.ns, appWrapper), &v1beta1.AppWrapper{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.AppWrapper), err +} + +// Delete takes name of the appWrapper and deletes it. Returns an error if one occurs. +func (c *FakeAppWrappers) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(appwrappersResource, c.ns, name), &v1beta1.AppWrapper{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeAppWrappers) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(appwrappersResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, &v1beta1.AppWrapperList{}) + return err +} + +// Patch applies the patch and returns the patched appWrapper. +func (c *FakeAppWrappers) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.AppWrapper, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(appwrappersResource, c.ns, name, pt, data, subresources...), &v1beta1.AppWrapper{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.AppWrapper), err +} diff --git a/pkg/client/clientset/versioned/typed/controller/v1beta1/fake/fake_controller_client.go b/pkg/client/clientset/versioned/typed/controller/v1beta1/fake/fake_controller_client.go new file mode 100644 index 000000000..606bd0de7 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/controller/v1beta1/fake/fake_controller_client.go @@ -0,0 +1,40 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned/typed/controller/v1beta1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeMcadV1beta1 struct { + *testing.Fake +} + +func (c *FakeMcadV1beta1) AppWrappers(namespace string) v1beta1.AppWrapperInterface { + return &FakeAppWrappers{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeMcadV1beta1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/client/clientset/versioned/typed/controller/v1beta1/generated_expansion.go b/pkg/client/clientset/versioned/typed/controller/v1beta1/generated_expansion.go new file mode 100644 index 000000000..e14e49e79 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/controller/v1beta1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1beta1 + +type AppWrapperExpansion interface{} diff --git a/pkg/client/informers/controller-externalversion/doc.go b/pkg/client/informers/controller-externalversion/doc.go new file mode 100644 index 000000000..32c77ae23 --- /dev/null +++ b/pkg/client/informers/controller-externalversion/doc.go @@ -0,0 +1,7 @@ +// Package controller_externalversion provides a set of Appwrapper informers to be used with interacting with AppWrapper CRDS. +// +// Deprecated: controller_externalversion has been replaced by the external version as that package is generated using the client gen tool. +// controller_externalversion interfaces and methods should not be used except for compatibility. It will be removed in future versions. +// +// This package is frozen and no new functionality will be added. +package controller_externalversion diff --git a/pkg/client/informers/controller-externalversion/internalinterfaces/doc.go b/pkg/client/informers/controller-externalversion/internalinterfaces/doc.go new file mode 100644 index 000000000..46be2f7ac --- /dev/null +++ b/pkg/client/informers/controller-externalversion/internalinterfaces/doc.go @@ -0,0 +1,5 @@ +// Deprecated: internalinterfaces has been replaced by the v1beta as that package is generated using the client gen tool. +// internalinterfaces interfaces and methods should not be used except for compatibility. It will be removed in future versions. +// +// This package is frozen and no new functionality will be added. +package internalinterfaces diff --git a/pkg/client/informers/controller-externalversion/v1/doc.go b/pkg/client/informers/controller-externalversion/v1/doc.go new file mode 100644 index 000000000..dd13ca1b8 --- /dev/null +++ b/pkg/client/informers/controller-externalversion/v1/doc.go @@ -0,0 +1,7 @@ +// Package v1 provides a set of Appwrapper informers to be used with interacting with AppWrapper CRDS. +// +// Deprecated: v1 has been replaced by the v1beta as that package is generated using the client gen tool. +// v1 interfaces and methods should not be used except for compatibility. It will be removed in future versions. +// +// This package is frozen and no new functionality will be added. +package v1 diff --git a/pkg/client/informers/externalversions/factory.go b/pkg/client/informers/externalversions/factory.go new file mode 100644 index 000000000..b38a52bdf --- /dev/null +++ b/pkg/client/informers/externalversions/factory.go @@ -0,0 +1,180 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package externalversions + +import ( + reflect "reflect" + sync "sync" + time "time" + + versioned "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned" + controller "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/externalversions/controller" + internalinterfaces "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/externalversions/internalinterfaces" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" +) + +// SharedInformerOption defines the functional option type for SharedInformerFactory. +type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory + +type sharedInformerFactory struct { + client versioned.Interface + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc + lock sync.Mutex + defaultResync time.Duration + customResync map[reflect.Type]time.Duration + + informers map[reflect.Type]cache.SharedIndexInformer + // startedInformers is used for tracking which informers have been started. + // This allows Start() to be called multiple times safely. + startedInformers map[reflect.Type]bool +} + +// WithCustomResyncConfig sets a custom resync period for the specified informer types. +func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + for k, v := range resyncConfig { + factory.customResync[reflect.TypeOf(k)] = v + } + return factory + } +} + +// WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory. +func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.tweakListOptions = tweakListOptions + return factory + } +} + +// WithNamespace limits the SharedInformerFactory to the specified namespace. +func WithNamespace(namespace string) SharedInformerOption { + return func(factory *sharedInformerFactory) *sharedInformerFactory { + factory.namespace = namespace + return factory + } +} + +// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces. +func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync) +} + +// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory. +// Listers obtained via this SharedInformerFactory will be subject to the same filters +// as specified here. +// Deprecated: Please use NewSharedInformerFactoryWithOptions instead +func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory { + return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions)) +} + +// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options. +func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory { + factory := &sharedInformerFactory{ + client: client, + namespace: v1.NamespaceAll, + defaultResync: defaultResync, + informers: make(map[reflect.Type]cache.SharedIndexInformer), + startedInformers: make(map[reflect.Type]bool), + customResync: make(map[reflect.Type]time.Duration), + } + + // Apply all options + for _, opt := range options { + factory = opt(factory) + } + + return factory +} + +// Start initializes all requested informers. +func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { + f.lock.Lock() + defer f.lock.Unlock() + + for informerType, informer := range f.informers { + if !f.startedInformers[informerType] { + go informer.Run(stopCh) + f.startedInformers[informerType] = true + } + } +} + +// WaitForCacheSync waits for all started informers' cache were synced. +func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool { + informers := func() map[reflect.Type]cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informers := map[reflect.Type]cache.SharedIndexInformer{} + for informerType, informer := range f.informers { + if f.startedInformers[informerType] { + informers[informerType] = informer + } + } + return informers + }() + + res := map[reflect.Type]bool{} + for informType, informer := range informers { + res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced) + } + return res +} + +// InternalInformerFor returns the SharedIndexInformer for obj using an internal +// client. +func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer { + f.lock.Lock() + defer f.lock.Unlock() + + informerType := reflect.TypeOf(obj) + informer, exists := f.informers[informerType] + if exists { + return informer + } + + resyncPeriod, exists := f.customResync[informerType] + if !exists { + resyncPeriod = f.defaultResync + } + + informer = newFunc(f.client, resyncPeriod) + f.informers[informerType] = informer + + return informer +} + +// SharedInformerFactory provides shared informers for resources in all known +// API group versions. +type SharedInformerFactory interface { + internalinterfaces.SharedInformerFactory + ForResource(resource schema.GroupVersionResource) (GenericInformer, error) + WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool + + Mcad() controller.Interface +} + +func (f *sharedInformerFactory) Mcad() controller.Interface { + return controller.New(f, f.namespace, f.tweakListOptions) +} From 5530dfc2ee58db1f34af570fa9ebb4d236f88ca1 Mon Sep 17 00:00:00 2001 From: Laurentiu Bradin <109964136+z103cb@users.noreply.github.com> Date: Tue, 1 Aug 2023 15:23:03 +0300 Subject: [PATCH 2/5] Added missing files. --- .../externalversions/controller/interface.go | 46 +++++ .../controller/v1beta1/appwrapper.go | 90 ++++++++++ .../controller/v1beta1/interface.go | 45 +++++ .../informers/externalversions/generic.go | 62 +++++++ .../internalinterfaces/factory_interfaces.go | 40 +++++ pkg/client/listers/controller/v1/doc.go | 7 + .../listers/controller/v1beta1/appwrapper.go | 99 +++++++++++ .../controller/v1beta1/expansion_generated.go | 27 +++ .../queuejob/queuejob_controller_ex.go | 161 ++++++++++-------- .../queuejobdispatch/queuejobagent.go | 43 ++--- .../qm_lib_backend_with_quotasubt_mgr.go | 6 +- 11 files changed, 520 insertions(+), 106 deletions(-) create mode 100644 pkg/client/informers/externalversions/controller/interface.go create mode 100644 pkg/client/informers/externalversions/controller/v1beta1/appwrapper.go create mode 100644 pkg/client/informers/externalversions/controller/v1beta1/interface.go create mode 100644 pkg/client/informers/externalversions/generic.go create mode 100644 pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go create mode 100644 pkg/client/listers/controller/v1/doc.go create mode 100644 pkg/client/listers/controller/v1beta1/appwrapper.go create mode 100644 pkg/client/listers/controller/v1beta1/expansion_generated.go diff --git a/pkg/client/informers/externalversions/controller/interface.go b/pkg/client/informers/externalversions/controller/interface.go new file mode 100644 index 000000000..dec27275b --- /dev/null +++ b/pkg/client/informers/externalversions/controller/interface.go @@ -0,0 +1,46 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package controller + +import ( + v1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/externalversions/controller/v1beta1" + internalinterfaces "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1beta1 provides access to shared informers for resources in V1beta1. + V1beta1() v1beta1.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1beta1 returns a new v1beta1.Interface. +func (g *group) V1beta1() v1beta1.Interface { + return v1beta1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/client/informers/externalversions/controller/v1beta1/appwrapper.go b/pkg/client/informers/externalversions/controller/v1beta1/appwrapper.go new file mode 100644 index 000000000..0fe752c88 --- /dev/null +++ b/pkg/client/informers/externalversions/controller/v1beta1/appwrapper.go @@ -0,0 +1,90 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "context" + time "time" + + controllerv1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" + versioned "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned" + internalinterfaces "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/externalversions/internalinterfaces" + v1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers/controller/v1beta1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// AppWrapperInformer provides access to a shared informer and lister for +// AppWrappers. +type AppWrapperInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1beta1.AppWrapperLister +} + +type appWrapperInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewAppWrapperInformer constructs a new informer for AppWrapper type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewAppWrapperInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredAppWrapperInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredAppWrapperInformer constructs a new informer for AppWrapper type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredAppWrapperInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.McadV1beta1().AppWrappers(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.McadV1beta1().AppWrappers(namespace).Watch(context.TODO(), options) + }, + }, + &controllerv1beta1.AppWrapper{}, + resyncPeriod, + indexers, + ) +} + +func (f *appWrapperInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredAppWrapperInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *appWrapperInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&controllerv1beta1.AppWrapper{}, f.defaultInformer) +} + +func (f *appWrapperInformer) Lister() v1beta1.AppWrapperLister { + return v1beta1.NewAppWrapperLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/controller/v1beta1/interface.go b/pkg/client/informers/externalversions/controller/v1beta1/interface.go new file mode 100644 index 000000000..03a6f44d6 --- /dev/null +++ b/pkg/client/informers/externalversions/controller/v1beta1/interface.go @@ -0,0 +1,45 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1beta1 + +import ( + internalinterfaces "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // AppWrappers returns a AppWrapperInformer. + AppWrappers() AppWrapperInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// AppWrappers returns a AppWrapperInformer. +func (v *version) AppWrappers() AppWrapperInformer { + return &appWrapperInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go new file mode 100644 index 000000000..7ccb5819e --- /dev/null +++ b/pkg/client/informers/externalversions/generic.go @@ -0,0 +1,62 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package externalversions + +import ( + "fmt" + + v1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" + schema "k8s.io/apimachinery/pkg/runtime/schema" + cache "k8s.io/client-go/tools/cache" +) + +// GenericInformer is type of SharedIndexInformer which will locate and delegate to other +// sharedInformers based on type +type GenericInformer interface { + Informer() cache.SharedIndexInformer + Lister() cache.GenericLister +} + +type genericInformer struct { + informer cache.SharedIndexInformer + resource schema.GroupResource +} + +// Informer returns the SharedIndexInformer. +func (f *genericInformer) Informer() cache.SharedIndexInformer { + return f.informer +} + +// Lister returns the GenericLister. +func (f *genericInformer) Lister() cache.GenericLister { + return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) +} + +// ForResource gives generic access to a shared informer of the matching type +// TODO extend this to unknown resources with a client pool +func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { + switch resource { + // Group=mcad.ibm.com, Version=v1beta1 + case v1beta1.SchemeGroupVersion.WithResource("appwrappers"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Mcad().V1beta1().AppWrappers().Informer()}, nil + + } + + return nil, fmt.Errorf("no informer found for %v", resource) +} diff --git a/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go b/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go new file mode 100644 index 000000000..04b8340ca --- /dev/null +++ b/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -0,0 +1,40 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package internalinterfaces + +import ( + time "time" + + versioned "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + cache "k8s.io/client-go/tools/cache" +) + +// NewInformerFunc takes versioned.Interface and time.Duration to return a SharedIndexInformer. +type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer + +// SharedInformerFactory a small interface to allow for adding an informer without an import cycle +type SharedInformerFactory interface { + Start(stopCh <-chan struct{}) + InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer +} + +// TweakListOptionsFunc is a function that transforms a v1.ListOptions. +type TweakListOptionsFunc func(*v1.ListOptions) diff --git a/pkg/client/listers/controller/v1/doc.go b/pkg/client/listers/controller/v1/doc.go new file mode 100644 index 000000000..589a06e38 --- /dev/null +++ b/pkg/client/listers/controller/v1/doc.go @@ -0,0 +1,7 @@ +// Package v1 provides a set of Appwrapper lister to be used with interacting with AppWrapper CRDS. +// +// Deprecated: v1 has been replaced by the v1beta as that package is generated using the client gen tool. +// v1 interfaces and methods should not be used except for compatibility. It will be removed in future versions. +// +// This package is frozen and no new functionality will be added. +package v1 diff --git a/pkg/client/listers/controller/v1beta1/appwrapper.go b/pkg/client/listers/controller/v1beta1/appwrapper.go new file mode 100644 index 000000000..b99fb2af1 --- /dev/null +++ b/pkg/client/listers/controller/v1beta1/appwrapper.go @@ -0,0 +1,99 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1beta1 + +import ( + v1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// AppWrapperLister helps list AppWrappers. +// All objects returned here must be treated as read-only. +type AppWrapperLister interface { + // List lists all AppWrappers in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1beta1.AppWrapper, err error) + // AppWrappers returns an object that can list and get AppWrappers. + AppWrappers(namespace string) AppWrapperNamespaceLister + AppWrapperListerExpansion +} + +// appWrapperLister implements the AppWrapperLister interface. +type appWrapperLister struct { + indexer cache.Indexer +} + +// NewAppWrapperLister returns a new AppWrapperLister. +func NewAppWrapperLister(indexer cache.Indexer) AppWrapperLister { + return &appWrapperLister{indexer: indexer} +} + +// List lists all AppWrappers in the indexer. +func (s *appWrapperLister) List(selector labels.Selector) (ret []*v1beta1.AppWrapper, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.AppWrapper)) + }) + return ret, err +} + +// AppWrappers returns an object that can list and get AppWrappers. +func (s *appWrapperLister) AppWrappers(namespace string) AppWrapperNamespaceLister { + return appWrapperNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// AppWrapperNamespaceLister helps list and get AppWrappers. +// All objects returned here must be treated as read-only. +type AppWrapperNamespaceLister interface { + // List lists all AppWrappers in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1beta1.AppWrapper, err error) + // Get retrieves the AppWrapper from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1beta1.AppWrapper, error) + AppWrapperNamespaceListerExpansion +} + +// appWrapperNamespaceLister implements the AppWrapperNamespaceLister +// interface. +type appWrapperNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all AppWrappers in the indexer for a given namespace. +func (s appWrapperNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.AppWrapper, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.AppWrapper)) + }) + return ret, err +} + +// Get retrieves the AppWrapper from the indexer for a given namespace and name. +func (s appWrapperNamespaceLister) Get(name string) (*v1beta1.AppWrapper, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1beta1.Resource("appwrapper"), name) + } + return obj.(*v1beta1.AppWrapper), nil +} diff --git a/pkg/client/listers/controller/v1beta1/expansion_generated.go b/pkg/client/listers/controller/v1beta1/expansion_generated.go new file mode 100644 index 000000000..8b87cd337 --- /dev/null +++ b/pkg/client/listers/controller/v1beta1/expansion_generated.go @@ -0,0 +1,27 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1beta1 + +// AppWrapperListerExpansion allows custom methods to be added to +// AppWrapperLister. +type AppWrapperListerExpansion interface{} + +// AppWrapperNamespaceListerExpansion allows custom methods to be added to +// AppWrapperNamespaceLister. +type AppWrapperNamespaceListerExpansion interface{} diff --git a/pkg/controller/queuejob/queuejob_controller_ex.go b/pkg/controller/queuejob/queuejob_controller_ex.go index 0bc84d108..03639ef57 100644 --- a/pkg/controller/queuejob/queuejob_controller_ex.go +++ b/pkg/controller/queuejob/queuejob_controller_ex.go @@ -17,6 +17,7 @@ limitations under the License. package queuejob import ( + "context" jsons "encoding/json" "errors" "fmt" @@ -60,11 +61,15 @@ import ( "k8s.io/apimachinery/pkg/labels" arbv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" - clientset "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/controller-versioned" - "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/controller-versioned/clients" - arbinformers "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/controller-externalversion" - informersv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/controller-externalversion/v1" - listersv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers/controller/v1" + clientset "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned" + + // arbinformers "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/controller-externalversion" + informerFactory "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/externalversions" + arbinformers "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/externalversions/controller/v1beta1" + + // informersv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/controller-externalversion/v1" + // listersv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers/controller/v1" + arblisters "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers/controller/v1beta1" "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/controller/queuejobdispatch" @@ -77,7 +82,7 @@ type XController struct { config *rest.Config serverOption *options.ServerOption - queueJobInformer informersv1.AppWrapperInformer + appwrapperInformer arbinformers.AppWrapperInformer // resources registered for the AppWrapper qjobRegisteredResources queuejobresources.RegisteredResources // controllers for these resources @@ -90,8 +95,8 @@ type XController struct { arbclients *clientset.Clientset // A store of jobs - queueJobLister listersv1.AppWrapperLister - queueJobSynced func() bool + appWrapperLister arblisters.AppWrapperLister + appWrapperSynced func() bool // QueueJobs that need to be initialized // Add labels and selectors to AppWrapper @@ -186,12 +191,12 @@ func NewJobController(config *rest.Config, serverOption *options.ServerOption) * } cc.qjobResControls[arbv1.ResourceTypePod] = resControlPod - queueJobClient, _, err := clients.NewClient(cc.config) + appWrapperClient, err := clientset.NewForConfig(cc.config) if err != nil { - panic(err) + klog.Fatalf("Could not instantiate k8s client") } - cc.queueJobInformer = arbinformers.NewSharedInformerFactory(queueJobClient, 0).AppWrapper().AppWrappers() - cc.queueJobInformer.Informer().AddEventHandler( + cc.appwrapperInformer = informerFactory.NewSharedInformerFactory(appWrapperClient, 0).Mcad().V1beta1().AppWrappers() + cc.appwrapperInformer.Informer().AddEventHandler( cache.FilteringResourceEventHandler{ FilterFunc: func(obj interface{}) bool { switch t := obj.(type) { @@ -214,13 +219,13 @@ func NewJobController(config *rest.Config, serverOption *options.ServerOption) * DeleteFunc: cc.deleteQueueJob, }, }) - cc.queueJobLister = cc.queueJobInformer.Lister() - cc.queueJobSynced = cc.queueJobInformer.Informer().HasSynced + cc.appWrapperLister = cc.appwrapperInformer.Lister() + cc.appWrapperSynced = cc.appwrapperInformer.Informer().HasSynced // Setup Quota if serverOption.QuotaEnabled { dispatchedAWDemands, dispatchedAWs := cc.getDispatchedAppWrappers() - cc.quotaManager, err = quotaforestmanager.NewQuotaManager(dispatchedAWDemands, dispatchedAWs, cc.queueJobLister, + cc.quotaManager, err = quotaforestmanager.NewQuotaManager(dispatchedAWDemands, dispatchedAWs, cc.appWrapperLister, config, serverOption) if err != nil { klog.Error("Failed to instantiate quota manager: %#v", err) @@ -259,6 +264,8 @@ func NewJobController(config *rest.Config, serverOption *options.ServerOption) * } func (qjm *XController) PreemptQueueJobs() { + ctx := context.Background() + qjobs := qjm.GetQueueJobsEligibleForPreemption() for _, aw := range qjobs { if aw.Status.State == arbv1.AppWrapperStateCompleted || aw.Status.State == arbv1.AppWrapperStateDeleted || aw.Status.State == arbv1.AppWrapperStateFailed { @@ -293,7 +300,7 @@ func (qjm *XController) PreemptQueueJobs() { newjob.Status.Running = 0 updateNewJob = newjob.DeepCopy() - err := qjm.updateStatusInEtcdWithRetry(updateNewJob, "PreemptQueueJobs - CanRun: false -- DispatchDeadlineExceeded") + err := qjm.updateStatusInEtcdWithRetry(ctx, updateNewJob, "PreemptQueueJobs - CanRun: false -- DispatchDeadlineExceeded") if err != nil { klog.Warningf("[PreemptQueueJobs] status update CanRun: false -- DispatchDeadlineExceeded for '%s/%s' failed", aw.Namespace, aw.Name) continue @@ -361,7 +368,7 @@ func (qjm *XController) PreemptQueueJobs() { updateNewJob = newjob.DeepCopy() } - err = qjm.updateStatusInEtcdWithRetry(updateNewJob, "PreemptQueueJobs - CanRun: false -- MinPodsNotRunning") + err = qjm.updateStatusInEtcdWithRetry(ctx, updateNewJob, "PreemptQueueJobs - CanRun: false -- MinPodsNotRunning") if err != nil { klog.Warningf("[PreemptQueueJobs] status update for '%s/%s' failed, skipping app wrapper err =%v", aw.Namespace, aw.Name, err) continue @@ -369,18 +376,18 @@ func (qjm *XController) PreemptQueueJobs() { if cleanAppWrapper { klog.V(4).Infof("[PreemptQueueJobs] Deleting AppWrapper %s/%s due to maximum number of re-queueing(s) exceeded.", aw.Name, aw.Namespace) - go qjm.Cleanup(updateNewJob) + go qjm.Cleanup(ctx, updateNewJob) } else { // Only back-off AWs that are in state running and not in state Failed if updateNewJob.Status.State != arbv1.AppWrapperStateFailed { klog.Infof("[PreemptQueueJobs] Adding preempted AppWrapper %s/%s to back off queue.", aw.Name, aw.Namespace) - go qjm.backoff(updateNewJob, "PreemptionTriggered", string(message)) + go qjm.backoff(ctx, updateNewJob, "PreemptionTriggered", string(message)) } } } } -func (qjm *XController) preemptAWJobs(preemptAWs []*arbv1.AppWrapper) { +func (qjm *XController) preemptAWJobs(ctx context.Context, preemptAWs []*arbv1.AppWrapper) { if preemptAWs == nil { return } @@ -397,7 +404,7 @@ func (qjm *XController) preemptAWJobs(preemptAWs []*arbv1.AppWrapper) { continue } apiCacheAWJob.Status.CanRun = false - err = qjm.updateStatusInEtcdWithRetry(apiCacheAWJob, "preemptAWJobs - CanRun: false") + err = qjm.updateStatusInEtcdWithRetry(ctx, apiCacheAWJob, "preemptAWJobs - CanRun: false") if err != nil { if apierrors.IsNotFound(err) { klog.Warningf("[preemptAWJobs] App wrapper '%s/%s' was not found when updating status. ", aw.Namespace, aw.Name) @@ -411,7 +418,7 @@ func (qjm *XController) preemptAWJobs(preemptAWs []*arbv1.AppWrapper) { func (qjm *XController) GetQueueJobsEligibleForPreemption() []*arbv1.AppWrapper { qjobs := make([]*arbv1.AppWrapper, 0) - queueJobs, err := qjm.queueJobLister.AppWrappers("").List(labels.Everything()) + queueJobs, err := qjm.appWrapperLister.AppWrappers("").List(labels.Everything()) if err != nil { klog.Errorf("List of queueJobs %+v", qjobs) return qjobs @@ -648,12 +655,12 @@ func (qjm *XController) getDispatchedAppWrappers() (map[string]*clusterstateapi. awrRetVal := make(map[string]*clusterstateapi.Resource) awsRetVal := make(map[string]*arbv1.AppWrapper) // Setup and break down an informer to get a list of appwrappers bofore controllerinitialization completes - appwrapperJobClient, _, err := clients.NewClient(qjm.config) + appWrapperClient, err := clientset.NewForConfig(qjm.config) if err != nil { klog.Errorf("[getDispatchedAppWrappers] Failure creating client for initialization informer err=%#v", err) return awrRetVal, awsRetVal } - queueJobInformer := arbinformers.NewSharedInformerFactory(appwrapperJobClient, 0).AppWrapper().AppWrappers() + queueJobInformer := informerFactory.NewSharedInformerFactory(appWrapperClient, 0).Mcad().V1beta1().AppWrappers() queueJobInformer.Informer().AddEventHandler( cache.FilteringResourceEventHandler{ FilterFunc: func(obj interface{}) bool { @@ -723,7 +730,7 @@ func (qjm *XController) getAggregatedAvailableResourcesPriority(unallocatedClust pending := clusterstateapi.EmptyResource() klog.V(3).Infof("[getAggAvaiResPri] Idle cluster resources %+v", r) - queueJobs, err := qjm.queueJobLister.AppWrappers("").List(labels.Everything()) + queueJobs, err := qjm.appWrapperLister.AppWrappers("").List(labels.Everything()) if err != nil { klog.Errorf("[getAggAvaiResPri] Unable to obtain the list of queueJobs %+v", err) return r, nil @@ -819,7 +826,7 @@ func addPreemptableAWs(preemptableAWs map[float64][]string, value *arbv1.AppWrap klog.V(10).Infof("[getAggAvaiResPri] %s: Added %s to candidate preemptable job with priority %f.", time.Now().String(), value.Name, value.Status.SystemPriority) } -func (qjm *XController) chooseAgent(qj *arbv1.AppWrapper) string { +func (qjm *XController) chooseAgent(ctx context.Context, qj *arbv1.AppWrapper) string { qjAggrResources := qjm.GetAggregatedResources(qj) klog.V(2).Infof("[chooseAgent] Aggregated Resources of XQJ %s: %v\n", qj.Name, qjAggrResources) @@ -840,7 +847,7 @@ func (qjm *XController) chooseAgent(qj *arbv1.AppWrapper) string { if qjm.quotaManager != nil { if fits, preemptAWs, _ := qjm.quotaManager.Fits(qj, qjAggrResources, proposedPreemptions); fits { klog.V(2).Infof("[chooseAgent] AppWrapper %s has enough quota.\n", qj.Name) - qjm.preemptAWJobs(preemptAWs) + qjm.preemptAWJobs(ctx, preemptAWs) return agentId } else { klog.V(2).Infof("[chooseAgent] AppWrapper %s does not have enough quota\n", qj.Name) @@ -906,6 +913,7 @@ func (qjm *XController) nodeChecks(histograms map[string]*dto.Metric, aw *arbv1. // Thread to find queue-job(QJ) for next schedule func (qjm *XController) ScheduleNext() { + ctx := context.Background() // get next QJ from the queue // check if we have enough compute resources for it // if we have enough compute resources then we set the AllocatedReplicas to the total @@ -1005,7 +1013,7 @@ func (qjm *XController) ScheduleNext() { qjm.addOrUpdateCondition(qj, arbv1.AppWrapperCondHeadOfLine, v1.ConditionTrue, "FrontOfQueue.", "") qj.Status.FilterIgnore = true // update QueueJobState only - retryErr = qjm.updateStatusInEtcd(qj, "ScheduleNext - setHOL") + retryErr = qjm.updateStatusInEtcd(ctx, qj, "ScheduleNext - setHOL") if retryErr != nil { if apierrors.IsConflict(retryErr) { klog.Warningf("[ScheduleNext] Conflict error detected when updating status in etcd for app wrapper '%s/%s, status = %+v. Retrying update.", qj.Namespace, qj.Name, qj.Status) @@ -1026,7 +1034,7 @@ func (qjm *XController) ScheduleNext() { dispatchFailedReason := "AppWrapperNotRunnable." dispatchFailedMessage := "" if qjm.isDispatcher { // Dispatcher Mode - agentId := qjm.chooseAgent(qj) + agentId := qjm.chooseAgent(ctx, qj) if agentId != "" { // A proper agent is found. // Update states (CanRun=True) of XQJ in API Server // Add XQJ -> Agent Map @@ -1049,7 +1057,7 @@ func (qjm *XController) ScheduleNext() { queueJobKey, _ := GetQueueJobKey(qj) qjm.dispatchMap[queueJobKey] = agentId klog.V(10).Infof("[ScheduleNext] [Dispatcher Mode] %s, %s: ScheduleNextBeforeEtcd", qj.Name, time.Now().Sub(qj.CreationTimestamp.Time)) - retryErr = qjm.updateStatusInEtcd(qj, "[ScheduleNext] [Dispatcher Mode] - setCanRun") + retryErr = qjm.updateStatusInEtcd(ctx, qj, "[ScheduleNext] [Dispatcher Mode] - setCanRun") if retryErr != nil { if apierrors.IsConflict(err) { klog.Warningf("[ScheduleNext] [Dispatcher Mode] Conflict error detected when updating status in etcd for app wrapper '%s/%s, status = %+v. Retrying update.", qj.Namespace, qj.Name, qj.Status) @@ -1072,7 +1080,7 @@ func (qjm *XController) ScheduleNext() { } else { dispatchFailedMessage = "Cannot find an cluster with enough resources to dispatch AppWrapper." klog.V(2).Infof("[ScheduleNex] [Dispatcher Mode] %s %s\n", dispatchFailedReason, dispatchFailedMessage) - go qjm.backoff(qj, dispatchFailedReason, dispatchFailedMessage) + go qjm.backoff(ctx, qj, dispatchFailedReason, dispatchFailedMessage) } } else { // Agent Mode aggqj := qjm.GetAggregatedResources(qj) @@ -1142,7 +1150,7 @@ func (qjm *XController) ScheduleNext() { return retryErr } tempAW.SetLabels(newLabels) - updatedAW, retryErr := qjm.updateEtcd(tempAW, "ScheduleNext [Agent Mode] - setDefaultQuota") + updatedAW, retryErr := qjm.updateEtcd(ctx, tempAW, "ScheduleNext [Agent Mode] - setDefaultQuota") if retryErr != nil { if apierrors.IsConflict(err) { klog.Warningf("[ScheduleNext] [Agent mode] Conflict error detected when updating labels in etcd for app wrapper '%s/%s, status = %+v. Retrying update.", qj.Namespace, qj.Name, qj.Status) @@ -1161,7 +1169,7 @@ func (qjm *XController) ScheduleNext() { klog.Infof("[ScheduleNext] [Agent mode] quota evaluation successful for app wrapper '%s/%s' activeQ=%t Unsched=%t &qj=%p Version=%s Status=%+v", qj.Namespace, qj.Name, time.Now().Sub(HOLStartTime), qjm.qjqueue.IfExistActiveQ(qj), qjm.qjqueue.IfExistUnschedulableQ(qj), qj, qj.ResourceVersion, qj.Status) // Set any jobs that are marked for preemption - qjm.preemptAWJobs(preemptAWs) + qjm.preemptAWJobs(ctx, preemptAWs) } else { // Not enough free quota to dispatch appwrapper dispatchFailedMessage = "Insufficient quota to dispatch AppWrapper." if len(msg) > 0 { @@ -1196,7 +1204,7 @@ func (qjm *XController) ScheduleNext() { } tempAW.Status.CanRun = true tempAW.Status.FilterIgnore = true // update CanRun & Spec. no need to trigger event - retryErr = qjm.updateStatusInEtcd(tempAW, "ScheduleNext - setCanRun") + retryErr = qjm.updateStatusInEtcd(ctx, tempAW, "ScheduleNext - setCanRun") if retryErr != nil { if qjm.quotaManager != nil && quotaFits { // Quota was allocated for this appwrapper, release it. @@ -1258,7 +1266,7 @@ func (qjm *XController) ScheduleNext() { if qjm.quotaManager != nil && quotaFits { qjm.quotaManager.Release(qj) } - go qjm.backoff(qj, dispatchFailedReason, dispatchFailedMessage) + go qjm.backoff(ctx, qj, dispatchFailedReason, dispatchFailedMessage) } } return nil @@ -1276,11 +1284,11 @@ func (qjm *XController) ScheduleNext() { // Update AppWrappers in etcd // todo: This is a current workaround for duplicate message bug. -func (cc *XController) updateEtcd(currentAppwrapper *arbv1.AppWrapper, caller string) (*arbv1.AppWrapper, error) { +func (cc *XController) updateEtcd(ctx context.Context, currentAppwrapper *arbv1.AppWrapper, caller string) (*arbv1.AppWrapper, error) { klog.V(4).Infof("[updateEtcd] trying to update '%s/%s' called by '%s'", currentAppwrapper.Namespace, currentAppwrapper.Name, caller) currentAppwrapper.Status.Sender = "before " + caller // set Sender string to indicate code location currentAppwrapper.Status.Local = false // for Informer FilterFunc to pickup - updatedAppwrapper, err := cc.arbclients.ArbV1().AppWrappers(currentAppwrapper.Namespace).Update(currentAppwrapper) + updatedAppwrapper, err := cc.arbclients.McadV1beta1().AppWrappers(currentAppwrapper.Namespace).Update(ctx, currentAppwrapper, metav1.UpdateOptions{}) if err != nil { return nil, err } @@ -1293,10 +1301,10 @@ func (cc *XController) updateEtcd(currentAppwrapper *arbv1.AppWrapper, caller st return updatedAppwrapper.DeepCopy(), nil } -func (cc *XController) updateStatusInEtcd(currentAppwrapper *arbv1.AppWrapper, caller string) error { +func (cc *XController) updateStatusInEtcd(ctx context.Context, currentAppwrapper *arbv1.AppWrapper, caller string) error { klog.V(4).Infof("[updateStatusInEtcd] trying to update '%s/%s' called by '%s'", currentAppwrapper.Namespace, currentAppwrapper.Name, caller) currentAppwrapper.Status.Sender = "before " + caller // set Sender string to indicate code location - updatedAppwrapper, err := cc.arbclients.ArbV1().AppWrappers(currentAppwrapper.Namespace).UpdateStatus(currentAppwrapper) + updatedAppwrapper, err := cc.arbclients.McadV1beta1().AppWrappers(currentAppwrapper.Namespace).UpdateStatus(ctx, currentAppwrapper, metav1.UpdateOptions{}) if err != nil { return err } @@ -1309,15 +1317,15 @@ func (cc *XController) updateStatusInEtcd(currentAppwrapper *arbv1.AppWrapper, c return nil } -func (cc *XController) updateStatusInEtcdWithRetry(source *arbv1.AppWrapper, caller string) error { +func (cc *XController) updateStatusInEtcdWithRetry(ctx context.Context, source *arbv1.AppWrapper, caller string) error { klog.V(4).Infof("[updateStatusInEtcdWithMergeFunction] trying to update '%s/%s' version '%s' called by '%s'", source.Namespace, source.Name, source.ResourceVersion, caller) source.Status.Sender = "before " + caller // set Sender string to indicate code location updateStatusRetrierRetrier := retrier.New(retrier.ExponentialBackoff(10, 100*time.Millisecond), &EtcdErrorClassifier{}) updateStatusRetrierRetrier.SetJitter(0.05) updatedAW := source.DeepCopy() - err := updateStatusRetrierRetrier.Run(func() error { + err := updateStatusRetrierRetrier.RunCtx(ctx, func(localContext context.Context) error { var retryErr error - updatedAW, retryErr = cc.arbclients.ArbV1().AppWrappers(updatedAW.Namespace).UpdateStatus(updatedAW) + updatedAW, retryErr = cc.arbclients.McadV1beta1().AppWrappers(updatedAW.Namespace).UpdateStatus(localContext, updatedAW, metav1.UpdateOptions{}) if retryErr != nil && apierrors.IsConflict(retryErr) { dest, retryErr := cc.getAppWrapper(source.Namespace, source.Name, caller) if retryErr != nil && !apierrors.IsNotFound(retryErr) { @@ -1367,7 +1375,7 @@ func (qjm *XController) addOrUpdateCondition(aw *arbv1.AppWrapper, condType arbv } } -func (qjm *XController) backoff(q *arbv1.AppWrapper, reason string, message string) { +func (qjm *XController) backoff(ctx context.Context, q *arbv1.AppWrapper, reason string, message string) { etcUpdateRetrier := retrier.New(retrier.ExponentialBackoff(10, 100*time.Millisecond), &EtcdErrorClassifier{}) err := etcUpdateRetrier.Run(func() error { @@ -1380,7 +1388,7 @@ func (qjm *XController) backoff(q *arbv1.AppWrapper, reason string, message stri apiCacheAWJob.Status.FilterIgnore = true // update QueueJobState only, no work needed // Update condition qjm.addOrUpdateCondition(apiCacheAWJob, arbv1.AppWrapperCondBackoff, v1.ConditionTrue, reason, message) - if retryErr := qjm.updateStatusInEtcd(apiCacheAWJob, "[backoff] - Rejoining"); retryErr != nil { + if retryErr := qjm.updateStatusInEtcd(ctx, apiCacheAWJob, "[backoff] - Rejoining"); retryErr != nil { if apierrors.IsConflict(retryErr) { klog.Warningf("[backoff] Conflict when upating AW status in etcd '%s/%s'. Retrying.", apiCacheAWJob.Namespace, apiCacheAWJob.Name) } @@ -1406,11 +1414,11 @@ func (cc *XController) Run(stopCh chan struct{}) { // initialized createAppWrapperKind(cc.config) - go cc.queueJobInformer.Informer().Run(stopCh) + go cc.appwrapperInformer.Informer().Run(stopCh) go cc.qjobResControls[arbv1.ResourceTypePod].Run(stopCh) - cache.WaitForCacheSync(stopCh, cc.queueJobSynced) + cache.WaitForCacheSync(stopCh, cc.appWrapperSynced) // update snapshot of ClientStateCache every second cc.cache.Run(stopCh) @@ -1438,16 +1446,17 @@ func (cc *XController) Run(stopCh chan struct{}) { } func (qjm *XController) UpdateAgent() { + ctx := context.Background() klog.V(3).Infof("[Controller] Update AggrResources for All Agents\n") for _, jobClusterAgent := range qjm.agentMap { - jobClusterAgent.UpdateAggrResources() + jobClusterAgent.UpdateAggrResources(ctx) } } func (qjm *XController) UpdateQueueJobs() { firstTime := metav1.NowMicro() // retrieve queueJobs from local cache. no guarantee queueJobs contain up-to-date information - queueJobs, err := qjm.queueJobLister.AppWrappers("").List(labels.Everything()) + queueJobs, err := qjm.appWrapperLister.AppWrappers("").List(labels.Everything()) if err != nil { klog.Errorf("[UpdateQueueJobs] Failed to get a list of active appwrappers, err=%+v", err) return @@ -1608,6 +1617,7 @@ func (cc *XController) enqueueIfNotPresent(obj interface{}) error { } func (cc *XController) agentEventQueueWorker() { + ctx := context.Background() if _, err := cc.agentEventQueue.Pop(func(obj interface{}) error { var queuejob *arbv1.AppWrapper switch v := obj.(type) { @@ -1628,7 +1638,7 @@ func (cc *XController) agentEventQueueWorker() { klog.V(3).Infof("[Controller: Dispatcher Mode] XQJ Status Update from AGENT: Name:%s, Status: %+v\n", queuejob.Name, queuejob.Status) // sync AppWrapper - if err := cc.updateQueueJobStatus(queuejob); err != nil { + if err := cc.updateQueueJobStatus(ctx, queuejob); err != nil { klog.Errorf("Failed to sync AppWrapper %s, err %#v", queuejob.Name, err) // If any error, requeue it. return err @@ -1641,12 +1651,12 @@ func (cc *XController) agentEventQueueWorker() { } } -func (cc *XController) updateQueueJobStatus(queueJobFromAgent *arbv1.AppWrapper) error { - queueJobInEtcd, err := cc.queueJobLister.AppWrappers(queueJobFromAgent.Namespace).Get(queueJobFromAgent.Name) +func (cc *XController) updateQueueJobStatus(ctx context.Context, queueJobFromAgent *arbv1.AppWrapper) error { + queueJobInEtcd, err := cc.appWrapperLister.AppWrappers(queueJobFromAgent.Namespace).Get(queueJobFromAgent.Name) if err != nil { if apierrors.IsNotFound(err) { if cc.isDispatcher { - cc.Cleanup(queueJobFromAgent) + cc.Cleanup(ctx, queueJobFromAgent) cc.qjqueue.Delete(queueJobFromAgent) } return nil @@ -1658,7 +1668,7 @@ func (cc *XController) updateQueueJobStatus(queueJobFromAgent *arbv1.AppWrapper) } new_flag := queueJobFromAgent.Status.State queueJobInEtcd.Status.State = new_flag - _, err = cc.arbclients.ArbV1().AppWrappers(queueJobInEtcd.Namespace).Update(queueJobInEtcd) + _, err = cc.arbclients.McadV1beta1().AppWrappers(queueJobInEtcd.Namespace).Update(ctx, queueJobInEtcd, metav1.UpdateOptions{}) if err != nil { return err } @@ -1666,6 +1676,7 @@ func (cc *XController) updateQueueJobStatus(queueJobFromAgent *arbv1.AppWrapper) } func (cc *XController) worker() { + ctx := context.Background() defer func() { if pErr := recover(); pErr != nil { klog.Errorf("[worker] Panic occurred error: %v, stacktrace: %s", pErr, string(debug.Stack())) @@ -1691,7 +1702,7 @@ func (cc *XController) worker() { } // sync AppWrapper - if err := cc.syncQueueJob(queuejob); err != nil { + if err := cc.syncQueueJob(ctx, queuejob); err != nil { // If any error, requeue it. return err } @@ -1710,12 +1721,12 @@ func (cc *XController) worker() { } } -func (cc *XController) syncQueueJob(qj *arbv1.AppWrapper) error { +func (cc *XController) syncQueueJob(ctx context.Context, qj *arbv1.AppWrapper) error { // validate that app wraper has not been marked for deletion by the infomer's delete handler if qj.DeletionTimestamp != nil { klog.V(3).Infof("[syncQueueJob] AW job=%s/%s set for deletion.", qj.Namespace, qj.Name) // cleanup resources for running job, ignoring errors - if err00 := cc.Cleanup(qj); err00 != nil { + if err00 := cc.Cleanup(ctx, qj); err00 != nil { klog.Warningf("Failed to cleanup resources for app wrapper '%s/%s', err = %v", qj.Namespace, qj.Name, err00) } // empty finalizers and delete the queuejob again @@ -1732,7 +1743,7 @@ func (cc *XController) syncQueueJob(qj *arbv1.AppWrapper) error { if apierrors.IsNotFound(err) { klog.Warningf("[syncQueueJob] AppWrapper '%s/%s' not found in cache and will be deleted", qj.Namespace, qj.Name) // clean up app wrapper resources including quota - if err := cc.Cleanup(qj); err != nil { + if err := cc.Cleanup(ctx, qj); err != nil { klog.Errorf("Failed to delete resources associated with app wrapper: '%s/%s', err %v", qj.Namespace, qj.Name, err) // return error so operation can be retried return err @@ -1772,7 +1783,7 @@ func (cc *XController) syncQueueJob(qj *arbv1.AppWrapper) error { cond := GenerateAppWrapperCondition(arbv1.AppWrapperCondRunning, v1.ConditionTrue, "PodsRunning", "") awNew.Status.Conditions = append(awNew.Status.Conditions, cond) awNew.Status.FilterIgnore = true // Update AppWrapperCondRunning - err := cc.updateStatusInEtcdWithRetry(awNew, "[syncQueueJob] Update pod counts") + err := cc.updateStatusInEtcdWithRetry(ctx, awNew, "[syncQueueJob] Update pod counts") if err != nil { klog.Error("[syncQueueJob] Error updating pod status counts for app wrapper job: '%s/%s', err=%+v.", qj.Namespace, qj.Name, err) return err @@ -1792,14 +1803,14 @@ func (cc *XController) syncQueueJob(qj *arbv1.AppWrapper) error { } } - err = cc.manageQueueJob(qj, podPhaseChanges) + err = cc.manageQueueJob(ctx, qj, podPhaseChanges) return err } // manageQueueJob is the core method responsible for managing the number of running // pods according to what is specified in the job.Spec. // Does NOT modify . -func (cc *XController) manageQueueJob(qj *arbv1.AppWrapper, podPhaseChanges bool) error { +func (cc *XController) manageQueueJob(ctx context.Context, qj *arbv1.AppWrapper, podPhaseChanges bool) error { if !cc.isDispatcher { // Agent Mode // Job is Complete only update pods if needed. @@ -1807,7 +1818,7 @@ func (cc *XController) manageQueueJob(qj *arbv1.AppWrapper, podPhaseChanges bool if podPhaseChanges { // Only update etcd if AW status has changed. This can happen for periodic // updates of pod phase counts done in caller of this function. - err := cc.updateStatusInEtcdWithRetry(qj, "manageQueueJob - podPhaseChanges") + err := cc.updateStatusInEtcdWithRetry(ctx, qj, "manageQueueJob - podPhaseChanges") if err != nil { klog.Errorf("[manageQueueJob] Error updating status for podPhaseChanges for AppWrapper: '%s/%s',Status=%+v, err=%+v.", qj.Namespace, qj.Name, qj.Status, err) return err @@ -1825,7 +1836,7 @@ func (cc *XController) manageQueueJob(qj *arbv1.AppWrapper, podPhaseChanges bool stateLen := len(qj.Status.State) if stateLen > 0 { klog.V(2).Infof("[manageQueueJob] Deleting resources for AppWrapper Job '%s/%s' because it was preempted, status.CanRun=%t, status.State=%s", qj.Namespace, qj.Name, qj.Status.CanRun, qj.Status.State) - err00 := cc.Cleanup(qj) + err00 := cc.Cleanup(ctx, qj) if err00 != nil { klog.Errorf("[manageQueueJob] Failed to delete resources for AppWrapper Job '%s/%s', err=%v", qj.Namespace, qj.Name, err00) return err00 @@ -1852,7 +1863,7 @@ func (cc *XController) manageQueueJob(qj *arbv1.AppWrapper, podPhaseChanges bool } qj.Status.FilterIgnore = true // Update Queueing status, add to qjqueue for ScheduleNext - err := cc.updateStatusInEtcdWithRetry(qj, "manageQueueJob - setQueueing") + err := cc.updateStatusInEtcdWithRetry(ctx, qj, "manageQueueJob - setQueueing") if err != nil { klog.Errorf("[manageQueueJob] Error updating status 'setQueueing' AppWrapper: '%s/%s',Status=%+v, err=%+v.", qj.Namespace, qj.Name, qj.Status, err) return err @@ -1931,7 +1942,7 @@ func (cc *XController) manageQueueJob(qj *arbv1.AppWrapper, podPhaseChanges bool qj.Status.Conditions = append(qj.Status.Conditions, cond) } // clean up app wrapper resources including quota - if err00 := cc.Cleanup(qj); err00 != nil { + if err00 := cc.Cleanup(ctx, qj); err00 != nil { klog.Errorf("Failed to delete resources associated with app wrapper: '%s/%s', err %v", qj.Namespace, qj.Name, err00) // return error so operation can be retried return err00 @@ -1940,7 +1951,7 @@ func (cc *XController) manageQueueJob(qj *arbv1.AppWrapper, podPhaseChanges bool } qj.Status.FilterIgnore = true // update State & QueueJobState after dispatch - err := cc.updateStatusInEtcdWithRetry(qj, "manageQueueJob - afterEtcdDispatching") + err := cc.updateStatusInEtcdWithRetry(ctx, qj, "manageQueueJob - afterEtcdDispatching") if err != nil { klog.Errorf("[manageQueueJob] Error updating status 'afterEtcdDispatching' for AppWrapper: '%s/%s',Status=%+v, err=%+v.", qj.Namespace, qj.Name, qj.Status, err) return err @@ -1973,7 +1984,7 @@ func (cc *XController) manageQueueJob(qj *arbv1.AppWrapper, podPhaseChanges bool qj.Status.Conditions[index] = *cond.DeepCopy() updateQj = qj.DeepCopy() } - err := cc.updateStatusInEtcdWithRetry(updateQj, "[manageQueueJob] setRunningHoldCompletion") + err := cc.updateStatusInEtcdWithRetry(ctx, updateQj, "[manageQueueJob] setRunningHoldCompletion") if err != nil { klog.Errorf("[manageQueueJob] Error updating status 'setRunningHoldCompletion' for AppWrapper: '%s/%s',Status=%+v, err=%+v.", qj.Namespace, qj.Name, qj.Status, err) return err @@ -1996,7 +2007,7 @@ func (cc *XController) manageQueueJob(qj *arbv1.AppWrapper, podPhaseChanges bool qj.Status.Conditions[index] = *cond.DeepCopy() updateQj = qj.DeepCopy() } - err := cc.updateStatusInEtcdWithRetry(updateQj, "[manageQueueJob] setCompleted") + err := cc.updateStatusInEtcdWithRetry(ctx, updateQj, "[manageQueueJob] setCompleted") if err != nil { if cc.quotaManager != nil { cc.quotaManager.Release(updateQj) @@ -2014,7 +2025,7 @@ func (cc *XController) manageQueueJob(qj *arbv1.AppWrapper, podPhaseChanges bool } else if podPhaseChanges { // Continued bug fix // Only update etcd if AW status has changed. This can happen for periodic // updates of pod phase counts done in caller of this function. - err := cc.updateStatusInEtcdWithRetry(qj, "manageQueueJob - podPhaseChanges") + err := cc.updateStatusInEtcdWithRetry(ctx, qj, "manageQueueJob - podPhaseChanges") if err != nil { klog.Errorf("[manageQueueJob] Error updating status 'podPhaseChanges' AppWrapper: '%s/%s',Status=%+v, err=%+v.", qj.Namespace, qj.Name, qj.Status, err) return err @@ -2026,7 +2037,7 @@ func (cc *XController) manageQueueJob(qj *arbv1.AppWrapper, podPhaseChanges bool // if there are running resources for this job then delete them because the job was put in // pending state... klog.V(3).Infof("[manageQueueJob] [Dispatcher] Deleting AppWrapper resources because it will be preempted! %s", qj.Name) - err00 := cc.Cleanup(qj) + err00 := cc.Cleanup(ctx, qj) if err00 != nil { klog.Errorf("Failed to clean up resources for app wrapper '%s/%s', err =%v", qj.Namespace, qj.Name, err00) return err00 @@ -2039,7 +2050,7 @@ func (cc *XController) manageQueueJob(qj *arbv1.AppWrapper, podPhaseChanges bool klog.V(10).Infof("[manageQueueJob] [Dispatcher] before add to activeQ '%s/%s' activeQ=%t Unsched=%t &qj=%p Version=%s Status=%+v", qj.Namespace, qj.Name, cc.qjqueue.IfExistActiveQ(qj), cc.qjqueue.IfExistUnschedulableQ(qj), qj, qj.ResourceVersion, qj.Status) qj.Status.QueueJobState = arbv1.AppWrapperCondQueueing qj.Status.FilterIgnore = true // Update Queueing status, add to qjqueue for ScheduleNext - err := cc.updateStatusInEtcdWithRetry(qj, "manageQueueJob - setQueueing") + err := cc.updateStatusInEtcdWithRetry(ctx, qj, "manageQueueJob - setQueueing") if err != nil { klog.Errorf("[manageQueueJob] Error updating status 'setQueueing' for AppWrapper: '%s/%s',Status=%+v, err=%+v.", qj.Namespace, qj.Name, qj.Status, err) return err @@ -2069,7 +2080,7 @@ func (cc *XController) manageQueueJob(qj *arbv1.AppWrapper, podPhaseChanges bool queuejobKey, _ := GetQueueJobKey(qj) if agentId, ok := cc.dispatchMap[queuejobKey]; ok { klog.V(10).Infof("[manageQueueJob] [Dispatcher] Dispatched AppWrapper %s to Agent ID: %s.", qj.Name, agentId) - cc.agentMap[agentId].CreateJob(qj) + cc.agentMap[agentId].CreateJob(ctx, qj) qj.Status.IsDispatched = true } else { klog.Errorf("[manageQueueJob] [Dispatcher] AppWrapper %s not found in dispatcher mapping.", qj.Name) @@ -2079,7 +2090,7 @@ func (cc *XController) manageQueueJob(qj *arbv1.AppWrapper, podPhaseChanges bool klog.V(10).Infof("[manageQueueJob] [Dispatcher] XQJ %s has Overhead After Dispatching: %s", qj.Name, current_time.Sub(qj.CreationTimestamp.Time)) klog.V(10).Infof("[manageQueueJob] [Dispatcher] %s, %s: WorkerAfterDispatch", qj.Name, time.Now().Sub(qj.CreationTimestamp.Time)) } - err := cc.updateStatusInEtcdWithRetry(qj, "[manageQueueJob] [Dispatcher] -- set dispatched true") + err := cc.updateStatusInEtcdWithRetry(ctx, qj, "[manageQueueJob] [Dispatcher] -- set dispatched true") if err != nil { klog.Errorf("Failed to update status of AppWrapper %s/%s: err=%v", qj.Namespace, qj.Name, err) return err @@ -2090,7 +2101,7 @@ func (cc *XController) manageQueueJob(qj *arbv1.AppWrapper, podPhaseChanges bool } // Cleanup function -func (cc *XController) Cleanup(appwrapper *arbv1.AppWrapper) error { +func (cc *XController) Cleanup(ctx context.Context, appwrapper *arbv1.AppWrapper) error { klog.V(3).Infof("[Cleanup] begin AppWrapper '%s/%s' Version=%s", appwrapper.Namespace, appwrapper.Name, appwrapper.ResourceVersion) var err *multierror.Error if !cc.isDispatcher { @@ -2116,7 +2127,7 @@ func (cc *XController) Cleanup(appwrapper *arbv1.AppWrapper) error { if appwrapper.Status.IsDispatched { queuejobKey, _ := GetQueueJobKey(appwrapper) if obj, ok := cc.dispatchMap[queuejobKey]; ok { - cc.agentMap[obj].DeleteJob(appwrapper) + cc.agentMap[obj].DeleteJob(ctx, appwrapper) } appwrapper.Status.IsDispatched = false } @@ -2136,7 +2147,7 @@ func (cc *XController) Cleanup(appwrapper *arbv1.AppWrapper) error { } func (cc *XController) getAppWrapper(namespace string, name string, caller string) (*arbv1.AppWrapper, error) { klog.V(5).Infof("[getAppWrapper] getting a copy of '%s/%s' when called by '%s'.", namespace, name, caller) - apiCacheAWJob, err := cc.queueJobLister.AppWrappers(namespace).Get(name) + apiCacheAWJob, err := cc.appWrapperLister.AppWrappers(namespace).Get(name) if err != nil { if !apierrors.IsNotFound(err) { klog.Errorf("[getAppWrapper] getting a copy of '%s/%s' failed, when called by '%s', err=%v", namespace, name, caller, err) diff --git a/pkg/controller/queuejobdispatch/queuejobagent.go b/pkg/controller/queuejobdispatch/queuejobagent.go index 738db41b4..213d80bf5 100644 --- a/pkg/controller/queuejobdispatch/queuejobagent.go +++ b/pkg/controller/queuejobdispatch/queuejobagent.go @@ -25,7 +25,7 @@ import ( "time" arbv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" - clientset "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/controller-versioned" + clientset "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned" clusterstateapi "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/controller/clusterstate/api" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" @@ -40,7 +40,7 @@ import ( listersv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers/controller/v1" "k8s.io/client-go/tools/cache" - "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/controller-versioned/clients" + clients "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/controller-versioned/clients" _ "k8s.io/client-go/plugin/pkg/client/auth/oidc" ) @@ -67,7 +67,6 @@ func NewJobClusterAgent(config string, agentEventQueue *cache.FIFO) *JobClusterA klog.V(2).Infof("[Dispatcher: Agent] Creation: %s\n", "/root/kubernetes/"+configStrings[0]) agent_config, err := clientcmd.BuildConfigFromFlags("", "/root/kubernetes/"+configStrings[0]) - // agent_config, err:=clientcmd.BuildConfigFromFlags("", "/root/agent101config") if err != nil { klog.V(2).Infof("[Dispatcher: Agent] Cannot crate client\n") return nil @@ -119,7 +118,7 @@ func NewJobClusterAgent(config string, agentEventQueue *cache.FIFO) *JobClusterA qa.jobSynced = qa.jobInformer.Informer().HasSynced - qa.UpdateAggrResources() + qa.UpdateAggrResources(context.Background()) return qa } @@ -157,17 +156,16 @@ func (cc *JobClusterAgent) deleteQueueJob(obj interface{}) { func (qa *JobClusterAgent) Run(stopCh chan struct{}) { go qa.jobInformer.Informer().Run(stopCh) cache.WaitForCacheSync(stopCh, qa.jobSynced) - // go wait.Until(qa.UpdateAgent, 2*time.Second, stopCh) } -func (qa *JobClusterAgent) DeleteJob(cqj *arbv1.AppWrapper) { +func (qa *JobClusterAgent) DeleteJob(ctx context.Context, cqj *arbv1.AppWrapper) { qj_temp := cqj.DeepCopy() klog.V(2).Infof("[Dispatcher: Agent] Request deletion of XQJ %s to Agent %s\n", qj_temp.Name, qa.AgentId) - qa.queuejobclients.ArbV1().AppWrappers(qj_temp.Namespace).Delete(qj_temp.Name, &metav1.DeleteOptions{}) + qa.queuejobclients.McadV1beta1().AppWrappers(qj_temp.Namespace).Delete(ctx, qj_temp.Name, metav1.DeleteOptions{}) return } -func (qa *JobClusterAgent) CreateJob(cqj *arbv1.AppWrapper) { +func (qa *JobClusterAgent) CreateJob(ctx context.Context, cqj *arbv1.AppWrapper) { qj_temp := cqj.DeepCopy() agent_qj := &arbv1.AppWrapper{ TypeMeta: qj_temp.TypeMeta, @@ -185,19 +183,8 @@ func (qa *JobClusterAgent) CreateJob(cqj *arbv1.AppWrapper) { } agent_qj.Labels["IsDispatched"] = "true" - // klog.Infof("[Agent] XQJ resourceVersion cleaned--Name:%s, Kind:%s\n", agent_qj.Name, agent_qj.Kind) klog.V(2).Infof("[Dispatcher: Agent] Create XQJ: %s (Status: %+v) in Agent %s\n", agent_qj.Name, agent_qj.Status, qa.AgentId) - qa.queuejobclients.ArbV1().AppWrappers(agent_qj.Namespace).Create(agent_qj) - // pods, err := qa.deploymentclients.CoreV1().Pods("").List(metav1.ListOptions{}) - // if err != nil { - // klog.Infof("[Agent] Cannot Access Agent================\n") - // } - // klog.Infof("There are %d pods in the cluster\n", len(pods.Items)) - // // for _, pod := range pods.Items { - // klog.Infof("[Agent] Pod Name=%s\n",pod.Name) - // } - - return + qa.queuejobclients.McadV1beta1().AppWrappers(agent_qj.Namespace).Create(ctx, agent_qj, metav1.CreateOptions{}) } type ClusterMetricsList struct { @@ -214,7 +201,7 @@ type ClusterMetricsList struct { } `json:"items"` } -func (qa *JobClusterAgent) UpdateAggrResources() error { +func (qa *JobClusterAgent) UpdateAggrResources(ctx context.Context) error { klog.V(6).Infof("[Dispatcher: UpdateAggrResources] Getting aggregated resources for Agent ID: %s with Agent Name: %s\n", qa.AgentId, qa.DeploymentName) // Read the Agent XQJ Deployment object @@ -223,7 +210,7 @@ func (qa *JobClusterAgent) UpdateAggrResources() error { } - data, err := qa.k8sClients.RESTClient().Get().AbsPath("apis/external.metrics.k8s.io/v1beta1/namespaces/default/cluster-external-metric").DoRaw(context.Background()) + data, err := qa.k8sClients.RESTClient().Get().AbsPath("apis/external.metrics.k8s.io/v1beta1/namespaces/default/cluster-external-metric").DoRaw(ctx) if err != nil { klog.V(2).Infof("[Dispatcher: UpdateAggrResources] Failed to get metrics from deployment Agent ID: %s with Agent Name: %s, Error: %v\n", qa.AgentId, qa.DeploymentName, err) @@ -241,10 +228,10 @@ func (qa *JobClusterAgent) UpdateAggrResources() error { res.Items[i].MetricName, res.Items[i].MetricLabels, res.Items[i].Value, qa.AgentId, qa.DeploymentName) clusterMetricType := res.Items[i].MetricLabels["cluster"] - if strings.Compare(clusterMetricType, "cpu") == 0 || strings.Compare(clusterMetricType, "memory") == 0 { + if strings.Compare(clusterMetricType, "cpu") == 0 || strings.Compare(clusterMetricType, "memory") == 0 { val, units, _ := getFloatString(res.Items[i].Value) num, err := strconv.ParseFloat(val, 64) - if err !=nil { + if err != nil { klog.Warningf("[Dispatcher: UpdateAggrResources] Possible issue converting %s string value of %s due to error: %v\n", clusterMetricType, res.Items[i].Value, err) } else { @@ -269,8 +256,8 @@ func (qa *JobClusterAgent) UpdateAggrResources() error { } // Float value resulted in zero value. } // Converting string to float success } else if strings.Compare(clusterMetricType, "gpu") == 0 { - num, err := getInt64String(res.Items[i].Value) - if err !=nil { + num, err := getInt64String(res.Items[i].Value) + if err != nil { klog.Warningf("[Dispatcher: UpdateAggrResources] Possible issue converting %s string value of %s due to int64 type, error: %v\n", clusterMetricType, res.Items[i].Value, err) } else { @@ -309,7 +296,7 @@ func getFloatString(num string) (string, string, error) { } else { validatedNum = num } - return validatedNum, numUnits, err + return validatedNum, numUnits, err } func getInt64String(num string) (int64, error) { var validatedNum int64 = 0 @@ -317,7 +304,7 @@ func getInt64String(num string) (int64, error) { if err == nil { validatedNum = n } - return validatedNum, err + return validatedNum, err } func buildResource(cpu string, memory string) *clusterstateapi.Resource { diff --git a/pkg/controller/quota/quotaforestmanager/qm_lib_backend_with_quotasubt_mgr.go b/pkg/controller/quota/quotaforestmanager/qm_lib_backend_with_quotasubt_mgr.go index 7a4bfa5b9..c691fd577 100644 --- a/pkg/controller/quota/quotaforestmanager/qm_lib_backend_with_quotasubt_mgr.go +++ b/pkg/controller/quota/quotaforestmanager/qm_lib_backend_with_quotasubt_mgr.go @@ -25,7 +25,7 @@ import ( "github.com/hashicorp/go-multierror" "github.com/project-codeflare/multi-cluster-app-dispatcher/cmd/kar-controllers/app/options" arbv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" - listersv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers/controller/v1" + listersv1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers/controller/v1beta1" clusterstateapi "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/controller/clusterstate/api" "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/controller/quota" qstmanager "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/controller/quota/quotaforestmanager/qm_lib_backend_with_quotasubt_mgr/quotasubtmgr" @@ -56,7 +56,7 @@ const ( // QuotaManager implements a QuotaManagerInterface. type QuotaManager struct { url string - appwrapperLister listersv1.AppWrapperLister + appwrapperLister listersv1beta1.AppWrapperLister preemptionEnabled bool quotaManagerBackend *qmbackend.Manager quotaSubtreeManager *qstmanager.QuotaSubtreeManager @@ -108,7 +108,7 @@ func getDispatchedAppWrapper(dispatchedAWs map[string]*arbv1.AppWrapper, awId st } func NewQuotaManager(dispatchedAWDemands map[string]*clusterstateapi.Resource, dispatchedAWs map[string]*arbv1.AppWrapper, - awJobLister listersv1.AppWrapperLister, config *rest.Config, serverOptions *options.ServerOption) (*QuotaManager, error) { + awJobLister listersv1beta1.AppWrapperLister, config *rest.Config, serverOptions *options.ServerOption) (*QuotaManager, error) { var err error From 0a3b9ce79f419791fcab296b533154c1f411c5c7 Mon Sep 17 00:00:00 2001 From: Laurentiu Bradin <109964136+z103cb@users.noreply.github.com> Date: Tue, 1 Aug 2023 17:09:06 +0300 Subject: [PATCH 3/5] Added quota management package to the generation --- Makefile | 8 +- pkg/client/clientset/versioned/clientset.go | 14 ++ .../versioned/fake/clientset_generated.go | 7 + .../clientset/versioned/fake/register.go | 2 + .../clientset/versioned/scheme/register.go | 2 + .../versioned/typed/quotasubtree/v1/doc.go | 20 ++ .../typed/quotasubtree/v1/fake/doc.go | 20 ++ .../quotasubtree/v1/fake/fake_quotasubtree.go | 142 +++++++++++++ .../v1/fake/fake_quotasubtree_client.go | 40 ++++ .../quotasubtree/v1/generated_expansion.go | 21 ++ .../typed/quotasubtree/v1/quotasubtree.go | 195 ++++++++++++++++++ .../quotasubtree/v1/quotasubtree_client.go | 89 ++++++++ .../informers/externalversions/factory.go | 6 + .../informers/externalversions/generic.go | 7 +- .../quotasubtree/interface.go | 46 +++++ .../quotasubtree/v1/interface.go | 45 ++++ .../quotasubtree/v1/quotasubtree.go | 90 ++++++++ .../quotasubtree/v1/expansion_generated.go | 27 +++ .../listers/quotasubtree/v1/quotasubtree.go | 99 +++++++++ .../quotasubtree/clientset/versioned/doc.go | 4 + .../versioned/typed/quotasubtree/v1/doc.go | 4 + pkg/client/quotasubtree/doc.go | 5 + .../informers/externalversions/doc.go | 24 +++ .../externalversions/quotasubtree/v1/doc.go | 24 +++ .../listers/quotasubtree/v1/doc.go | 24 +++ .../metrics/adapter/provider/provider.go | 4 +- .../metrics/test-adapter/provider/provider.go | 2 +- .../queuejob/queuejob_controller_ex.go | 3 - .../quotasubtmgr/quota_subtree_manager.go | 16 +- 29 files changed, 973 insertions(+), 17 deletions(-) create mode 100644 pkg/client/clientset/versioned/typed/quotasubtree/v1/doc.go create mode 100644 pkg/client/clientset/versioned/typed/quotasubtree/v1/fake/doc.go create mode 100644 pkg/client/clientset/versioned/typed/quotasubtree/v1/fake/fake_quotasubtree.go create mode 100644 pkg/client/clientset/versioned/typed/quotasubtree/v1/fake/fake_quotasubtree_client.go create mode 100644 pkg/client/clientset/versioned/typed/quotasubtree/v1/generated_expansion.go create mode 100644 pkg/client/clientset/versioned/typed/quotasubtree/v1/quotasubtree.go create mode 100644 pkg/client/clientset/versioned/typed/quotasubtree/v1/quotasubtree_client.go create mode 100644 pkg/client/informers/externalversions/quotasubtree/interface.go create mode 100644 pkg/client/informers/externalversions/quotasubtree/v1/interface.go create mode 100644 pkg/client/informers/externalversions/quotasubtree/v1/quotasubtree.go create mode 100644 pkg/client/listers/quotasubtree/v1/expansion_generated.go create mode 100644 pkg/client/listers/quotasubtree/v1/quotasubtree.go create mode 100644 pkg/client/quotasubtree/doc.go create mode 100755 pkg/client/quotasubtree/informers/externalversions/doc.go create mode 100755 pkg/client/quotasubtree/informers/externalversions/quotasubtree/v1/doc.go create mode 100755 pkg/client/quotasubtree/listers/quotasubtree/v1/doc.go diff --git a/Makefile b/Makefile index 489eeb2db..f99f35078 100644 --- a/Makefile +++ b/Makefile @@ -77,7 +77,7 @@ verify-tag-name: print-global-variables t=${TAG} && [ $${#t} -le 128 ] || { echo "Target name $$t has 128 or more chars"; false; } .PHONY: generate-client ## Generate client packages generate-client: code-generator - rm -rf pkg/client/clientset/versioned pkg/client/informers/externalversions pkg/client/listers/controller/v1beta1 + rm -rf pkg/client/clientset/versioned pkg/client/informers/externalversions pkg/client/listers/controller/v1beta1 pkg/client/listers/quotasubtree/v1 # TODO: add this back when the version of the tool has been updated and supports this executable # $(APPLYCONFIGURATION_GEN) \ # --input-dirs="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" \ @@ -86,6 +86,7 @@ generate-client: code-generator # --trim-path-prefix "github.com/project-codeflare/multi-cluster-app-dispatcher" $(CLIENT_GEN) \ --input="pkg/apis/controller/v1beta1" \ + --input="pkg/apis/quotaplugins/quotasubtree/v1" \ --input-base="github.com/project-codeflare/multi-cluster-app-dispatcher" \ --go-header-file="hack/boilerplate/boilerplate.go.txt" \ --clientset-name "versioned" \ @@ -95,6 +96,7 @@ generate-client: code-generator # --trim-path-prefix "github.com/project-codeflare/multi-cluster-app-dispatcher" $(LISTER_GEN) \ --input-dirs="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" \ + --input-dirs="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/quotaplugins/quotasubtree/v1" \ --go-header-file="hack/boilerplate/boilerplate.go.txt" \ --output-base="." \ --output-package="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers" @@ -102,6 +104,7 @@ generate-client: code-generator # --trim-path-prefix "github.com/project-codeflare/multi-cluster-app-dispatcher" $(INFORMER_GEN) \ --input-dirs="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" \ + --input-dirs="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/quotaplugins/quotasubtree/v1" \ --versioned-clientset-package="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned" \ --listers-package="github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers" \ --go-header-file="hack/boilerplate/boilerplate.go.txt" \ @@ -114,7 +117,8 @@ generate-client: code-generator mv -f github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned pkg/client/clientset/versioned mv -f github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/externalversions pkg/client/informers/externalversions mv -f github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers/controller/v1beta1 pkg/client/listers/controller/v1beta1 - rm -rf github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client + mv -f github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers/quotasubtree/v1 pkg/client/listers/quotasubtree/v1 + rm -rf github.com .PHONY: controller-gen controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go index 2cb2c8f7c..e79521648 100644 --- a/pkg/client/clientset/versioned/clientset.go +++ b/pkg/client/clientset/versioned/clientset.go @@ -22,6 +22,7 @@ import ( "fmt" mcadv1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned/typed/controller/v1beta1" + ibmv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned/typed/quotasubtree/v1" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" @@ -30,6 +31,7 @@ import ( type Interface interface { Discovery() discovery.DiscoveryInterface McadV1beta1() mcadv1beta1.McadV1beta1Interface + IbmV1() ibmv1.IbmV1Interface } // Clientset contains the clients for groups. Each group has exactly one @@ -37,6 +39,7 @@ type Interface interface { type Clientset struct { *discovery.DiscoveryClient mcadV1beta1 *mcadv1beta1.McadV1beta1Client + ibmV1 *ibmv1.IbmV1Client } // McadV1beta1 retrieves the McadV1beta1Client @@ -44,6 +47,11 @@ func (c *Clientset) McadV1beta1() mcadv1beta1.McadV1beta1Interface { return c.mcadV1beta1 } +// IbmV1 retrieves the IbmV1Client +func (c *Clientset) IbmV1() ibmv1.IbmV1Interface { + return c.ibmV1 +} + // Discovery retrieves the DiscoveryClient func (c *Clientset) Discovery() discovery.DiscoveryInterface { if c == nil { @@ -69,6 +77,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { if err != nil { return nil, err } + cs.ibmV1, err = ibmv1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) if err != nil { @@ -82,6 +94,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { func NewForConfigOrDie(c *rest.Config) *Clientset { var cs Clientset cs.mcadV1beta1 = mcadv1beta1.NewForConfigOrDie(c) + cs.ibmV1 = ibmv1.NewForConfigOrDie(c) cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) return &cs @@ -91,6 +104,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { func New(c rest.Interface) *Clientset { var cs Clientset cs.mcadV1beta1 = mcadv1beta1.New(c) + cs.ibmV1 = ibmv1.New(c) cs.DiscoveryClient = discovery.NewDiscoveryClient(c) return &cs diff --git a/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go index 2a0217675..53b34208e 100644 --- a/pkg/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -22,6 +22,8 @@ import ( clientset "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned" mcadv1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned/typed/controller/v1beta1" fakemcadv1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned/typed/controller/v1beta1/fake" + ibmv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned/typed/quotasubtree/v1" + fakeibmv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned/typed/quotasubtree/v1/fake" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/discovery" @@ -80,3 +82,8 @@ var _ clientset.Interface = &Clientset{} func (c *Clientset) McadV1beta1() mcadv1beta1.McadV1beta1Interface { return &fakemcadv1beta1.FakeMcadV1beta1{Fake: &c.Fake} } + +// IbmV1 retrieves the IbmV1Client +func (c *Clientset) IbmV1() ibmv1.IbmV1Interface { + return &fakeibmv1.FakeIbmV1{Fake: &c.Fake} +} diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go index ea2269452..ca0dbd64c 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -20,6 +20,7 @@ package fake import ( mcadv1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" + ibmv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/quotaplugins/quotasubtree/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -32,6 +33,7 @@ var codecs = serializer.NewCodecFactory(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ mcadv1beta1.AddToScheme, + ibmv1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index 598c25cc7..b2cd44f80 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -20,6 +20,7 @@ package scheme import ( mcadv1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" + ibmv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/quotaplugins/quotasubtree/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -32,6 +33,7 @@ var Codecs = serializer.NewCodecFactory(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ mcadv1beta1.AddToScheme, + ibmv1.AddToScheme, } // AddToScheme adds all types of this clientset into the given scheme. This allows composition diff --git a/pkg/client/clientset/versioned/typed/quotasubtree/v1/doc.go b/pkg/client/clientset/versioned/typed/quotasubtree/v1/doc.go new file mode 100644 index 000000000..d75026c76 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/quotasubtree/v1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1 diff --git a/pkg/client/clientset/versioned/typed/quotasubtree/v1/fake/doc.go b/pkg/client/clientset/versioned/typed/quotasubtree/v1/fake/doc.go new file mode 100644 index 000000000..8804eb10a --- /dev/null +++ b/pkg/client/clientset/versioned/typed/quotasubtree/v1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/pkg/client/clientset/versioned/typed/quotasubtree/v1/fake/fake_quotasubtree.go b/pkg/client/clientset/versioned/typed/quotasubtree/v1/fake/fake_quotasubtree.go new file mode 100644 index 000000000..0b5341ce9 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/quotasubtree/v1/fake/fake_quotasubtree.go @@ -0,0 +1,142 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + quotasubtreev1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/quotaplugins/quotasubtree/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeQuotaSubtrees implements QuotaSubtreeInterface +type FakeQuotaSubtrees struct { + Fake *FakeIbmV1 + ns string +} + +var quotasubtreesResource = schema.GroupVersionResource{Group: "ibm.com", Version: "v1", Resource: "quotasubtrees"} + +var quotasubtreesKind = schema.GroupVersionKind{Group: "ibm.com", Version: "v1", Kind: "QuotaSubtree"} + +// Get takes name of the quotaSubtree, and returns the corresponding quotaSubtree object, and an error if there is any. +func (c *FakeQuotaSubtrees) Get(ctx context.Context, name string, options v1.GetOptions) (result *quotasubtreev1.QuotaSubtree, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(quotasubtreesResource, c.ns, name), "asubtreev1.QuotaSubtree{}) + + if obj == nil { + return nil, err + } + return obj.(*quotasubtreev1.QuotaSubtree), err +} + +// List takes label and field selectors, and returns the list of QuotaSubtrees that match those selectors. +func (c *FakeQuotaSubtrees) List(ctx context.Context, opts v1.ListOptions) (result *quotasubtreev1.QuotaSubtreeList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(quotasubtreesResource, quotasubtreesKind, c.ns, opts), "asubtreev1.QuotaSubtreeList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := "asubtreev1.QuotaSubtreeList{ListMeta: obj.(*quotasubtreev1.QuotaSubtreeList).ListMeta} + for _, item := range obj.(*quotasubtreev1.QuotaSubtreeList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested quotaSubtrees. +func (c *FakeQuotaSubtrees) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(quotasubtreesResource, c.ns, opts)) + +} + +// Create takes the representation of a quotaSubtree and creates it. Returns the server's representation of the quotaSubtree, and an error, if there is any. +func (c *FakeQuotaSubtrees) Create(ctx context.Context, quotaSubtree *quotasubtreev1.QuotaSubtree, opts v1.CreateOptions) (result *quotasubtreev1.QuotaSubtree, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(quotasubtreesResource, c.ns, quotaSubtree), "asubtreev1.QuotaSubtree{}) + + if obj == nil { + return nil, err + } + return obj.(*quotasubtreev1.QuotaSubtree), err +} + +// Update takes the representation of a quotaSubtree and updates it. Returns the server's representation of the quotaSubtree, and an error, if there is any. +func (c *FakeQuotaSubtrees) Update(ctx context.Context, quotaSubtree *quotasubtreev1.QuotaSubtree, opts v1.UpdateOptions) (result *quotasubtreev1.QuotaSubtree, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(quotasubtreesResource, c.ns, quotaSubtree), "asubtreev1.QuotaSubtree{}) + + if obj == nil { + return nil, err + } + return obj.(*quotasubtreev1.QuotaSubtree), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeQuotaSubtrees) UpdateStatus(ctx context.Context, quotaSubtree *quotasubtreev1.QuotaSubtree, opts v1.UpdateOptions) (*quotasubtreev1.QuotaSubtree, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(quotasubtreesResource, "status", c.ns, quotaSubtree), "asubtreev1.QuotaSubtree{}) + + if obj == nil { + return nil, err + } + return obj.(*quotasubtreev1.QuotaSubtree), err +} + +// Delete takes name of the quotaSubtree and deletes it. Returns an error if one occurs. +func (c *FakeQuotaSubtrees) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(quotasubtreesResource, c.ns, name), "asubtreev1.QuotaSubtree{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeQuotaSubtrees) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(quotasubtreesResource, c.ns, listOpts) + + _, err := c.Fake.Invokes(action, "asubtreev1.QuotaSubtreeList{}) + return err +} + +// Patch applies the patch and returns the patched quotaSubtree. +func (c *FakeQuotaSubtrees) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *quotasubtreev1.QuotaSubtree, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(quotasubtreesResource, c.ns, name, pt, data, subresources...), "asubtreev1.QuotaSubtree{}) + + if obj == nil { + return nil, err + } + return obj.(*quotasubtreev1.QuotaSubtree), err +} diff --git a/pkg/client/clientset/versioned/typed/quotasubtree/v1/fake/fake_quotasubtree_client.go b/pkg/client/clientset/versioned/typed/quotasubtree/v1/fake/fake_quotasubtree_client.go new file mode 100644 index 000000000..9046c1b1d --- /dev/null +++ b/pkg/client/clientset/versioned/typed/quotasubtree/v1/fake/fake_quotasubtree_client.go @@ -0,0 +1,40 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned/typed/quotasubtree/v1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeIbmV1 struct { + *testing.Fake +} + +func (c *FakeIbmV1) QuotaSubtrees(namespace string) v1.QuotaSubtreeInterface { + return &FakeQuotaSubtrees{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeIbmV1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/client/clientset/versioned/typed/quotasubtree/v1/generated_expansion.go b/pkg/client/clientset/versioned/typed/quotasubtree/v1/generated_expansion.go new file mode 100644 index 000000000..1f4a9cd17 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/quotasubtree/v1/generated_expansion.go @@ -0,0 +1,21 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1 + +type QuotaSubtreeExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/quotasubtree/v1/quotasubtree.go b/pkg/client/clientset/versioned/typed/quotasubtree/v1/quotasubtree.go new file mode 100644 index 000000000..8c194d63f --- /dev/null +++ b/pkg/client/clientset/versioned/typed/quotasubtree/v1/quotasubtree.go @@ -0,0 +1,195 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1 + +import ( + "context" + "time" + + v1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/quotaplugins/quotasubtree/v1" + scheme "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned/scheme" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// QuotaSubtreesGetter has a method to return a QuotaSubtreeInterface. +// A group's client should implement this interface. +type QuotaSubtreesGetter interface { + QuotaSubtrees(namespace string) QuotaSubtreeInterface +} + +// QuotaSubtreeInterface has methods to work with QuotaSubtree resources. +type QuotaSubtreeInterface interface { + Create(ctx context.Context, quotaSubtree *v1.QuotaSubtree, opts metav1.CreateOptions) (*v1.QuotaSubtree, error) + Update(ctx context.Context, quotaSubtree *v1.QuotaSubtree, opts metav1.UpdateOptions) (*v1.QuotaSubtree, error) + UpdateStatus(ctx context.Context, quotaSubtree *v1.QuotaSubtree, opts metav1.UpdateOptions) (*v1.QuotaSubtree, error) + Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error + Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.QuotaSubtree, error) + List(ctx context.Context, opts metav1.ListOptions) (*v1.QuotaSubtreeList, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.QuotaSubtree, err error) + QuotaSubtreeExpansion +} + +// quotaSubtrees implements QuotaSubtreeInterface +type quotaSubtrees struct { + client rest.Interface + ns string +} + +// newQuotaSubtrees returns a QuotaSubtrees +func newQuotaSubtrees(c *IbmV1Client, namespace string) *quotaSubtrees { + return "aSubtrees{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the quotaSubtree, and returns the corresponding quotaSubtree object, and an error if there is any. +func (c *quotaSubtrees) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.QuotaSubtree, err error) { + result = &v1.QuotaSubtree{} + err = c.client.Get(). + Namespace(c.ns). + Resource("quotasubtrees"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of QuotaSubtrees that match those selectors. +func (c *quotaSubtrees) List(ctx context.Context, opts metav1.ListOptions) (result *v1.QuotaSubtreeList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.QuotaSubtreeList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("quotasubtrees"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested quotaSubtrees. +func (c *quotaSubtrees) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("quotasubtrees"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a quotaSubtree and creates it. Returns the server's representation of the quotaSubtree, and an error, if there is any. +func (c *quotaSubtrees) Create(ctx context.Context, quotaSubtree *v1.QuotaSubtree, opts metav1.CreateOptions) (result *v1.QuotaSubtree, err error) { + result = &v1.QuotaSubtree{} + err = c.client.Post(). + Namespace(c.ns). + Resource("quotasubtrees"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(quotaSubtree). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a quotaSubtree and updates it. Returns the server's representation of the quotaSubtree, and an error, if there is any. +func (c *quotaSubtrees) Update(ctx context.Context, quotaSubtree *v1.QuotaSubtree, opts metav1.UpdateOptions) (result *v1.QuotaSubtree, err error) { + result = &v1.QuotaSubtree{} + err = c.client.Put(). + Namespace(c.ns). + Resource("quotasubtrees"). + Name(quotaSubtree.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(quotaSubtree). + Do(ctx). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *quotaSubtrees) UpdateStatus(ctx context.Context, quotaSubtree *v1.QuotaSubtree, opts metav1.UpdateOptions) (result *v1.QuotaSubtree, err error) { + result = &v1.QuotaSubtree{} + err = c.client.Put(). + Namespace(c.ns). + Resource("quotasubtrees"). + Name(quotaSubtree.Name). + SubResource("status"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(quotaSubtree). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the quotaSubtree and deletes it. Returns an error if one occurs. +func (c *quotaSubtrees) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("quotasubtrees"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *quotaSubtrees) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("quotasubtrees"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched quotaSubtree. +func (c *quotaSubtrees) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.QuotaSubtree, err error) { + result = &v1.QuotaSubtree{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("quotasubtrees"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/quotasubtree/v1/quotasubtree_client.go b/pkg/client/clientset/versioned/typed/quotasubtree/v1/quotasubtree_client.go new file mode 100644 index 000000000..91e98a3d6 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/quotasubtree/v1/quotasubtree_client.go @@ -0,0 +1,89 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1 + +import ( + v1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/quotaplugins/quotasubtree/v1" + "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type IbmV1Interface interface { + RESTClient() rest.Interface + QuotaSubtreesGetter +} + +// IbmV1Client is used to interact with features provided by the ibm.com group. +type IbmV1Client struct { + restClient rest.Interface +} + +func (c *IbmV1Client) QuotaSubtrees(namespace string) QuotaSubtreeInterface { + return newQuotaSubtrees(c, namespace) +} + +// NewForConfig creates a new IbmV1Client for the given config. +func NewForConfig(c *rest.Config) (*IbmV1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &IbmV1Client{client}, nil +} + +// NewForConfigOrDie creates a new IbmV1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *IbmV1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new IbmV1Client for the given RESTClient. +func New(c rest.Interface) *IbmV1Client { + return &IbmV1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *IbmV1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/client/informers/externalversions/factory.go b/pkg/client/informers/externalversions/factory.go index b38a52bdf..63513c4a5 100644 --- a/pkg/client/informers/externalversions/factory.go +++ b/pkg/client/informers/externalversions/factory.go @@ -26,6 +26,7 @@ import ( versioned "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned" controller "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/externalversions/controller" internalinterfaces "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/externalversions/internalinterfaces" + quotasubtree "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/externalversions/quotasubtree" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -173,8 +174,13 @@ type SharedInformerFactory interface { WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool Mcad() controller.Interface + Ibm() quotasubtree.Interface } func (f *sharedInformerFactory) Mcad() controller.Interface { return controller.New(f, f.namespace, f.tweakListOptions) } + +func (f *sharedInformerFactory) Ibm() quotasubtree.Interface { + return quotasubtree.New(f, f.namespace, f.tweakListOptions) +} diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index 7ccb5819e..2c3eef75f 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -22,6 +22,7 @@ import ( "fmt" v1beta1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" + v1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/quotaplugins/quotasubtree/v1" schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" ) @@ -52,7 +53,11 @@ func (f *genericInformer) Lister() cache.GenericLister { // TODO extend this to unknown resources with a client pool func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { - // Group=mcad.ibm.com, Version=v1beta1 + // Group=ibm.com, Version=v1 + case v1.SchemeGroupVersion.WithResource("quotasubtrees"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Ibm().V1().QuotaSubtrees().Informer()}, nil + + // Group=mcad.ibm.com, Version=v1beta1 case v1beta1.SchemeGroupVersion.WithResource("appwrappers"): return &genericInformer{resource: resource.GroupResource(), informer: f.Mcad().V1beta1().AppWrappers().Informer()}, nil diff --git a/pkg/client/informers/externalversions/quotasubtree/interface.go b/pkg/client/informers/externalversions/quotasubtree/interface.go new file mode 100644 index 000000000..f4b410a4d --- /dev/null +++ b/pkg/client/informers/externalversions/quotasubtree/interface.go @@ -0,0 +1,46 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package quotasubtree + +import ( + internalinterfaces "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/externalversions/internalinterfaces" + v1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/externalversions/quotasubtree/v1" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1 provides access to shared informers for resources in V1. + V1() v1.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1 returns a new v1.Interface. +func (g *group) V1() v1.Interface { + return v1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/client/informers/externalversions/quotasubtree/v1/interface.go b/pkg/client/informers/externalversions/quotasubtree/v1/interface.go new file mode 100644 index 000000000..8a7b6a348 --- /dev/null +++ b/pkg/client/informers/externalversions/quotasubtree/v1/interface.go @@ -0,0 +1,45 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1 + +import ( + internalinterfaces "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // QuotaSubtrees returns a QuotaSubtreeInformer. + QuotaSubtrees() QuotaSubtreeInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// QuotaSubtrees returns a QuotaSubtreeInformer. +func (v *version) QuotaSubtrees() QuotaSubtreeInformer { + return "aSubtreeInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/client/informers/externalversions/quotasubtree/v1/quotasubtree.go b/pkg/client/informers/externalversions/quotasubtree/v1/quotasubtree.go new file mode 100644 index 000000000..0b07f1130 --- /dev/null +++ b/pkg/client/informers/externalversions/quotasubtree/v1/quotasubtree.go @@ -0,0 +1,90 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1 + +import ( + "context" + time "time" + + quotasubtreev1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/quotaplugins/quotasubtree/v1" + versioned "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned" + internalinterfaces "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/externalversions/internalinterfaces" + v1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers/quotasubtree/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// QuotaSubtreeInformer provides access to a shared informer and lister for +// QuotaSubtrees. +type QuotaSubtreeInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1.QuotaSubtreeLister +} + +type quotaSubtreeInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewQuotaSubtreeInformer constructs a new informer for QuotaSubtree type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewQuotaSubtreeInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredQuotaSubtreeInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredQuotaSubtreeInformer constructs a new informer for QuotaSubtree type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredQuotaSubtreeInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.IbmV1().QuotaSubtrees(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.IbmV1().QuotaSubtrees(namespace).Watch(context.TODO(), options) + }, + }, + "asubtreev1.QuotaSubtree{}, + resyncPeriod, + indexers, + ) +} + +func (f *quotaSubtreeInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredQuotaSubtreeInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *quotaSubtreeInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor("asubtreev1.QuotaSubtree{}, f.defaultInformer) +} + +func (f *quotaSubtreeInformer) Lister() v1.QuotaSubtreeLister { + return v1.NewQuotaSubtreeLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/listers/quotasubtree/v1/expansion_generated.go b/pkg/client/listers/quotasubtree/v1/expansion_generated.go new file mode 100644 index 000000000..f11df5b17 --- /dev/null +++ b/pkg/client/listers/quotasubtree/v1/expansion_generated.go @@ -0,0 +1,27 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1 + +// QuotaSubtreeListerExpansion allows custom methods to be added to +// QuotaSubtreeLister. +type QuotaSubtreeListerExpansion interface{} + +// QuotaSubtreeNamespaceListerExpansion allows custom methods to be added to +// QuotaSubtreeNamespaceLister. +type QuotaSubtreeNamespaceListerExpansion interface{} diff --git a/pkg/client/listers/quotasubtree/v1/quotasubtree.go b/pkg/client/listers/quotasubtree/v1/quotasubtree.go new file mode 100644 index 000000000..1b3173057 --- /dev/null +++ b/pkg/client/listers/quotasubtree/v1/quotasubtree.go @@ -0,0 +1,99 @@ +/* +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1 + +import ( + v1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/quotaplugins/quotasubtree/v1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" +) + +// QuotaSubtreeLister helps list QuotaSubtrees. +// All objects returned here must be treated as read-only. +type QuotaSubtreeLister interface { + // List lists all QuotaSubtrees in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1.QuotaSubtree, err error) + // QuotaSubtrees returns an object that can list and get QuotaSubtrees. + QuotaSubtrees(namespace string) QuotaSubtreeNamespaceLister + QuotaSubtreeListerExpansion +} + +// quotaSubtreeLister implements the QuotaSubtreeLister interface. +type quotaSubtreeLister struct { + indexer cache.Indexer +} + +// NewQuotaSubtreeLister returns a new QuotaSubtreeLister. +func NewQuotaSubtreeLister(indexer cache.Indexer) QuotaSubtreeLister { + return "aSubtreeLister{indexer: indexer} +} + +// List lists all QuotaSubtrees in the indexer. +func (s *quotaSubtreeLister) List(selector labels.Selector) (ret []*v1.QuotaSubtree, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1.QuotaSubtree)) + }) + return ret, err +} + +// QuotaSubtrees returns an object that can list and get QuotaSubtrees. +func (s *quotaSubtreeLister) QuotaSubtrees(namespace string) QuotaSubtreeNamespaceLister { + return quotaSubtreeNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// QuotaSubtreeNamespaceLister helps list and get QuotaSubtrees. +// All objects returned here must be treated as read-only. +type QuotaSubtreeNamespaceLister interface { + // List lists all QuotaSubtrees in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1.QuotaSubtree, err error) + // Get retrieves the QuotaSubtree from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1.QuotaSubtree, error) + QuotaSubtreeNamespaceListerExpansion +} + +// quotaSubtreeNamespaceLister implements the QuotaSubtreeNamespaceLister +// interface. +type quotaSubtreeNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all QuotaSubtrees in the indexer for a given namespace. +func (s quotaSubtreeNamespaceLister) List(selector labels.Selector) (ret []*v1.QuotaSubtree, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1.QuotaSubtree)) + }) + return ret, err +} + +// Get retrieves the QuotaSubtree from the indexer for a given namespace and name. +func (s quotaSubtreeNamespaceLister) Get(name string) (*v1.QuotaSubtree, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1.Resource("quotasubtree"), name) + } + return obj.(*v1.QuotaSubtree), nil +} diff --git a/pkg/client/quotasubtree/clientset/versioned/doc.go b/pkg/client/quotasubtree/clientset/versioned/doc.go index 41721ca52..f762c527b 100755 --- a/pkg/client/quotasubtree/clientset/versioned/doc.go +++ b/pkg/client/quotasubtree/clientset/versioned/doc.go @@ -13,6 +13,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +// Deprecated: quotasubtree has been replaced by the versioned as that package is generated using the client gen tool. +// quotasubtree interfaces and methods should not be used except for compatibility. It will be removed in future versions. +// +// This package is frozen and no new functionality will be added. // Code generated by client-gen. DO NOT EDIT. diff --git a/pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/doc.go b/pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/doc.go index 3af5d054f..09c6457f1 100755 --- a/pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/doc.go +++ b/pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/doc.go @@ -13,6 +13,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +// Deprecated: quotasubtree has been replaced by the versioned as that package is generated using the client gen tool. +// quotasubtree interfaces and methods should not be used except for compatibility. It will be removed in future versions. +// +// This package is frozen and no new functionality will be added. // Code generated by client-gen. DO NOT EDIT. diff --git a/pkg/client/quotasubtree/doc.go b/pkg/client/quotasubtree/doc.go new file mode 100644 index 000000000..6d75274f6 --- /dev/null +++ b/pkg/client/quotasubtree/doc.go @@ -0,0 +1,5 @@ +// Deprecated: quotasubtree has been replaced by the versioned as that package is generated using the client gen tool. +// quotasubtree interfaces and methods should not be used except for compatibility. It will be removed in future versions. +// +// This package is frozen and no new functionality will be added. +package quotasubtree diff --git a/pkg/client/quotasubtree/informers/externalversions/doc.go b/pkg/client/quotasubtree/informers/externalversions/doc.go new file mode 100755 index 000000000..d083a818a --- /dev/null +++ b/pkg/client/quotasubtree/informers/externalversions/doc.go @@ -0,0 +1,24 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Deprecated: quotasubtree has been replaced by the versioned as that package is generated using the client gen tool. +// quotasubtree interfaces and methods should not be used except for compatibility. It will be removed in future versions. +// +// This package is frozen and no new functionality will be added. + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package externalversions diff --git a/pkg/client/quotasubtree/informers/externalversions/quotasubtree/v1/doc.go b/pkg/client/quotasubtree/informers/externalversions/quotasubtree/v1/doc.go new file mode 100755 index 000000000..09c6457f1 --- /dev/null +++ b/pkg/client/quotasubtree/informers/externalversions/quotasubtree/v1/doc.go @@ -0,0 +1,24 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Deprecated: quotasubtree has been replaced by the versioned as that package is generated using the client gen tool. +// quotasubtree interfaces and methods should not be used except for compatibility. It will be removed in future versions. +// +// This package is frozen and no new functionality will be added. + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1 diff --git a/pkg/client/quotasubtree/listers/quotasubtree/v1/doc.go b/pkg/client/quotasubtree/listers/quotasubtree/v1/doc.go new file mode 100755 index 000000000..09c6457f1 --- /dev/null +++ b/pkg/client/quotasubtree/listers/quotasubtree/v1/doc.go @@ -0,0 +1,24 @@ +/* +Copyright The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Deprecated: quotasubtree has been replaced by the versioned as that package is generated using the client gen tool. +// quotasubtree interfaces and methods should not be used except for compatibility. It will be removed in future versions. +// +// This package is frozen and no new functionality will be added. + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1 diff --git a/pkg/controller/metrics/adapter/provider/provider.go b/pkg/controller/metrics/adapter/provider/provider.go index 6909471b3..fb3d33d4c 100644 --- a/pkg/controller/metrics/adapter/provider/provider.go +++ b/pkg/controller/metrics/adapter/provider/provider.go @@ -50,9 +50,9 @@ import ( "k8s.io/metrics/pkg/apis/custom_metrics" "k8s.io/metrics/pkg/apis/external_metrics" - clusterstatecache "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/controller/clusterstate/cache" "github.com/kubernetes-sigs/custom-metrics-apiserver/pkg/provider" "github.com/kubernetes-sigs/custom-metrics-apiserver/pkg/provider/helpers" + clusterstatecache "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/controller/clusterstate/cache" ) // CustomMetricResource wraps provider.CustomMetricInfo in a struct which stores the Name and Namespace of the resource @@ -271,7 +271,7 @@ func (p *clusterMetricsProvider) metricFor(value resource.Quantity, name types.N Metric: custom_metrics.MetricIdentifier{ Name: info.Metric, }, - Timestamp: metav1.Time{time.Now()}, + Timestamp: metav1.Time{Time: time.Now()}, Value: value, } diff --git a/pkg/controller/metrics/test-adapter/provider/provider.go b/pkg/controller/metrics/test-adapter/provider/provider.go index ace37df83..bb27ecb4c 100644 --- a/pkg/controller/metrics/test-adapter/provider/provider.go +++ b/pkg/controller/metrics/test-adapter/provider/provider.go @@ -252,7 +252,7 @@ func (p *testingProvider) metricFor(value resource.Quantity, name types.Namespac Metric: custom_metrics.MetricIdentifier{ Name: info.Metric, }, - Timestamp: metav1.Time{time.Now()}, + Timestamp: metav1.Time{Time: time.Now()}, Value: value, } diff --git a/pkg/controller/queuejob/queuejob_controller_ex.go b/pkg/controller/queuejob/queuejob_controller_ex.go index 03639ef57..6ffbfb220 100644 --- a/pkg/controller/queuejob/queuejob_controller_ex.go +++ b/pkg/controller/queuejob/queuejob_controller_ex.go @@ -63,12 +63,9 @@ import ( arbv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" clientset "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned" - // arbinformers "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/controller-externalversion" informerFactory "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/externalversions" arbinformers "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/externalversions/controller/v1beta1" - // informersv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/controller-externalversion/v1" - // listersv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers/controller/v1" arblisters "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers/controller/v1beta1" "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/controller/queuejobdispatch" diff --git a/pkg/controller/quota/quotaforestmanager/qm_lib_backend_with_quotasubt_mgr/quotasubtmgr/quota_subtree_manager.go b/pkg/controller/quota/quotaforestmanager/qm_lib_backend_with_quotasubt_mgr/quotasubtmgr/quota_subtree_manager.go index 752541716..fb859ff2e 100644 --- a/pkg/controller/quota/quotaforestmanager/qm_lib_backend_with_quotasubt_mgr/quotasubtmgr/quota_subtree_manager.go +++ b/pkg/controller/quota/quotaforestmanager/qm_lib_backend_with_quotasubt_mgr/quotasubtmgr/quota_subtree_manager.go @@ -33,11 +33,11 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/tools/cache" - qst "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/quotasubtree/clientset/versioned" + qst "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned" "k8s.io/client-go/rest" - qstinformer "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/quotasubtree/informers/externalversions" - qstinformers "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/quotasubtree/informers/externalversions/quotasubtree/v1" + qstinformers "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/externalversions" + qstinformer "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/externalversions/quotasubtree/v1" ) // New returns a new implementation. @@ -49,7 +49,7 @@ type QuotaSubtreeManager struct { quotaManagerBackend *qmlib.Manager /* Information about Quota Subtrees */ - quotaSubtreeInformer qstinformers.QuotaSubtreeInformer + quotaSubtreeInformer qstinformer.QuotaSubtreeInformer qstMutex sync.RWMutex qstMap map[string]*qstv1.QuotaSubtree @@ -64,16 +64,16 @@ func newQuotaSubtreeManager(config *rest.Config, quotaManagerBackend *qmlib.Mana qstChanged: true, } // QuotaSubtree informer setup - qstClient, err := qst.NewForConfigOrDie(config) + qstClient, err := qst.NewForConfig(config) if err != nil { return nil, err } - qstInformerFactory := qstinformer.NewSharedInformerFactoryWithOptions(qstClient, 0, - qstinformer.WithTweakListOptions(func(opt *metav1.ListOptions) { + qstInformerFactory := qstinformers.NewSharedInformerFactoryWithOptions(qstClient, 0, + qstinformers.WithTweakListOptions(func(opt *metav1.ListOptions) { opt.LabelSelector = util.URMTreeLabel })) - qstm.quotaSubtreeInformer = qstInformerFactory.Quotasubtree().V1().QuotaSubtrees() + qstm.quotaSubtreeInformer = qstInformerFactory.Ibm().V1().QuotaSubtrees() // Add event handle for resource plans qstm.quotaSubtreeInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ From 87bb27ca5b443eaa3a3c379021ce083901d8e0a9 Mon Sep 17 00:00:00 2001 From: Laurentiu Bradin <109964136+z103cb@users.noreply.github.com> Date: Wed, 2 Aug 2023 11:10:11 +0300 Subject: [PATCH 4/5] Removed previously obsoleted code Minor cleanups. --- .../controller-versioned/clients/factory.go | 59 ------ .../controller-versioned/clients/queuejob.go | 101 --------- .../clients/schedulingspec.go | 101 --------- .../controller-versioned/clientset.go | 80 ------- .../clientset/controller-versioned/doc.go | 7 - .../controller-versioned/scheme/register.go | 67 ------ .../typed/v1/appwrapper.go | 145 ------------- .../controller-versioned/typed/v1/client.go | 114 ---------- .../controller-versioned/typed/v1/queuejob.go | 145 ------------- .../typed/v1/schedulingspec.go | 145 ------------- .../controller-externalversion/doc.go | 7 - .../controller-externalversion/factory.go | 177 ---------------- .../controller-externalversion/generic.go | 82 -------- .../internalinterfaces/doc.go | 5 - .../internalinterfaces/factory_interfaces.go | 37 ---- .../v1/appwrapper.go | 103 --------- .../controller-externalversion/v1/doc.go | 7 - .../v1/interface.go | 62 ------ .../v1/schedulingspec.go | 87 -------- .../listers/controller/v1/appwrapper.go | 105 ---------- pkg/client/listers/controller/v1/doc.go | 7 - .../listers/controller/v1/schedulingspec.go | 105 ---------- .../clients/appwrapper.go => queuejob.go} | 74 +++++-- .../clientset/versioned/clientset.go | 103 --------- .../quotasubtree/clientset/versioned/doc.go | 24 --- .../versioned/fake/clientset_generated.go | 82 -------- .../clientset/versioned/fake/doc.go | 20 -- .../clientset/versioned/fake/register.go | 56 ----- .../clientset/versioned/scheme/doc.go | 20 -- .../clientset/versioned/scheme/register.go | 56 ----- .../versioned/typed/quotasubtree/v1/doc.go | 24 --- .../typed/quotasubtree/v1/fake/doc.go | 20 -- .../quotasubtree/v1/fake/fake_quotasubtree.go | 142 ------------- .../v1/fake/fake_quotasubtree_client.go | 41 ---- .../quotasubtree/v1/generated_expansion.go | 21 -- .../typed/quotasubtree/v1/quotasubtree.go | 195 ------------------ .../quotasubtree/v1/quotasubtree_client.go | 89 -------- pkg/client/quotasubtree/doc.go | 5 - .../informers/externalversions/doc.go | 24 --- .../informers/externalversions/factory.go | 180 ---------------- .../informers/externalversions/generic.go | 62 ------ .../internalinterfaces/factory_interfaces.go | 40 ---- .../quotasubtree/interface.go | 46 ----- .../externalversions/quotasubtree/v1/doc.go | 24 --- .../quotasubtree/v1/interface.go | 45 ---- .../quotasubtree/v1/quotasubtree.go | 90 -------- .../listers/quotasubtree/v1/doc.go | 24 --- .../quotasubtree/v1/expansion_generated.go | 27 --- .../listers/quotasubtree/v1/quotasubtree.go | 99 --------- .../queuejob/queuejob_controller_ex.go | 2 +- pkg/controller/queuejob/utils.go | 20 +- .../queuejobdispatch/queuejobagent.go | 32 ++- pkg/controller/queuejobresources/pod/pod.go | 2 +- 53 files changed, 80 insertions(+), 3357 deletions(-) delete mode 100644 pkg/client/clientset/controller-versioned/clients/factory.go delete mode 100644 pkg/client/clientset/controller-versioned/clients/queuejob.go delete mode 100644 pkg/client/clientset/controller-versioned/clients/schedulingspec.go delete mode 100644 pkg/client/clientset/controller-versioned/clientset.go delete mode 100644 pkg/client/clientset/controller-versioned/doc.go delete mode 100644 pkg/client/clientset/controller-versioned/scheme/register.go delete mode 100644 pkg/client/clientset/controller-versioned/typed/v1/appwrapper.go delete mode 100644 pkg/client/clientset/controller-versioned/typed/v1/client.go delete mode 100644 pkg/client/clientset/controller-versioned/typed/v1/queuejob.go delete mode 100644 pkg/client/clientset/controller-versioned/typed/v1/schedulingspec.go delete mode 100644 pkg/client/informers/controller-externalversion/doc.go delete mode 100644 pkg/client/informers/controller-externalversion/factory.go delete mode 100644 pkg/client/informers/controller-externalversion/generic.go delete mode 100644 pkg/client/informers/controller-externalversion/internalinterfaces/doc.go delete mode 100644 pkg/client/informers/controller-externalversion/internalinterfaces/factory_interfaces.go delete mode 100644 pkg/client/informers/controller-externalversion/v1/appwrapper.go delete mode 100644 pkg/client/informers/controller-externalversion/v1/doc.go delete mode 100644 pkg/client/informers/controller-externalversion/v1/interface.go delete mode 100644 pkg/client/informers/controller-externalversion/v1/schedulingspec.go delete mode 100644 pkg/client/listers/controller/v1/appwrapper.go delete mode 100644 pkg/client/listers/controller/v1/doc.go delete mode 100644 pkg/client/listers/controller/v1/schedulingspec.go rename pkg/client/{clientset/controller-versioned/clients/appwrapper.go => queuejob.go} (59%) delete mode 100755 pkg/client/quotasubtree/clientset/versioned/clientset.go delete mode 100755 pkg/client/quotasubtree/clientset/versioned/doc.go delete mode 100755 pkg/client/quotasubtree/clientset/versioned/fake/clientset_generated.go delete mode 100755 pkg/client/quotasubtree/clientset/versioned/fake/doc.go delete mode 100755 pkg/client/quotasubtree/clientset/versioned/fake/register.go delete mode 100755 pkg/client/quotasubtree/clientset/versioned/scheme/doc.go delete mode 100755 pkg/client/quotasubtree/clientset/versioned/scheme/register.go delete mode 100755 pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/doc.go delete mode 100755 pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/fake/doc.go delete mode 100755 pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/fake/fake_quotasubtree.go delete mode 100755 pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/fake/fake_quotasubtree_client.go delete mode 100755 pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/generated_expansion.go delete mode 100755 pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/quotasubtree.go delete mode 100755 pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/quotasubtree_client.go delete mode 100644 pkg/client/quotasubtree/doc.go delete mode 100755 pkg/client/quotasubtree/informers/externalversions/doc.go delete mode 100755 pkg/client/quotasubtree/informers/externalversions/factory.go delete mode 100755 pkg/client/quotasubtree/informers/externalversions/generic.go delete mode 100755 pkg/client/quotasubtree/informers/externalversions/internalinterfaces/factory_interfaces.go delete mode 100755 pkg/client/quotasubtree/informers/externalversions/quotasubtree/interface.go delete mode 100755 pkg/client/quotasubtree/informers/externalversions/quotasubtree/v1/doc.go delete mode 100755 pkg/client/quotasubtree/informers/externalversions/quotasubtree/v1/interface.go delete mode 100755 pkg/client/quotasubtree/informers/externalversions/quotasubtree/v1/quotasubtree.go delete mode 100755 pkg/client/quotasubtree/listers/quotasubtree/v1/doc.go delete mode 100755 pkg/client/quotasubtree/listers/quotasubtree/v1/expansion_generated.go delete mode 100755 pkg/client/quotasubtree/listers/quotasubtree/v1/quotasubtree.go diff --git a/pkg/client/clientset/controller-versioned/clients/factory.go b/pkg/client/clientset/controller-versioned/clients/factory.go deleted file mode 100644 index 8a9907a99..000000000 --- a/pkg/client/clientset/controller-versioned/clients/factory.go +++ /dev/null @@ -1,59 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -/* -Copyright 2019, 2021 The Multi-Cluster App Dispatcher Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package clients - -import ( - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/serializer" - "k8s.io/client-go/rest" - - arbv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" -) - -func NewClient(cfg *rest.Config) (*rest.RESTClient, *runtime.Scheme, error) { - scheme := runtime.NewScheme() - if err := arbv1.AddToScheme(scheme); err != nil { - return nil, nil, err - } - - config := *cfg - config.GroupVersion = &arbv1.SchemeGroupVersion - config.APIPath = "/apis" - config.ContentType = runtime.ContentTypeJSON - config.NegotiatedSerializer = serializer.WithoutConversionCodecFactory{CodecFactory: serializer.NewCodecFactory(scheme)} - - client, err := rest.RESTClientFor(&config) - if err != nil { - return nil, nil, err - } - - return client, scheme, nil -} diff --git a/pkg/client/clientset/controller-versioned/clients/queuejob.go b/pkg/client/clientset/controller-versioned/clients/queuejob.go deleted file mode 100644 index ed40031e6..000000000 --- a/pkg/client/clientset/controller-versioned/clients/queuejob.go +++ /dev/null @@ -1,101 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -/* -Copyright 2019, 2021 The Multi-Cluster App Dispatcher Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package clients - -import ( - "context" - "fmt" - "os" - "time" - - arbv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" - - apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - apiextensionsclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/errors" - "k8s.io/apimachinery/pkg/util/wait" - "k8s.io/klog/v2" - "sigs.k8s.io/yaml" -) - -const QueueJobCrdPath = "config/crd/bases/mcad.ibm.com_queuejobs.yaml" -const queueJobKindName = arbv1.QueueJobPlural + "." + arbv1.GroupName - -func CreateQueueJobKind(clientset apiextensionsclient.Interface) (*apiextensionsv1.CustomResourceDefinition, error) { - f, err := os.ReadFile(QueueJobCrdPath) - if err != nil { - return nil, fmt.Errorf("cannot load the CRD from file %s: %v", QueueJobCrdPath, err) - } - - crd := &apiextensionsv1.CustomResourceDefinition{} - err = yaml.Unmarshal(f, crd) - if err != nil { - return nil, fmt.Errorf("cannot unmarshal the CRD: %v", err) - } - - _, err = clientset.ApiextensionsV1().CustomResourceDefinitions().Create(context.Background(), crd, metav1.CreateOptions{}) - if err != nil { - return nil, err - } - - // wait for CRD being established - err = wait.Poll(500*time.Millisecond, 60*time.Second, func() (bool, error) { - crd, err = clientset.ApiextensionsV1().CustomResourceDefinitions().Get(context.Background(), queueJobKindName, metav1.GetOptions{}) - if err != nil { - return false, err - } - for _, cond := range crd.Status.Conditions { - switch cond.Type { - case apiextensionsv1.Established: - if cond.Status == apiextensionsv1.ConditionTrue { - return true, err - } - case apiextensionsv1.NamesAccepted: - if cond.Status == apiextensionsv1.ConditionFalse { - fmt.Printf("Name conflict: %v\n", cond.Reason) - } - } - } - return false, err - }) - if err != nil { - deleteErr := clientset.ApiextensionsV1().CustomResourceDefinitions().Delete(context.Background(), queueJobKindName, metav1.DeleteOptions{}) - if deleteErr != nil { - return nil, errors.NewAggregate([]error{err, deleteErr}) - } - return nil, err - } - - klog.V(4).Infof("QueueJob CRD was created.") - - return crd, nil -} diff --git a/pkg/client/clientset/controller-versioned/clients/schedulingspec.go b/pkg/client/clientset/controller-versioned/clients/schedulingspec.go deleted file mode 100644 index df00c3690..000000000 --- a/pkg/client/clientset/controller-versioned/clients/schedulingspec.go +++ /dev/null @@ -1,101 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -/* -Copyright 2019, 2021 The Multi-Cluster App Dispatcher Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package clients - -import ( - "context" - "fmt" - "os" - "time" - - arbv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" - - apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - apiextensionsclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/errors" - "k8s.io/apimachinery/pkg/util/wait" - "k8s.io/klog/v2" - "sigs.k8s.io/yaml" -) - -const SchedulingSpecCrdPath = "config/crd/bases/mcad.ibm.com_schedulingspecs.yaml" -const schedulingSpecKindName = arbv1.SchedulingSpecPlural + "." + arbv1.GroupName - -func CreateSchedulingSpecKind(clientset apiextensionsclient.Interface) (*apiextensionsv1.CustomResourceDefinition, error) { - f, err := os.ReadFile(SchedulingSpecCrdPath) - if err != nil { - return nil, fmt.Errorf("cannot load the CRD from file %s: %v", SchedulingSpecCrdPath, err) - } - - crd := &apiextensionsv1.CustomResourceDefinition{} - err = yaml.Unmarshal(f, crd) - if err != nil { - return nil, fmt.Errorf("cannot unmarshal the CRD: %v", err) - } - - _, err = clientset.ApiextensionsV1().CustomResourceDefinitions().Create(context.Background(), crd, metav1.CreateOptions{}) - if err != nil { - return nil, err - } - - // wait for CRD being established - err = wait.Poll(500*time.Millisecond, 60*time.Second, func() (bool, error) { - crd, err = clientset.ApiextensionsV1().CustomResourceDefinitions().Get(context.Background(), schedulingSpecKindName, metav1.GetOptions{}) - if err != nil { - return false, err - } - for _, cond := range crd.Status.Conditions { - switch cond.Type { - case apiextensionsv1.Established: - if cond.Status == apiextensionsv1.ConditionTrue { - return true, err - } - case apiextensionsv1.NamesAccepted: - if cond.Status == apiextensionsv1.ConditionFalse { - fmt.Printf("Name conflict: %v\n", cond.Reason) - } - } - } - return false, err - }) - if err != nil { - deleteErr := clientset.ApiextensionsV1().CustomResourceDefinitions().Delete(context.Background(), schedulingSpecKindName, metav1.DeleteOptions{}) - if deleteErr != nil { - return nil, errors.NewAggregate([]error{err, deleteErr}) - } - return nil, err - } - - klog.V(3).Infof("SchedulingSpec CRD was created.") - - return crd, nil -} diff --git a/pkg/client/clientset/controller-versioned/clientset.go b/pkg/client/clientset/controller-versioned/clientset.go deleted file mode 100644 index 36649bf4e..000000000 --- a/pkg/client/clientset/controller-versioned/clientset.go +++ /dev/null @@ -1,80 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -/* -Copyright 2019, 2021 The Multi-Cluster App Dispatcher Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package controller_versioned - -import ( - "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/controller-versioned/typed/v1" - - "k8s.io/client-go/rest" -) - -type Interface interface { - ArbV1() v1.ArbV1Interface -} - -// Clientset contains the clients for groups. Each group has exactly one -// version included in a Clientset. -type Clientset struct { - arbv1 *v1.ArbV1Client -} - -// CoreV1 retrieves the CoreV1Client -func (c *Clientset) ArbV1() v1.ArbV1Interface { - return c.arbv1 -} - -// NewForConfig creates a new Clientset for the given config. -func NewForConfig(c *rest.Config) (*Clientset, error) { - var cs Clientset - var err error - cs.arbv1, err = v1.NewForConfig(c) - if err != nil { - return nil, err - } - return &cs, nil -} - -// NewForConfigOrDie creates a new Clientset for the given config and -// panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *Clientset { - var cs Clientset - cs.arbv1 = v1.NewForConfigOrDie(c) - - return &cs -} - -// New creates a new Clientset for the given RESTClient. -func New(c rest.Interface) *Clientset { - var cs Clientset - cs.arbv1 = v1.New(c) - - return &cs -} diff --git a/pkg/client/clientset/controller-versioned/doc.go b/pkg/client/clientset/controller-versioned/doc.go deleted file mode 100644 index 0da431ac4..000000000 --- a/pkg/client/clientset/controller-versioned/doc.go +++ /dev/null @@ -1,7 +0,0 @@ -// Package controller_versioned provides a set of Appwrapper clients to be used with interacting with AppWrapper CRDS. -// RC4 -// Deprecated: controller_versioned has been replaced by the versioned as that package is generated using the client gen tool. -// controller_versioned interfaces and methods should not be used except for compatibility. It will be removed in future versions. -// -// This package is frozen and no new functionality will be added. -package controller_versioned diff --git a/pkg/client/clientset/controller-versioned/scheme/register.go b/pkg/client/clientset/controller-versioned/scheme/register.go deleted file mode 100644 index ce16a4086..000000000 --- a/pkg/client/clientset/controller-versioned/scheme/register.go +++ /dev/null @@ -1,67 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -/* -Copyright 2019, 2021 The Multi-Cluster App Dispatcher Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package scheme - -import ( - arbv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" - - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - schema "k8s.io/apimachinery/pkg/runtime/schema" - serializer "k8s.io/apimachinery/pkg/runtime/serializer" -) - -var Scheme = runtime.NewScheme() -var Codecs = serializer.NewCodecFactory(Scheme) -var ParameterCodec = runtime.NewParameterCodec(Scheme) - -func init() { - v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) - AddToScheme(Scheme) -} - -// AddToScheme adds all types of this clientset into the given scheme. This allows composition -// of clientsets, like in: -// -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kuberentes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) -// -// kclientset, _ := kubernetes.NewForConfig(c) -// aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) -// -// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types -// correctly. -func AddToScheme(scheme *runtime.Scheme) { - arbv1.AddToScheme(scheme) -} diff --git a/pkg/client/clientset/controller-versioned/typed/v1/appwrapper.go b/pkg/client/clientset/controller-versioned/typed/v1/appwrapper.go deleted file mode 100644 index 74ecee540..000000000 --- a/pkg/client/clientset/controller-versioned/typed/v1/appwrapper.go +++ /dev/null @@ -1,145 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -/* -Copyright 2019, 2021 The Multi-Cluster App Dispatcher Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package v1 - -import ( - "context" - - v1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" - "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/controller-versioned/scheme" - - meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/client-go/rest" -) - -type AppWrapperGetter interface { - AppWrappers(namespaces string) AppWrapperInterface -} - -type AppWrapperInterface interface { - Create(*v1.AppWrapper) (*v1.AppWrapper, error) - Update(*v1.AppWrapper) (*v1.AppWrapper, error) - UpdateStatus(*v1.AppWrapper) (*v1.AppWrapper, error) - Delete(name string, options *meta_v1.DeleteOptions) error - Get(name string, options meta_v1.GetOptions) (*v1.AppWrapper, error) - List(opts meta_v1.ListOptions) (*v1.AppWrapperList, error) -} - -// appwrappers implements AppWrapperInterface -type appwrappers struct { - client rest.Interface - ns string -} - -// newAppWrappers returns a AppWrapper -func newAppWrappers(c *ArbV1Client, namespace string) *appwrappers { - return &appwrappers{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Create takes the representation of an appwrappers and creates it. Returns the server's representation of the appwrappers, and an error, if there is any. -func (c *appwrappers) Create(appwrapper *v1.AppWrapper) (result *v1.AppWrapper, err error) { - result = &v1.AppWrapper{} - err = c.client.Post(). - Namespace(c.ns). - Resource(v1.AppWrapperPlural). - Body(appwrapper). - Do(context.Background()). - Into(result) - return -} - -// Update takes the representation of an appwrappers and updates it. Returns the server's representation of the appwrappers, and an error, if there is any. -func (c *appwrappers) Update(appwrapper *v1.AppWrapper) (result *v1.AppWrapper, err error) { - result = &v1.AppWrapper{} - err = c.client.Put(). - Namespace(c.ns). - Resource(v1.AppWrapperPlural). - Name(appwrapper.Name). - Body(appwrapper). - Do(context.Background()). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). - -func (c *appwrappers) UpdateStatus(appwrapper *v1.AppWrapper) (result *v1.AppWrapper, err error) { - result = &v1.AppWrapper{} - err = c.client.Put(). - Namespace(c.ns). - Resource(v1.AppWrapperPlural). - Name(appwrapper.Name). - SubResource("status"). - Body(appwrapper). - Do(context.Background()). - Into(result) - return -} - -// Delete takes name of the appwrappers and deletes it. Returns an error if one occurs. -func (c *appwrappers) Delete(name string, options *meta_v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource(v1.AppWrapperPlural). - Name(name). - Body(options). - Do(context.Background()). - Error() -} - -// Get takes name of the appwrappers, and returns the corresponding appwrappers object, and an error if there is any. -func (c *appwrappers) Get(name string, options meta_v1.GetOptions) (result *v1.AppWrapper, err error) { - result = &v1.AppWrapper{} - err = c.client.Get(). - Namespace(c.ns). - Resource(v1.AppWrapperPlural). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(context.Background()). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of AppWrappers that match those selectors. -func (c *appwrappers) List(opts meta_v1.ListOptions) (result *v1.AppWrapperList, err error) { - result = &v1.AppWrapperList{} - err = c.client.Get(). - Namespace(c.ns). - Resource(v1.AppWrapperPlural). - VersionedParams(&opts, scheme.ParameterCodec). - Do(context.Background()). - Into(result) - return -} diff --git a/pkg/client/clientset/controller-versioned/typed/v1/client.go b/pkg/client/clientset/controller-versioned/typed/v1/client.go deleted file mode 100644 index 20bd1c028..000000000 --- a/pkg/client/clientset/controller-versioned/typed/v1/client.go +++ /dev/null @@ -1,114 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -/* -Copyright 2019, 2021 The Multi-Cluster App Dispatcher Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package v1 - -import ( - v1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" - - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/serializer" - "k8s.io/client-go/rest" -) - -type ArbV1Interface interface { - RESTClient() rest.Interface - SchedulingSpecGetter - QueueJobGetter - AppWrapperGetter -} - -// ArbV1Client is used to interact with features provided by the group. -type ArbV1Client struct { - restClient rest.Interface -} - -func (c *ArbV1Client) SchedulingSpecs(namespace string) SchedulingSpecInterface { - return newSchedulingSpecs(c, namespace) -} - -func (c *ArbV1Client) QueueJobs(namespace string) QueueJobInterface { - return newQueueJobs(c, namespace) -} - -func (c *ArbV1Client) AppWrappers(namespace string) AppWrapperInterface { - return newAppWrappers(c, namespace) -} - -// NewForConfig creates a new ArbV1Client for the given config. -func NewForConfig(c *rest.Config) (*ArbV1Client, error) { - config := *c - if err := setConfigDefaults(&config); err != nil { - return nil, err - } - client, err := rest.RESTClientFor(&config) - if err != nil { - return nil, err - } - return &ArbV1Client{client}, nil -} - -// NewForConfigOrDie creates a new ArbV1Client for the given config and -// panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *ArbV1Client { - client, err := NewForConfig(c) - if err != nil { - panic(err) - } - return client -} - -// New creates a new ArbV1Client for the given RESTClient. -func New(c rest.Interface) *ArbV1Client { - return &ArbV1Client{c} -} - -func setConfigDefaults(config *rest.Config) error { - scheme := runtime.NewScheme() - if err := v1.AddToScheme(scheme); err != nil { - return err - } - - config.GroupVersion = &v1.SchemeGroupVersion - config.APIPath = "/apis" - config.ContentType = runtime.ContentTypeJSON - config.NegotiatedSerializer = serializer.WithoutConversionCodecFactory{CodecFactory: serializer.NewCodecFactory(scheme)} // serializer.DirectCodecFactory{CodecFactory: serializer.NewCodecFactory(scheme)} - - return nil -} - -// RESTClient returns a RESTClient that is used to communicate -// with API server by this client implementation. -func (c *ArbV1Client) RESTClient() rest.Interface { - if c == nil { - return nil - } - return c.restClient -} diff --git a/pkg/client/clientset/controller-versioned/typed/v1/queuejob.go b/pkg/client/clientset/controller-versioned/typed/v1/queuejob.go deleted file mode 100644 index dd8814b54..000000000 --- a/pkg/client/clientset/controller-versioned/typed/v1/queuejob.go +++ /dev/null @@ -1,145 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -/* -Copyright 2019, 2021 The Multi-Cluster App Dispatcher Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package v1 - -import ( - "context" - - v1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" - "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/controller-versioned/scheme" - - meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/client-go/rest" -) - -type QueueJobGetter interface { - QueueJobs(namespaces string) QueueJobInterface -} - -type QueueJobInterface interface { - Create(*v1.QueueJob) (*v1.QueueJob, error) - Update(*v1.QueueJob) (*v1.QueueJob, error) - UpdateStatus(*v1.QueueJob) (*v1.QueueJob, error) - Delete(name string, options *meta_v1.DeleteOptions) error - Get(name string, options meta_v1.GetOptions) (*v1.QueueJob, error) - List(opts meta_v1.ListOptions) (*v1.QueueJobList, error) -} - -// queuejobs implements QueueJobInterface -type queuejobs struct { - client rest.Interface - ns string -} - -// newQueueJobs returns a QueueJobs -func newQueueJobs(c *ArbV1Client, namespace string) *queuejobs { - return &queuejobs{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Create takes the representation of a queuejob and creates it. Returns the server's representation of the queuejob, and an error, if there is any. -func (c *queuejobs) Create(queuejob *v1.QueueJob) (result *v1.QueueJob, err error) { - result = &v1.QueueJob{} - err = c.client.Post(). - Namespace(c.ns). - Resource(v1.QueueJobPlural). - Body(queuejob). - Do(context.Background()). - Into(result) - return -} - -// Update takes the representation of a queuejob and updates it. Returns the server's representation of the queuejob, and an error, if there is any. -func (c *queuejobs) Update(queuejob *v1.QueueJob) (result *v1.QueueJob, err error) { - result = &v1.QueueJob{} - err = c.client.Put(). - Namespace(c.ns). - Resource(v1.QueueJobPlural). - Name(queuejob.Name). - Body(queuejob). - Do(context.Background()). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). - -func (c *queuejobs) UpdateStatus(queuejob *v1.QueueJob) (result *v1.QueueJob, err error) { - result = &v1.QueueJob{} - err = c.client.Put(). - Namespace(c.ns). - Resource(v1.QueueJobPlural). - Name(queuejob.Name). - SubResource("status"). - Body(queuejob). - Do(context.Background()). - Into(result) - return -} - -// Delete takes name of the queuejob and deletes it. Returns an error if one occurs. -func (c *queuejobs) Delete(name string, options *meta_v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource(v1.QueueJobPlural). - Name(name). - Body(options). - Do(context.Background()). - Error() -} - -// Get takes name of the queuejob, and returns the corresponding queuejob object, and an error if there is any. -func (c *queuejobs) Get(name string, options meta_v1.GetOptions) (result *v1.QueueJob, err error) { - result = &v1.QueueJob{} - err = c.client.Get(). - Namespace(c.ns). - Resource(v1.QueueJobPlural). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(context.Background()). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of QueueJobs that match those selectors. -func (c *queuejobs) List(opts meta_v1.ListOptions) (result *v1.QueueJobList, err error) { - result = &v1.QueueJobList{} - err = c.client.Get(). - Namespace(c.ns). - Resource(v1.QueueJobPlural). - VersionedParams(&opts, scheme.ParameterCodec). - Do(context.Background()). - Into(result) - return -} diff --git a/pkg/client/clientset/controller-versioned/typed/v1/schedulingspec.go b/pkg/client/clientset/controller-versioned/typed/v1/schedulingspec.go deleted file mode 100644 index 93f6b36ac..000000000 --- a/pkg/client/clientset/controller-versioned/typed/v1/schedulingspec.go +++ /dev/null @@ -1,145 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -/* -Copyright 2019, 2021 The Multi-Cluster App Dispatcher Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package v1 - -import ( - "context" - - v1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" - "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/controller-versioned/scheme" - - meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/client-go/rest" -) - -type SchedulingSpecGetter interface { - SchedulingSpecs(namespaces string) SchedulingSpecInterface -} - -type SchedulingSpecInterface interface { - Create(*v1.SchedulingSpec) (*v1.SchedulingSpec, error) - Update(*v1.SchedulingSpec) (*v1.SchedulingSpec, error) - UpdateStatus(*v1.SchedulingSpec) (*v1.SchedulingSpec, error) - Delete(name string, options *meta_v1.DeleteOptions) error - Get(name string, options meta_v1.GetOptions) (*v1.SchedulingSpec, error) - List(opts meta_v1.ListOptions) (*v1.SchedulingSpecList, error) -} - -// schedulingSpecs implements SchedulingSpecInterface -type schedulingSpecs struct { - client rest.Interface - ns string -} - -// newQueues returns a Queues -func newSchedulingSpecs(c *ArbV1Client, namespace string) *schedulingSpecs { - return &schedulingSpecs{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Create takes the representation of a queue and creates it. Returns the server's representation of the queue, and an error, if there is any. -func (c *schedulingSpecs) Create(queue *v1.SchedulingSpec) (result *v1.SchedulingSpec, err error) { - result = &v1.SchedulingSpec{} - err = c.client.Post(). - Namespace(c.ns). - Resource(v1.SchedulingSpecPlural). - Body(queue). - Do(context.Background()). - Into(result) - return -} - -// Update takes the representation of a queue and updates it. Returns the server's representation of the queue, and an error, if there is any. -func (c *schedulingSpecs) Update(queue *v1.SchedulingSpec) (result *v1.SchedulingSpec, err error) { - result = &v1.SchedulingSpec{} - err = c.client.Put(). - Namespace(c.ns). - Resource(v1.SchedulingSpecPlural). - Name(queue.Name). - Body(queue). - Do(context.Background()). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). - -func (c *schedulingSpecs) UpdateStatus(queue *v1.SchedulingSpec) (result *v1.SchedulingSpec, err error) { - result = &v1.SchedulingSpec{} - err = c.client.Put(). - Namespace(c.ns). - Resource(v1.SchedulingSpecPlural). - Name(queue.Name). - SubResource("status"). - Body(queue). - Do(context.Background()). - Into(result) - return -} - -// Delete takes name of the queue and deletes it. Returns an error if one occurs. -func (c *schedulingSpecs) Delete(name string, options *meta_v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource(v1.SchedulingSpecPlural). - Name(name). - Body(options). - Do(context.Background()). - Error() -} - -// Get takes name of the queue, and returns the corresponding queue object, and an error if there is any. -func (c *schedulingSpecs) Get(name string, options meta_v1.GetOptions) (result *v1.SchedulingSpec, err error) { - result = &v1.SchedulingSpec{} - err = c.client.Get(). - Namespace(c.ns). - Resource(v1.SchedulingSpecPlural). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(context.Background()). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of Queues that match those selectors. -func (c *schedulingSpecs) List(opts meta_v1.ListOptions) (result *v1.SchedulingSpecList, err error) { - result = &v1.SchedulingSpecList{} - err = c.client.Get(). - Namespace(c.ns). - Resource(v1.SchedulingSpecPlural). - VersionedParams(&opts, scheme.ParameterCodec). - Do(context.Background()). - Into(result) - return -} diff --git a/pkg/client/informers/controller-externalversion/doc.go b/pkg/client/informers/controller-externalversion/doc.go deleted file mode 100644 index 32c77ae23..000000000 --- a/pkg/client/informers/controller-externalversion/doc.go +++ /dev/null @@ -1,7 +0,0 @@ -// Package controller_externalversion provides a set of Appwrapper informers to be used with interacting with AppWrapper CRDS. -// -// Deprecated: controller_externalversion has been replaced by the external version as that package is generated using the client gen tool. -// controller_externalversion interfaces and methods should not be used except for compatibility. It will be removed in future versions. -// -// This package is frozen and no new functionality will be added. -package controller_externalversion diff --git a/pkg/client/informers/controller-externalversion/factory.go b/pkg/client/informers/controller-externalversion/factory.go deleted file mode 100644 index c082108a0..000000000 --- a/pkg/client/informers/controller-externalversion/factory.go +++ /dev/null @@ -1,177 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -/* -Copyright 2019, 2021 The Multi-Cluster App Dispatcher Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package controller_externalversion - -import ( - "reflect" - "sync" - "time" - - "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/controller-externalversion/internalinterfaces" - arbclient "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/controller-externalversion/v1" - - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/client-go/rest" - "k8s.io/client-go/tools/cache" -) - - -// SharedInformerOption defines the functional option type for SharedInformerFactory. -type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory - -type sharedInformerFactory struct { - client *rest.RESTClient - - tweakListOptions internalinterfaces.TweakListOptionsFunc - lock sync.Mutex - defaultResync time.Duration - - - informers map[reflect.Type]cache.SharedIndexInformer - // startedInformers is used for tracking which informers have been started. - // This allows Start() to be called multiple times safely. - startedInformers map[reflect.Type]bool -} - - -func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption { - return func(factory *sharedInformerFactory) *sharedInformerFactory { - factory.tweakListOptions = tweakListOptions - return factory - } -} - -func NewSharedInformerFactory(client *rest.RESTClient, defaultResync time.Duration) SharedInformerFactory { - return NewSharedInformerFactoryWithOptions(client, defaultResync) -} - -func NewFilteredSharedInformerFactory(client *rest.RESTClient, defaultResync time.Duration, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory { - return NewSharedInformerFactoryWithOptions(client, defaultResync, WithTweakListOptions(tweakListOptions)) -} - -// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options. -func NewSharedInformerFactoryWithOptions(client *rest.RESTClient, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory { - factory := &sharedInformerFactory{ - client: client, - - defaultResync: defaultResync, - informers: make(map[reflect.Type]cache.SharedIndexInformer), - startedInformers: make(map[reflect.Type]bool), - - } - - // Apply all options - for _, opt := range options { - factory = opt(factory) - } - - return factory -} - -// Start initializes all requested informers. -func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { - f.lock.Lock() - defer f.lock.Unlock() - - for informerType, informer := range f.informers { - if !f.startedInformers[informerType] { - go informer.Run(stopCh) - f.startedInformers[informerType] = true - } - } -} - -// WaitForCacheSync waits for all started informers' cache were synced. -func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool { - informers := func() map[reflect.Type]cache.SharedIndexInformer { - f.lock.Lock() - defer f.lock.Unlock() - - informers := map[reflect.Type]cache.SharedIndexInformer{} - for informerType, informer := range f.informers { - if f.startedInformers[informerType] { - informers[informerType] = informer - } - } - return informers - }() - - res := map[reflect.Type]bool{} - for informType, informer := range informers { - res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced) - } - return res -} - -// InternalInformerFor returns the SharedIndexInformer for obj using an internal -// client. -func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer { - f.lock.Lock() - defer f.lock.Unlock() - - informerType := reflect.TypeOf(obj) - informer, exists := f.informers[informerType] - if exists { - return informer - } - informer = newFunc(f.client, f.defaultResync) - f.informers[informerType] = informer - - return informer -} - -// SharedInformerFactory provides shared informers for resources in all known -// API group versions. -type SharedInformerFactory interface { - internalinterfaces.SharedInformerFactory - ForResource(resource schema.GroupVersionResource) (GenericInformer, error) - WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool - - SchedulingSpec() arbclient.Interface - - QueueJob() arbclient.Interface - - AppWrapper() arbclient.Interface - -} - -func (f *sharedInformerFactory) SchedulingSpec() arbclient.Interface { - return arbclient.New(f, f.tweakListOptions) -} - -func (f *sharedInformerFactory) QueueJob() arbclient.Interface { - return arbclient.New(f, f.tweakListOptions) -} - -func (f *sharedInformerFactory) AppWrapper() arbclient.Interface { - return arbclient.New(f, f.tweakListOptions) -} diff --git a/pkg/client/informers/controller-externalversion/generic.go b/pkg/client/informers/controller-externalversion/generic.go deleted file mode 100644 index a1715087f..000000000 --- a/pkg/client/informers/controller-externalversion/generic.go +++ /dev/null @@ -1,82 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -/* -Copyright 2019, 2021 The Multi-Cluster App Dispatcher Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package controller_externalversion - -import ( - "fmt" - - arbv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" - - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/client-go/tools/cache" -) - -// GenericInformer is type of SharedIndexInformer which will locate and delegate to other -// sharedInformers based on type -type GenericInformer interface { - Informer() cache.SharedIndexInformer - Lister() cache.GenericLister -} - -type genericInformer struct { - informer cache.SharedIndexInformer - resource schema.GroupResource -} - -// Informer returns the SharedIndexInformer. -func (f *genericInformer) Informer() cache.SharedIndexInformer { - return f.informer -} - -// Lister returns the GenericLister. -func (f *genericInformer) Lister() cache.GenericLister { - return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) -} - -// ForResource gives generic access to a shared informer of the matching type -// TODO extend this to unknown resources with a client pool -func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { - switch resource { - // Group=, Version=V1 - case arbv1.SchemeGroupVersion.WithResource("schedulingspecs"): - return &genericInformer{ - resource: resource.GroupResource(), - informer: f.SchedulingSpec().SchedulingSpecs().Informer(), - }, nil - case arbv1.SchemeGroupVersion.WithResource("appwrappers"): - return &genericInformer{ - resource: resource.GroupResource(), - informer: f.AppWrapper().AppWrappers().Informer(), - }, nil - } - - return nil, fmt.Errorf("no informer found for %v", resource) -} diff --git a/pkg/client/informers/controller-externalversion/internalinterfaces/doc.go b/pkg/client/informers/controller-externalversion/internalinterfaces/doc.go deleted file mode 100644 index 46be2f7ac..000000000 --- a/pkg/client/informers/controller-externalversion/internalinterfaces/doc.go +++ /dev/null @@ -1,5 +0,0 @@ -// Deprecated: internalinterfaces has been replaced by the v1beta as that package is generated using the client gen tool. -// internalinterfaces interfaces and methods should not be used except for compatibility. It will be removed in future versions. -// -// This package is frozen and no new functionality will be added. -package internalinterfaces diff --git a/pkg/client/informers/controller-externalversion/internalinterfaces/factory_interfaces.go b/pkg/client/informers/controller-externalversion/internalinterfaces/factory_interfaces.go deleted file mode 100644 index 55d6e1cbf..000000000 --- a/pkg/client/informers/controller-externalversion/internalinterfaces/factory_interfaces.go +++ /dev/null @@ -1,37 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package internalinterfaces - -import ( - "time" - - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/client-go/rest" - "k8s.io/client-go/tools/cache" -) - -type NewInformerFunc func(*rest.RESTClient, time.Duration) cache.SharedIndexInformer - -// SharedInformerFactory a small interface to allow for adding an informer without an import cycle -type SharedInformerFactory interface { - Start(stopCh <-chan struct{}) - InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer -} - - -type TweakListOptionsFunc func(*v1.ListOptions) diff --git a/pkg/client/informers/controller-externalversion/v1/appwrapper.go b/pkg/client/informers/controller-externalversion/v1/appwrapper.go deleted file mode 100644 index dc26ca30e..000000000 --- a/pkg/client/informers/controller-externalversion/v1/appwrapper.go +++ /dev/null @@ -1,103 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -/* -Copyright 2019, 2021 The Multi-Cluster App Dispatcher Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package v1 - -import ( - "time" - - meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/fields" - "k8s.io/client-go/rest" - "k8s.io/client-go/tools/cache" - - arbv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" - "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/controller-externalversion/internalinterfaces" - "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers/controller/v1" -) - -//AppWrapperInformer provides access to a shared informer and lister for -// AppWrappers. -type AppWrapperInformer interface { - Informer() cache.SharedIndexInformer - Lister() v1.AppWrapperLister -} - -type appWrapperInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc -} - -//NewAppWrapperInformer constructs a new informer for AppWrapper type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewAppWrapperInformer(client *rest.RESTClient, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredAppWrapperInformer(client, namespace, resyncPeriod, indexers, nil) -} - -func NewFilteredAppWrapperInformer(client *rest.RESTClient, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { - if(tweakListOptions==nil) { - source := cache.NewListWatchFromClient( - client, - arbv1.AppWrapperPlural, - namespace, - fields.Everything()) - return cache.NewSharedIndexInformer( - source, - &arbv1.AppWrapper{}, - resyncPeriod, - indexers, - ) - } else { - source := cache.NewFilteredListWatchFromClient( - client, - arbv1.AppWrapperPlural, - namespace, - tweakListOptions) - return cache.NewSharedIndexInformer( - source, - &arbv1.AppWrapper{}, - resyncPeriod, - indexers, - ) - } -} - -func (f *appWrapperInformer) defaultAppWrapperInformer(client *rest.RESTClient, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredAppWrapperInformer(client, meta_v1.NamespaceAll, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) -} - -func (f *appWrapperInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&arbv1.AppWrapper{}, f.defaultAppWrapperInformer) -} - -func (f *appWrapperInformer) Lister() v1.AppWrapperLister { - return v1.NewAppWrapperLister(f.Informer().GetIndexer()) -} diff --git a/pkg/client/informers/controller-externalversion/v1/doc.go b/pkg/client/informers/controller-externalversion/v1/doc.go deleted file mode 100644 index dd13ca1b8..000000000 --- a/pkg/client/informers/controller-externalversion/v1/doc.go +++ /dev/null @@ -1,7 +0,0 @@ -// Package v1 provides a set of Appwrapper informers to be used with interacting with AppWrapper CRDS. -// -// Deprecated: v1 has been replaced by the v1beta as that package is generated using the client gen tool. -// v1 interfaces and methods should not be used except for compatibility. It will be removed in future versions. -// -// This package is frozen and no new functionality will be added. -package v1 diff --git a/pkg/client/informers/controller-externalversion/v1/interface.go b/pkg/client/informers/controller-externalversion/v1/interface.go deleted file mode 100644 index 92de6ac4c..000000000 --- a/pkg/client/informers/controller-externalversion/v1/interface.go +++ /dev/null @@ -1,62 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -/* -Copyright 2019, 2021 The Multi-Cluster App Dispatcher Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package v1 - -import ( - "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/controller-externalversion/internalinterfaces" -) - -// Interface provides access to all the informers in this group version. -type Interface interface { - // SchedulingSpecs returns a SchedulingSpecInformer. - SchedulingSpecs() SchedulingSpecInformer - // AppWrappers returns a QueueJobInformer. - AppWrappers() AppWrapperInformer -} - -type version struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc -} - -// New returns a new Interface. -func New(f internalinterfaces.SharedInformerFactory, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { - return &version{factory: f, tweakListOptions: tweakListOptions} -} - -// SchedulingSpecs returns a SchedulingSpecInformer. -func (v *version) SchedulingSpecs() SchedulingSpecInformer { - return &schedulingSpecInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} - -func (v *version) AppWrappers() AppWrapperInformer { - return &appWrapperInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} diff --git a/pkg/client/informers/controller-externalversion/v1/schedulingspec.go b/pkg/client/informers/controller-externalversion/v1/schedulingspec.go deleted file mode 100644 index dd2e1f01a..000000000 --- a/pkg/client/informers/controller-externalversion/v1/schedulingspec.go +++ /dev/null @@ -1,87 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -/* -Copyright 2019, 2021 The Multi-Cluster App Dispatcher Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package v1 - -import ( - "time" - - meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/fields" - "k8s.io/client-go/rest" - "k8s.io/client-go/tools/cache" - - arbv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" - "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/controller-externalversion/internalinterfaces" - "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers/controller/v1" -) - -// SchedulingSpecInformer provides access to a shared informer and lister for -// Queues. -type SchedulingSpecInformer interface { - Informer() cache.SharedIndexInformer - Lister() v1.SchedulingSpecLister -} - -type schedulingSpecInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc -} - -// NewSchedulingSpecInformer constructs a new informer for Queue type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewSchedulingSpecInformer(client *rest.RESTClient, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - source := cache.NewListWatchFromClient( - client, - arbv1.SchedulingSpecPlural, - namespace, - fields.Everything()) - - return cache.NewSharedIndexInformer( - source, - &arbv1.SchedulingSpec{}, - resyncPeriod, - indexers, - ) -} - -func (f *schedulingSpecInformer) defaultSchedulingSpecInformer(client *rest.RESTClient, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewSchedulingSpecInformer(client, meta_v1.NamespaceAll, - resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}) -} - -func (f *schedulingSpecInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&arbv1.SchedulingSpec{}, f.defaultSchedulingSpecInformer) -} - -func (f *schedulingSpecInformer) Lister() v1.SchedulingSpecLister { - return v1.NewSchedulingSpecLister(f.Informer().GetIndexer()) -} diff --git a/pkg/client/listers/controller/v1/appwrapper.go b/pkg/client/listers/controller/v1/appwrapper.go deleted file mode 100644 index f09e0676f..000000000 --- a/pkg/client/listers/controller/v1/appwrapper.go +++ /dev/null @@ -1,105 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -/* -Copyright 2019, 2021 The Multi-Cluster App Dispatcher Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package v1 - -import ( - arbv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" - - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/tools/cache" -) - -//AppWrapperLister helps list AppWrappers. -type AppWrapperLister interface { - // List lists all AppWrappers in the indexer. - List(selector labels.Selector) (ret []*arbv1.AppWrapper, err error) - // AppWrappers returns an object that can list and get AppWrappers. - AppWrappers(namespace string) AppWrapperNamespaceLister -} - -// queueJobLister implements the AppWrapperLister interface. -type appWrapperLister struct { - indexer cache.Indexer -} - -//NewAppWrapperLister returns a new AppWrapperLister. -func NewAppWrapperLister(indexer cache.Indexer) AppWrapperLister { - return &appWrapperLister{indexer: indexer} -} - -//List lists all AppWrappers in the indexer. -func (s *appWrapperLister) List(selector labels.Selector) (ret []*arbv1.AppWrapper, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*arbv1.AppWrapper)) - }) - return ret, err -} - -//AppWrappers returns an object that can list and get AppWrappers. -func (s *appWrapperLister) AppWrappers(namespace string) AppWrapperNamespaceLister { - return appWrapperNamespaceLister{indexer: s.indexer, namespace: namespace} -} - -//AppWrapperNamespaceLister helps list and get AppWrappers. -type AppWrapperNamespaceLister interface { - // List lists all AppWrappers in the indexer for a given namespace. - List(selector labels.Selector) (ret []*arbv1.AppWrapper, err error) - // Get retrieves the AppWrapper from the indexer for a given namespace and name. - Get(name string) (*arbv1.AppWrapper, error) -} - -// queueJobNamespaceLister implements the AppWrapperNamespaceLister -// interface. -type appWrapperNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all AppWrappers in the indexer for a given namespace. -func (s appWrapperNamespaceLister) List(selector labels.Selector) (ret []*arbv1.AppWrapper, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*arbv1.AppWrapper)) - }) - return ret, err -} - -// Get retrieves the AppWrapper from the indexer for a given namespace and name. -func (s appWrapperNamespaceLister) Get(name string) (*arbv1.AppWrapper, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(arbv1.Resource("appwrappers"), name) - } - return obj.(*arbv1.AppWrapper), nil -} diff --git a/pkg/client/listers/controller/v1/doc.go b/pkg/client/listers/controller/v1/doc.go deleted file mode 100644 index 589a06e38..000000000 --- a/pkg/client/listers/controller/v1/doc.go +++ /dev/null @@ -1,7 +0,0 @@ -// Package v1 provides a set of Appwrapper lister to be used with interacting with AppWrapper CRDS. -// -// Deprecated: v1 has been replaced by the v1beta as that package is generated using the client gen tool. -// v1 interfaces and methods should not be used except for compatibility. It will be removed in future versions. -// -// This package is frozen and no new functionality will be added. -package v1 diff --git a/pkg/client/listers/controller/v1/schedulingspec.go b/pkg/client/listers/controller/v1/schedulingspec.go deleted file mode 100644 index 6970ff4ee..000000000 --- a/pkg/client/listers/controller/v1/schedulingspec.go +++ /dev/null @@ -1,105 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -/* -Copyright 2019, 2021 The Multi-Cluster App Dispatcher Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package v1 - -import ( - arbv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" - - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/tools/cache" -) - -// SchedulingSpecLister helps list Queues. -type SchedulingSpecLister interface { - // List lists all Queues in the indexer. - List(selector labels.Selector) (ret []*arbv1.SchedulingSpec, err error) - // SchedulingSpecs returns an object that can list and get Queues. - SchedulingSpecs(namespace string) SchedulingSpecNamespaceLister -} - -// queueLister implements the QueueLister interface. -type schedulingSpecLister struct { - indexer cache.Indexer -} - -// NewSchedulingSpecLister returns a new QueueLister. -func NewSchedulingSpecLister(indexer cache.Indexer) SchedulingSpecLister { - return &schedulingSpecLister{indexer: indexer} -} - -// List lists all Queues in the indexer. -func (s *schedulingSpecLister) List(selector labels.Selector) (ret []*arbv1.SchedulingSpec, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*arbv1.SchedulingSpec)) - }) - return ret, err -} - -// Queues returns an object that can list and get Queues. -func (s *schedulingSpecLister) SchedulingSpecs(namespace string) SchedulingSpecNamespaceLister { - return schedulingSpecNamespaceLister{indexer: s.indexer, namespace: namespace} -} - -// SchedulingSpecNamespaceLister helps list and get Queues. -type SchedulingSpecNamespaceLister interface { - // List lists all Queues in the indexer for a given namespace. - List(selector labels.Selector) (ret []*arbv1.SchedulingSpec, err error) - // Get retrieves the Queue from the indexer for a given namespace and name. - Get(name string) (*arbv1.SchedulingSpec, error) -} - -// schedulingSpecNamespaceLister implements the QueueNamespaceLister -// interface. -type schedulingSpecNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all Queues in the indexer for a given namespace. -func (s schedulingSpecNamespaceLister) List(selector labels.Selector) (ret []*arbv1.SchedulingSpec, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*arbv1.SchedulingSpec)) - }) - return ret, err -} - -// Get retrieves the Queue from the indexer for a given namespace and name. -func (s schedulingSpecNamespaceLister) Get(name string) (*arbv1.SchedulingSpec, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(arbv1.Resource("schedulingspecs"), name) - } - return obj.(*arbv1.SchedulingSpec), nil -} diff --git a/pkg/client/clientset/controller-versioned/clients/appwrapper.go b/pkg/client/queuejob.go similarity index 59% rename from pkg/client/clientset/controller-versioned/clients/appwrapper.go rename to pkg/client/queuejob.go index 4cd4e13d6..ad9e3aacb 100644 --- a/pkg/client/clientset/controller-versioned/clients/appwrapper.go +++ b/pkg/client/queuejob.go @@ -1,11 +1,11 @@ /* -Copyright 2018 The Kubernetes Authors. +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -13,22 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -/* -Copyright 2019, 2021 The Multi-Cluster App Dispatcher Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package clients +package client import ( "context" @@ -47,9 +32,62 @@ import ( "sigs.k8s.io/yaml" ) +const QueueJobCrdPath = "config/crd/bases/mcad.ibm.com_queuejobs.yaml" +const queueJobKindName = arbv1.QueueJobPlural + "." + arbv1.GroupName + const AppWrapperCrdPath = "config/crd/bases/mcad.ibm.com_appwrappers.yaml" const appWrapperKindName = arbv1.AppWrapperPlural + "." + arbv1.GroupName +func CreateQueueJobKind(clientset apiextensionsclient.Interface) (*apiextensionsv1.CustomResourceDefinition, error) { + f, err := os.ReadFile(QueueJobCrdPath) + if err != nil { + return nil, fmt.Errorf("cannot load the CRD from file %s: %v", QueueJobCrdPath, err) + } + + crd := &apiextensionsv1.CustomResourceDefinition{} + err = yaml.Unmarshal(f, crd) + if err != nil { + return nil, fmt.Errorf("cannot unmarshal the CRD: %v", err) + } + + _, err = clientset.ApiextensionsV1().CustomResourceDefinitions().Create(context.Background(), crd, metav1.CreateOptions{}) + if err != nil { + return nil, err + } + + // wait for CRD being established + err = wait.Poll(500*time.Millisecond, 60*time.Second, func() (bool, error) { + crd, err = clientset.ApiextensionsV1().CustomResourceDefinitions().Get(context.Background(), queueJobKindName, metav1.GetOptions{}) + if err != nil { + return false, err + } + for _, cond := range crd.Status.Conditions { + switch cond.Type { + case apiextensionsv1.Established: + if cond.Status == apiextensionsv1.ConditionTrue { + return true, err + } + case apiextensionsv1.NamesAccepted: + if cond.Status == apiextensionsv1.ConditionFalse { + fmt.Printf("Name conflict: %v\n", cond.Reason) + } + } + } + return false, err + }) + if err != nil { + deleteErr := clientset.ApiextensionsV1().CustomResourceDefinitions().Delete(context.Background(), queueJobKindName, metav1.DeleteOptions{}) + if deleteErr != nil { + return nil, errors.NewAggregate([]error{err, deleteErr}) + } + return nil, err + } + + klog.V(4).Infof("QueueJob CRD was created.") + + return crd, nil +} + func CreateAppWrapperKind(clientset apiextensionsclient.Interface) (*apiextensionsv1.CustomResourceDefinition, error) { f, err := os.ReadFile(AppWrapperCrdPath) if err != nil { diff --git a/pkg/client/quotasubtree/clientset/versioned/clientset.go b/pkg/client/quotasubtree/clientset/versioned/clientset.go deleted file mode 100755 index dce585637..000000000 --- a/pkg/client/quotasubtree/clientset/versioned/clientset.go +++ /dev/null @@ -1,103 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package versioned - -import ( - "fmt" - - discovery "k8s.io/client-go/discovery" - rest "k8s.io/client-go/rest" - flowcontrol "k8s.io/client-go/util/flowcontrol" - quotasubtreev1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1" -) - -type Interface interface { - Discovery() discovery.DiscoveryInterface - QuotasubtreeV1() quotasubtreev1.QuotaSubtreeV1Interface -} - -// Clientset contains the clients for groups. Each group has exactly one -// version included in a Clientset. -type Clientset struct { - *discovery.DiscoveryClient - quotasubtreeV1 *quotasubtreev1.QuotasubtreeV1Client -} - -// QuotasubtreeV1 retrieves the QuotasubtreeV1Client -func (c *Clientset) QuotasubtreeV1() quotasubtreev1.QuotaSubtreeV1Interface { - return c.quotasubtreeV1 -} - -// Discovery retrieves the DiscoveryClient -func (c *Clientset) Discovery() discovery.DiscoveryInterface { - if c == nil { - return nil - } - return c.DiscoveryClient -} - -// NewForConfig creates a new Clientset for the given config. -// If config's RateLimiter is not set and QPS and Burst are acceptable, -// NewForConfig will generate a rate-limiter in configShallowCopy. -func NewForConfig(c *rest.Config) (*Clientset, error) { - configShallowCopy := *c - if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { - if configShallowCopy.Burst <= 0 { - return nil, fmt.Errorf("burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0") - } - configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) - } - var cs Clientset - var err error - cs.quotasubtreeV1, err = quotasubtreev1.NewForConfig(&configShallowCopy) - if err != nil { - return nil, err - } - - cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfig(&configShallowCopy) - if err != nil { - return nil, err - } - return &cs, nil -} - -// NewForConfigOrDie creates a new Clientset for the given config and -// panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) (*Clientset, error) { - var cs Clientset - var err error - err = nil - cs.quotasubtreeV1, err = quotasubtreev1.NewForConfigOrDie(c) - - if err != nil { - return nil, err - } else { - cs.DiscoveryClient = discovery.NewDiscoveryClientForConfigOrDie(c) - } - return &cs, err -} - -// New creates a new Clientset for the given RESTClient. -func New(c rest.Interface) *Clientset { - var cs Clientset - cs.quotasubtreeV1 = quotasubtreev1.New(c) - - cs.DiscoveryClient = discovery.NewDiscoveryClient(c) - return &cs -} diff --git a/pkg/client/quotasubtree/clientset/versioned/doc.go b/pkg/client/quotasubtree/clientset/versioned/doc.go deleted file mode 100755 index f762c527b..000000000 --- a/pkg/client/quotasubtree/clientset/versioned/doc.go +++ /dev/null @@ -1,24 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -// Deprecated: quotasubtree has been replaced by the versioned as that package is generated using the client gen tool. -// quotasubtree interfaces and methods should not be used except for compatibility. It will be removed in future versions. -// -// This package is frozen and no new functionality will be added. - -// Code generated by client-gen. DO NOT EDIT. - -// This package has the automatically generated clientset. -package versioned diff --git a/pkg/client/quotasubtree/clientset/versioned/fake/clientset_generated.go b/pkg/client/quotasubtree/clientset/versioned/fake/clientset_generated.go deleted file mode 100755 index 5798ab417..000000000 --- a/pkg/client/quotasubtree/clientset/versioned/fake/clientset_generated.go +++ /dev/null @@ -1,82 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/watch" - "k8s.io/client-go/discovery" - fakediscovery "k8s.io/client-go/discovery/fake" - "k8s.io/client-go/testing" - clientset "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/quotasubtree/clientset/versioned" - quotasubtreev1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1" - fakequotasubtreev1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/fake" -) - -// NewSimpleClientset returns a clientset that will respond with the provided objects. -// It's backed by a very simple object tracker that processes creates, updates and deletions as-is, -// without applying any validations and/or defaults. It shouldn't be considered a replacement -// for a real clientset and is mostly useful in simple unit tests. -func NewSimpleClientset(objects ...runtime.Object) *Clientset { - o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder()) - for _, obj := range objects { - if err := o.Add(obj); err != nil { - panic(err) - } - } - - cs := &Clientset{tracker: o} - cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake} - cs.AddReactor("*", "*", testing.ObjectReaction(o)) - cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) { - gvr := action.GetResource() - ns := action.GetNamespace() - watch, err := o.Watch(gvr, ns) - if err != nil { - return false, nil, err - } - return true, watch, nil - }) - - return cs -} - -// Clientset implements clientset.Interface. Meant to be embedded into a -// struct to get a default implementation. This makes faking out just the method -// you want to test easier. -type Clientset struct { - testing.Fake - discovery *fakediscovery.FakeDiscovery - tracker testing.ObjectTracker -} - -func (c *Clientset) Discovery() discovery.DiscoveryInterface { - return c.discovery -} - -func (c *Clientset) Tracker() testing.ObjectTracker { - return c.tracker -} - -var _ clientset.Interface = &Clientset{} - -// QuotasubtreeV1 retrieves the QuotasubtreeV1Client -func (c *Clientset) QuotasubtreeV1() quotasubtreev1.QuotaSubtreeV1Interface { - return &fakequotasubtreev1.FakeQuotasubtreeV1{Fake: &c.Fake} -} diff --git a/pkg/client/quotasubtree/clientset/versioned/fake/doc.go b/pkg/client/quotasubtree/clientset/versioned/fake/doc.go deleted file mode 100755 index 9b99e7167..000000000 --- a/pkg/client/quotasubtree/clientset/versioned/fake/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -// This package has the automatically generated fake clientset. -package fake diff --git a/pkg/client/quotasubtree/clientset/versioned/fake/register.go b/pkg/client/quotasubtree/clientset/versioned/fake/register.go deleted file mode 100755 index 433c12c9a..000000000 --- a/pkg/client/quotasubtree/clientset/versioned/fake/register.go +++ /dev/null @@ -1,56 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - schema "k8s.io/apimachinery/pkg/runtime/schema" - serializer "k8s.io/apimachinery/pkg/runtime/serializer" - utilruntime "k8s.io/apimachinery/pkg/util/runtime" - quotasubtreev1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/quotaplugins/quotasubtree/v1" -) - -var scheme = runtime.NewScheme() -var codecs = serializer.NewCodecFactory(scheme) - -var localSchemeBuilder = runtime.SchemeBuilder{ - quotasubtreev1.AddToScheme, -} - -// AddToScheme adds all types of this clientset into the given scheme. This allows composition -// of clientsets, like in: -// -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) -// -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) -// -// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types -// correctly. -var AddToScheme = localSchemeBuilder.AddToScheme - -func init() { - v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"}) - utilruntime.Must(AddToScheme(scheme)) -} diff --git a/pkg/client/quotasubtree/clientset/versioned/scheme/doc.go b/pkg/client/quotasubtree/clientset/versioned/scheme/doc.go deleted file mode 100755 index 7dc375616..000000000 --- a/pkg/client/quotasubtree/clientset/versioned/scheme/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -// This package contains the scheme of the automatically generated clientset. -package scheme diff --git a/pkg/client/quotasubtree/clientset/versioned/scheme/register.go b/pkg/client/quotasubtree/clientset/versioned/scheme/register.go deleted file mode 100755 index ce0f5c042..000000000 --- a/pkg/client/quotasubtree/clientset/versioned/scheme/register.go +++ /dev/null @@ -1,56 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package scheme - -import ( - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - schema "k8s.io/apimachinery/pkg/runtime/schema" - serializer "k8s.io/apimachinery/pkg/runtime/serializer" - utilruntime "k8s.io/apimachinery/pkg/util/runtime" - quotasubtreev1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/quotaplugins/quotasubtree/v1" -) - -var Scheme = runtime.NewScheme() -var Codecs = serializer.NewCodecFactory(Scheme) -var ParameterCodec = runtime.NewParameterCodec(Scheme) -var localSchemeBuilder = runtime.SchemeBuilder{ - quotasubtreev1.AddToScheme, -} - -// AddToScheme adds all types of this clientset into the given scheme. This allows composition -// of clientsets, like in: -// -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) -// -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) -// -// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types -// correctly. -var AddToScheme = localSchemeBuilder.AddToScheme - -func init() { - v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) - utilruntime.Must(AddToScheme(Scheme)) -} diff --git a/pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/doc.go b/pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/doc.go deleted file mode 100755 index 09c6457f1..000000000 --- a/pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/doc.go +++ /dev/null @@ -1,24 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -// Deprecated: quotasubtree has been replaced by the versioned as that package is generated using the client gen tool. -// quotasubtree interfaces and methods should not be used except for compatibility. It will be removed in future versions. -// -// This package is frozen and no new functionality will be added. - -// Code generated by client-gen. DO NOT EDIT. - -// This package has the automatically generated typed clients. -package v1 diff --git a/pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/fake/doc.go b/pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/fake/doc.go deleted file mode 100755 index 16f443990..000000000 --- a/pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/fake/doc.go +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -// Package fake has the automatically generated clients. -package fake diff --git a/pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/fake/fake_quotasubtree.go b/pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/fake/fake_quotasubtree.go deleted file mode 100755 index df8dea1b4..000000000 --- a/pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/fake/fake_quotasubtree.go +++ /dev/null @@ -1,142 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - "context" - - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" - quotasubtreev1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/quotaplugins/quotasubtree/v1" -) - -// FakeQuotaSubtrees implements QuotaSubtreeInterface -type FakeQuotaSubtrees struct { - Fake *FakeQuotasubtreeV1 - ns string -} - -var quotasubtreesResource = schema.GroupVersionResource{Group: "quotasubtree", Version: "v1", Resource: "quotasubtrees"} - -var quotasubtreesKind = schema.GroupVersionKind{Group: "quotasubtree", Version: "v1", Kind: "QuotaSubtree"} - -// Get takes name of the quotaSubtree, and returns the corresponding quotaSubtree object, and an error if there is any. -func (c *FakeQuotaSubtrees) Get(ctx context.Context, name string, options v1.GetOptions) (result *quotasubtreev1.QuotaSubtree, err error) { - obj, err := c.Fake. - Invokes(testing.NewGetAction(quotasubtreesResource, c.ns, name), "asubtreev1.QuotaSubtree{}) - - if obj == nil { - return nil, err - } - return obj.(*quotasubtreev1.QuotaSubtree), err -} - -// List takes label and field selectors, and returns the list of QuotaSubtrees that match those selectors. -func (c *FakeQuotaSubtrees) List(ctx context.Context, opts v1.ListOptions) (result *quotasubtreev1.QuotaSubtreeList, err error) { - obj, err := c.Fake. - Invokes(testing.NewListAction(quotasubtreesResource, quotasubtreesKind, c.ns, opts), "asubtreev1.QuotaSubtreeList{}) - - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := "asubtreev1.QuotaSubtreeList{ListMeta: obj.(*quotasubtreev1.QuotaSubtreeList).ListMeta} - for _, item := range obj.(*quotasubtreev1.QuotaSubtreeList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested quotaSubtrees. -func (c *FakeQuotaSubtrees) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewWatchAction(quotasubtreesResource, c.ns, opts)) - -} - -// Create takes the representation of a quotaSubtree and creates it. Returns the server's representation of the quotaSubtree, and an error, if there is any. -func (c *FakeQuotaSubtrees) Create(ctx context.Context, quotaSubtree *quotasubtreev1.QuotaSubtree, opts v1.CreateOptions) (result *quotasubtreev1.QuotaSubtree, err error) { - obj, err := c.Fake. - Invokes(testing.NewCreateAction(quotasubtreesResource, c.ns, quotaSubtree), "asubtreev1.QuotaSubtree{}) - - if obj == nil { - return nil, err - } - return obj.(*quotasubtreev1.QuotaSubtree), err -} - -// Update takes the representation of a quotaSubtree and updates it. Returns the server's representation of the quotaSubtree, and an error, if there is any. -func (c *FakeQuotaSubtrees) Update(ctx context.Context, quotaSubtree *quotasubtreev1.QuotaSubtree, opts v1.UpdateOptions) (result *quotasubtreev1.QuotaSubtree, err error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateAction(quotasubtreesResource, c.ns, quotaSubtree), "asubtreev1.QuotaSubtree{}) - - if obj == nil { - return nil, err - } - return obj.(*quotasubtreev1.QuotaSubtree), err -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeQuotaSubtrees) UpdateStatus(ctx context.Context, quotaSubtree *quotasubtreev1.QuotaSubtree, opts v1.UpdateOptions) (*quotasubtreev1.QuotaSubtree, error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(quotasubtreesResource, "status", c.ns, quotaSubtree), "asubtreev1.QuotaSubtree{}) - - if obj == nil { - return nil, err - } - return obj.(*quotasubtreev1.QuotaSubtree), err -} - -// Delete takes name of the quotaSubtree and deletes it. Returns an error if one occurs. -func (c *FakeQuotaSubtrees) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewDeleteAction(quotasubtreesResource, c.ns, name), "asubtreev1.QuotaSubtree{}) - - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeQuotaSubtrees) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(quotasubtreesResource, c.ns, listOpts) - - _, err := c.Fake.Invokes(action, "asubtreev1.QuotaSubtreeList{}) - return err -} - -// Patch applies the patch and returns the patched quotaSubtree. -func (c *FakeQuotaSubtrees) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *quotasubtreev1.QuotaSubtree, err error) { - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(quotasubtreesResource, c.ns, name, pt, data, subresources...), "asubtreev1.QuotaSubtree{}) - - if obj == nil { - return nil, err - } - return obj.(*quotasubtreev1.QuotaSubtree), err -} diff --git a/pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/fake/fake_quotasubtree_client.go b/pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/fake/fake_quotasubtree_client.go deleted file mode 100755 index da61491d5..000000000 --- a/pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/fake/fake_quotasubtree_client.go +++ /dev/null @@ -1,41 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - rest "k8s.io/client-go/rest" - testing "k8s.io/client-go/testing" - v1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1" - -) - -type FakeQuotasubtreeV1 struct { - *testing.Fake -} - -func (c *FakeQuotasubtreeV1) QuotaSubtrees(namespace string) v1.QuotaSubtreeInterface { - return &FakeQuotaSubtrees{c, namespace} -} - -// RESTClient returns a RESTClient that is used to communicate -// with API server by this client implementation. -func (c *FakeQuotasubtreeV1) RESTClient() rest.Interface { - var ret *rest.RESTClient - return ret -} diff --git a/pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/generated_expansion.go b/pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/generated_expansion.go deleted file mode 100755 index 4505b3f9a..000000000 --- a/pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/generated_expansion.go +++ /dev/null @@ -1,21 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1 - -type QuotaSubtreeExpansion interface{} diff --git a/pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/quotasubtree.go b/pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/quotasubtree.go deleted file mode 100755 index 2f06c18bc..000000000 --- a/pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/quotasubtree.go +++ /dev/null @@ -1,195 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1 - -import ( - "context" - "time" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" - v1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/quotaplugins/quotasubtree/v1" - scheme "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/quotasubtree/clientset/versioned/scheme" -) - -// QuotaSubtreesGetter has a method to return a QuotaSubtreeInterface. -// A group's client should implement this interface. -type QuotaSubtreesGetter interface { - QuotaSubtrees(namespace string) QuotaSubtreeInterface -} - -// QuotaSubtreeInterface has methods to work with QuotaSubtree resources. -type QuotaSubtreeInterface interface { - Create(ctx context.Context, quotaSubtree *v1.QuotaSubtree, opts metav1.CreateOptions) (*v1.QuotaSubtree, error) - Update(ctx context.Context, quotaSubtree *v1.QuotaSubtree, opts metav1.UpdateOptions) (*v1.QuotaSubtree, error) - UpdateStatus(ctx context.Context, quotaSubtree *v1.QuotaSubtree, opts metav1.UpdateOptions) (*v1.QuotaSubtree, error) - Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error - DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error - Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.QuotaSubtree, error) - List(ctx context.Context, opts metav1.ListOptions) (*v1.QuotaSubtreeList, error) - Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.QuotaSubtree, err error) - QuotaSubtreeExpansion -} - -// quotaSubtrees implements QuotaSubtreeInterface -type quotaSubtrees struct { - client rest.Interface - ns string -} - -// newQuotaSubtrees returns a QuotaSubtrees -func newQuotaSubtrees(c *QuotasubtreeV1Client, namespace string) *quotaSubtrees { - return "aSubtrees{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the quotaSubtree, and returns the corresponding quotaSubtree object, and an error if there is any. -func (c *quotaSubtrees) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.QuotaSubtree, err error) { - result = &v1.QuotaSubtree{} - err = c.client.Get(). - Namespace(c.ns). - Resource("quotasubtrees"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of QuotaSubtrees that match those selectors. -func (c *quotaSubtrees) List(ctx context.Context, opts metav1.ListOptions) (result *v1.QuotaSubtreeList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1.QuotaSubtreeList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("quotasubtrees"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested quotaSubtrees. -func (c *quotaSubtrees) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("quotasubtrees"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a quotaSubtree and creates it. Returns the server's representation of the quotaSubtree, and an error, if there is any. -func (c *quotaSubtrees) Create(ctx context.Context, quotaSubtree *v1.QuotaSubtree, opts metav1.CreateOptions) (result *v1.QuotaSubtree, err error) { - result = &v1.QuotaSubtree{} - err = c.client.Post(). - Namespace(c.ns). - Resource("quotasubtrees"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(quotaSubtree). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a quotaSubtree and updates it. Returns the server's representation of the quotaSubtree, and an error, if there is any. -func (c *quotaSubtrees) Update(ctx context.Context, quotaSubtree *v1.QuotaSubtree, opts metav1.UpdateOptions) (result *v1.QuotaSubtree, err error) { - result = &v1.QuotaSubtree{} - err = c.client.Put(). - Namespace(c.ns). - Resource("quotasubtrees"). - Name(quotaSubtree.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(quotaSubtree). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *quotaSubtrees) UpdateStatus(ctx context.Context, quotaSubtree *v1.QuotaSubtree, opts metav1.UpdateOptions) (result *v1.QuotaSubtree, err error) { - result = &v1.QuotaSubtree{} - err = c.client.Put(). - Namespace(c.ns). - Resource("quotasubtrees"). - Name(quotaSubtree.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(quotaSubtree). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the quotaSubtree and deletes it. Returns an error if one occurs. -func (c *quotaSubtrees) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("quotasubtrees"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *quotaSubtrees) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("quotasubtrees"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched quotaSubtree. -func (c *quotaSubtrees) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.QuotaSubtree, err error) { - result = &v1.QuotaSubtree{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("quotasubtrees"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/quotasubtree_client.go b/pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/quotasubtree_client.go deleted file mode 100755 index 626d1d16d..000000000 --- a/pkg/client/quotasubtree/clientset/versioned/typed/quotasubtree/v1/quotasubtree_client.go +++ /dev/null @@ -1,89 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1 - -import ( - rest "k8s.io/client-go/rest" - v1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/quotaplugins/quotasubtree/v1" - "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/quotasubtree/clientset/versioned/scheme" -) - -type QuotaSubtreeV1Interface interface { - RESTClient() rest.Interface - QuotaSubtreesGetter -} - -// QuotasubtreeV1Client is used to interact with features provided by the quotasubtree group. -type QuotasubtreeV1Client struct { - restClient rest.Interface -} - -func (c *QuotasubtreeV1Client) QuotaSubtrees(namespace string) QuotaSubtreeInterface { - return newQuotaSubtrees(c, namespace) -} - -// NewForConfig creates a new QuotasubtreeV1Client for the given config. -func NewForConfig(c *rest.Config) (*QuotasubtreeV1Client, error) { - config := *c - if err := setConfigDefaults(&config); err != nil { - return nil, err - } - client, err := rest.RESTClientFor(&config) - if err != nil { - return nil, err - } - return &QuotasubtreeV1Client{client}, nil -} - -// NewForConfigOrDie creates a new QuotasubtreeV1Client for the given config and -// panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) (*QuotasubtreeV1Client, error) { - client, err := NewForConfig(c) - if err != nil { - return nil, err - } - return client, err -} - -// New creates a new QuotasubtreeV1Client for the given RESTClient. -func New(c rest.Interface) *QuotasubtreeV1Client { - return &QuotasubtreeV1Client{c} -} - -func setConfigDefaults(config *rest.Config) error { - gv := v1.SchemeGroupVersion - config.GroupVersion = &gv - config.APIPath = "/apis" - config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() - - if config.UserAgent == "" { - config.UserAgent = rest.DefaultKubernetesUserAgent() - } - - return nil -} - -// RESTClient returns a RESTClient that is used to communicate -// with API server by this client implementation. -func (c *QuotasubtreeV1Client) RESTClient() rest.Interface { - if c == nil { - return nil - } - return c.restClient -} diff --git a/pkg/client/quotasubtree/doc.go b/pkg/client/quotasubtree/doc.go deleted file mode 100644 index 6d75274f6..000000000 --- a/pkg/client/quotasubtree/doc.go +++ /dev/null @@ -1,5 +0,0 @@ -// Deprecated: quotasubtree has been replaced by the versioned as that package is generated using the client gen tool. -// quotasubtree interfaces and methods should not be used except for compatibility. It will be removed in future versions. -// -// This package is frozen and no new functionality will be added. -package quotasubtree diff --git a/pkg/client/quotasubtree/informers/externalversions/doc.go b/pkg/client/quotasubtree/informers/externalversions/doc.go deleted file mode 100755 index d083a818a..000000000 --- a/pkg/client/quotasubtree/informers/externalversions/doc.go +++ /dev/null @@ -1,24 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -// Deprecated: quotasubtree has been replaced by the versioned as that package is generated using the client gen tool. -// quotasubtree interfaces and methods should not be used except for compatibility. It will be removed in future versions. -// -// This package is frozen and no new functionality will be added. - -// Code generated by client-gen. DO NOT EDIT. - -// This package has the automatically generated typed clients. -package externalversions diff --git a/pkg/client/quotasubtree/informers/externalversions/factory.go b/pkg/client/quotasubtree/informers/externalversions/factory.go deleted file mode 100755 index 0923eba3b..000000000 --- a/pkg/client/quotasubtree/informers/externalversions/factory.go +++ /dev/null @@ -1,180 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by informer-gen. DO NOT EDIT. - -package externalversions - -import ( - reflect "reflect" - sync "sync" - time "time" - - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - schema "k8s.io/apimachinery/pkg/runtime/schema" - cache "k8s.io/client-go/tools/cache" - versioned "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/quotasubtree/clientset/versioned" - internalinterfaces "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/quotasubtree/informers/externalversions/internalinterfaces" - quotasubtree "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/quotasubtree/informers/externalversions/quotasubtree" -) - -// SharedInformerOption defines the functional option type for SharedInformerFactory. -type SharedInformerOption func(*sharedInformerFactory) *sharedInformerFactory - -type sharedInformerFactory struct { - client versioned.Interface - namespace string - tweakListOptions internalinterfaces.TweakListOptionsFunc - lock sync.Mutex - defaultResync time.Duration - customResync map[reflect.Type]time.Duration - - informers map[reflect.Type]cache.SharedIndexInformer - // startedInformers is used for tracking which informers have been started. - // This allows Start() to be called multiple times safely. - startedInformers map[reflect.Type]bool -} - -// WithCustomResyncConfig sets a custom resync period for the specified informer types. -func WithCustomResyncConfig(resyncConfig map[v1.Object]time.Duration) SharedInformerOption { - return func(factory *sharedInformerFactory) *sharedInformerFactory { - for k, v := range resyncConfig { - factory.customResync[reflect.TypeOf(k)] = v - } - return factory - } -} - -// WithTweakListOptions sets a custom filter on all listers of the configured SharedInformerFactory. -func WithTweakListOptions(tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerOption { - return func(factory *sharedInformerFactory) *sharedInformerFactory { - factory.tweakListOptions = tweakListOptions - return factory - } -} - -// WithNamespace limits the SharedInformerFactory to the specified namespace. -func WithNamespace(namespace string) SharedInformerOption { - return func(factory *sharedInformerFactory) *sharedInformerFactory { - factory.namespace = namespace - return factory - } -} - -// NewSharedInformerFactory constructs a new instance of sharedInformerFactory for all namespaces. -func NewSharedInformerFactory(client versioned.Interface, defaultResync time.Duration) SharedInformerFactory { - return NewSharedInformerFactoryWithOptions(client, defaultResync) -} - -// NewFilteredSharedInformerFactory constructs a new instance of sharedInformerFactory. -// Listers obtained via this SharedInformerFactory will be subject to the same filters -// as specified here. -// Deprecated: Please use NewSharedInformerFactoryWithOptions instead -func NewFilteredSharedInformerFactory(client versioned.Interface, defaultResync time.Duration, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) SharedInformerFactory { - return NewSharedInformerFactoryWithOptions(client, defaultResync, WithNamespace(namespace), WithTweakListOptions(tweakListOptions)) -} - -// NewSharedInformerFactoryWithOptions constructs a new instance of a SharedInformerFactory with additional options. -func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResync time.Duration, options ...SharedInformerOption) SharedInformerFactory { - factory := &sharedInformerFactory{ - client: client, - namespace: v1.NamespaceAll, - defaultResync: defaultResync, - informers: make(map[reflect.Type]cache.SharedIndexInformer), - startedInformers: make(map[reflect.Type]bool), - customResync: make(map[reflect.Type]time.Duration), - } - - // Apply all options - for _, opt := range options { - factory = opt(factory) - } - - return factory -} - -// Start initializes all requested informers. -func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { - f.lock.Lock() - defer f.lock.Unlock() - - for informerType, informer := range f.informers { - if !f.startedInformers[informerType] { - go informer.Run(stopCh) - f.startedInformers[informerType] = true - } - } -} - -// WaitForCacheSync waits for all started informers' cache were synced. -func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool { - informers := func() map[reflect.Type]cache.SharedIndexInformer { - f.lock.Lock() - defer f.lock.Unlock() - - informers := map[reflect.Type]cache.SharedIndexInformer{} - for informerType, informer := range f.informers { - if f.startedInformers[informerType] { - informers[informerType] = informer - } - } - return informers - }() - - res := map[reflect.Type]bool{} - for informType, informer := range informers { - res[informType] = cache.WaitForCacheSync(stopCh, informer.HasSynced) - } - return res -} - -// InternalInformerFor returns the SharedIndexInformer for obj using an internal -// client. -func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer { - f.lock.Lock() - defer f.lock.Unlock() - - informerType := reflect.TypeOf(obj) - informer, exists := f.informers[informerType] - if exists { - return informer - } - - resyncPeriod, exists := f.customResync[informerType] - if !exists { - resyncPeriod = f.defaultResync - } - - informer = newFunc(f.client, resyncPeriod) - f.informers[informerType] = informer - - return informer -} - -// SharedInformerFactory provides shared informers for resources in all known -// API group versions. -type SharedInformerFactory interface { - internalinterfaces.SharedInformerFactory - ForResource(resource schema.GroupVersionResource) (GenericInformer, error) - WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool - - Quotasubtree() quotasubtree.Interface -} - -func (f *sharedInformerFactory) Quotasubtree() quotasubtree.Interface { - return quotasubtree.New(f, f.namespace, f.tweakListOptions) -} diff --git a/pkg/client/quotasubtree/informers/externalversions/generic.go b/pkg/client/quotasubtree/informers/externalversions/generic.go deleted file mode 100755 index 6809177ce..000000000 --- a/pkg/client/quotasubtree/informers/externalversions/generic.go +++ /dev/null @@ -1,62 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by informer-gen. DO NOT EDIT. - -package externalversions - -import ( - "fmt" - - schema "k8s.io/apimachinery/pkg/runtime/schema" - cache "k8s.io/client-go/tools/cache" - v1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/quotaplugins/quotasubtree/v1" -) - -// GenericInformer is type of SharedIndexInformer which will locate and delegate to other -// sharedInformers based on type -type GenericInformer interface { - Informer() cache.SharedIndexInformer - Lister() cache.GenericLister -} - -type genericInformer struct { - informer cache.SharedIndexInformer - resource schema.GroupResource -} - -// Informer returns the SharedIndexInformer. -func (f *genericInformer) Informer() cache.SharedIndexInformer { - return f.informer -} - -// Lister returns the GenericLister. -func (f *genericInformer) Lister() cache.GenericLister { - return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) -} - -// ForResource gives generic access to a shared informer of the matching type -// TODO extend this to unknown resources with a client pool -func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { - switch resource { - // Group=quotasubtree, Version=v1 - case v1.SchemeGroupVersion.WithResource("quotasubtrees"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Quotasubtree().V1().QuotaSubtrees().Informer()}, nil - - } - - return nil, fmt.Errorf("no informer found for %v", resource) -} diff --git a/pkg/client/quotasubtree/informers/externalversions/internalinterfaces/factory_interfaces.go b/pkg/client/quotasubtree/informers/externalversions/internalinterfaces/factory_interfaces.go deleted file mode 100755 index 88a577ca8..000000000 --- a/pkg/client/quotasubtree/informers/externalversions/internalinterfaces/factory_interfaces.go +++ /dev/null @@ -1,40 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by informer-gen. DO NOT EDIT. - -package internalinterfaces - -import ( - time "time" - - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - cache "k8s.io/client-go/tools/cache" - versioned "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/quotasubtree/clientset/versioned" -) - -// NewInformerFunc takes versioned.Interface and time.Duration to return a SharedIndexInformer. -type NewInformerFunc func(versioned.Interface, time.Duration) cache.SharedIndexInformer - -// SharedInformerFactory a small interface to allow for adding an informer without an import cycle -type SharedInformerFactory interface { - Start(stopCh <-chan struct{}) - InformerFor(obj runtime.Object, newFunc NewInformerFunc) cache.SharedIndexInformer -} - -// TweakListOptionsFunc is a function that transforms a v1.ListOptions. -type TweakListOptionsFunc func(*v1.ListOptions) diff --git a/pkg/client/quotasubtree/informers/externalversions/quotasubtree/interface.go b/pkg/client/quotasubtree/informers/externalversions/quotasubtree/interface.go deleted file mode 100755 index 02ca19aac..000000000 --- a/pkg/client/quotasubtree/informers/externalversions/quotasubtree/interface.go +++ /dev/null @@ -1,46 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by informer-gen. DO NOT EDIT. - -package quotasubtree - -import ( - internalinterfaces "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/quotasubtree/informers/externalversions/internalinterfaces" - v1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/quotasubtree/informers/externalversions/quotasubtree/v1" -) - -// Interface provides access to each of this group's versions. -type Interface interface { - // V1 provides access to shared informers for resources in V1. - V1() v1.Interface -} - -type group struct { - factory internalinterfaces.SharedInformerFactory - namespace string - tweakListOptions internalinterfaces.TweakListOptionsFunc -} - -// New returns a new Interface. -func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { - return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} -} - -// V1 returns a new v1.Interface. -func (g *group) V1() v1.Interface { - return v1.New(g.factory, g.namespace, g.tweakListOptions) -} diff --git a/pkg/client/quotasubtree/informers/externalversions/quotasubtree/v1/doc.go b/pkg/client/quotasubtree/informers/externalversions/quotasubtree/v1/doc.go deleted file mode 100755 index 09c6457f1..000000000 --- a/pkg/client/quotasubtree/informers/externalversions/quotasubtree/v1/doc.go +++ /dev/null @@ -1,24 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -// Deprecated: quotasubtree has been replaced by the versioned as that package is generated using the client gen tool. -// quotasubtree interfaces and methods should not be used except for compatibility. It will be removed in future versions. -// -// This package is frozen and no new functionality will be added. - -// Code generated by client-gen. DO NOT EDIT. - -// This package has the automatically generated typed clients. -package v1 diff --git a/pkg/client/quotasubtree/informers/externalversions/quotasubtree/v1/interface.go b/pkg/client/quotasubtree/informers/externalversions/quotasubtree/v1/interface.go deleted file mode 100755 index 6fae598d6..000000000 --- a/pkg/client/quotasubtree/informers/externalversions/quotasubtree/v1/interface.go +++ /dev/null @@ -1,45 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by informer-gen. DO NOT EDIT. - -package v1 - -import ( - internalinterfaces "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/quotasubtree/informers/externalversions/internalinterfaces" -) - -// Interface provides access to all the informers in this group version. -type Interface interface { - // QuotaSubtrees returns a QuotaSubtreeInformer. - QuotaSubtrees() QuotaSubtreeInformer -} - -type version struct { - factory internalinterfaces.SharedInformerFactory - namespace string - tweakListOptions internalinterfaces.TweakListOptionsFunc -} - -// New returns a new Interface. -func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { - return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} -} - -// QuotaSubtrees returns a QuotaSubtreeInformer. -func (v *version) QuotaSubtrees() QuotaSubtreeInformer { - return "aSubtreeInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} -} diff --git a/pkg/client/quotasubtree/informers/externalversions/quotasubtree/v1/quotasubtree.go b/pkg/client/quotasubtree/informers/externalversions/quotasubtree/v1/quotasubtree.go deleted file mode 100755 index 9712089f5..000000000 --- a/pkg/client/quotasubtree/informers/externalversions/quotasubtree/v1/quotasubtree.go +++ /dev/null @@ -1,90 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by informer-gen. DO NOT EDIT. - -package v1 - -import ( - "context" - time "time" - - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - watch "k8s.io/apimachinery/pkg/watch" - cache "k8s.io/client-go/tools/cache" - quotasubtreev1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/quotaplugins/quotasubtree/v1" - versioned "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/quotasubtree/clientset/versioned" - internalinterfaces "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/quotasubtree/informers/externalversions/internalinterfaces" - v1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/quotasubtree/listers/quotasubtree/v1" -) - -// QuotaSubtreeInformer provides access to a shared informer and lister for -// QuotaSubtrees. -type QuotaSubtreeInformer interface { - Informer() cache.SharedIndexInformer - Lister() v1.QuotaSubtreeLister -} - -type quotaSubtreeInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc - namespace string -} - -// NewQuotaSubtreeInformer constructs a new informer for QuotaSubtree type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewQuotaSubtreeInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredQuotaSubtreeInformer(client, namespace, resyncPeriod, indexers, nil) -} - -// NewFilteredQuotaSubtreeInformer constructs a new informer for QuotaSubtree type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewFilteredQuotaSubtreeInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { - return cache.NewSharedIndexInformer( - &cache.ListWatch{ - ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.QuotasubtreeV1().QuotaSubtrees(namespace).List(context.TODO(), options) - }, - WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.QuotasubtreeV1().QuotaSubtrees(namespace).Watch(context.TODO(), options) - }, - }, - "asubtreev1.QuotaSubtree{}, - resyncPeriod, - indexers, - ) -} - -func (f *quotaSubtreeInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredQuotaSubtreeInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) -} - -func (f *quotaSubtreeInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor("asubtreev1.QuotaSubtree{}, f.defaultInformer) -} - -func (f *quotaSubtreeInformer) Lister() v1.QuotaSubtreeLister { - return v1.NewQuotaSubtreeLister(f.Informer().GetIndexer()) -} diff --git a/pkg/client/quotasubtree/listers/quotasubtree/v1/doc.go b/pkg/client/quotasubtree/listers/quotasubtree/v1/doc.go deleted file mode 100755 index 09c6457f1..000000000 --- a/pkg/client/quotasubtree/listers/quotasubtree/v1/doc.go +++ /dev/null @@ -1,24 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -// Deprecated: quotasubtree has been replaced by the versioned as that package is generated using the client gen tool. -// quotasubtree interfaces and methods should not be used except for compatibility. It will be removed in future versions. -// -// This package is frozen and no new functionality will be added. - -// Code generated by client-gen. DO NOT EDIT. - -// This package has the automatically generated typed clients. -package v1 diff --git a/pkg/client/quotasubtree/listers/quotasubtree/v1/expansion_generated.go b/pkg/client/quotasubtree/listers/quotasubtree/v1/expansion_generated.go deleted file mode 100755 index 7e71ef385..000000000 --- a/pkg/client/quotasubtree/listers/quotasubtree/v1/expansion_generated.go +++ /dev/null @@ -1,27 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by lister-gen. DO NOT EDIT. - -package v1 - -// QuotaSubtreeListerExpansion allows custom methods to be added to -// QuotaSubtreeLister. -type QuotaSubtreeListerExpansion interface{} - -// QuotaSubtreeNamespaceListerExpansion allows custom methods to be added to -// QuotaSubtreeNamespaceLister. -type QuotaSubtreeNamespaceListerExpansion interface{} diff --git a/pkg/client/quotasubtree/listers/quotasubtree/v1/quotasubtree.go b/pkg/client/quotasubtree/listers/quotasubtree/v1/quotasubtree.go deleted file mode 100755 index 227d6adca..000000000 --- a/pkg/client/quotasubtree/listers/quotasubtree/v1/quotasubtree.go +++ /dev/null @@ -1,99 +0,0 @@ -/* -Copyright The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by lister-gen. DO NOT EDIT. - -package v1 - -import ( - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/tools/cache" - v1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/quotaplugins/quotasubtree/v1" -) - -// QuotaSubtreeLister helps list QuotaSubtrees. -// All objects returned here must be treated as read-only. -type QuotaSubtreeLister interface { - // List lists all QuotaSubtrees in the indexer. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1.QuotaSubtree, err error) - // QuotaSubtrees returns an object that can list and get QuotaSubtrees. - QuotaSubtrees(namespace string) QuotaSubtreeNamespaceLister - QuotaSubtreeListerExpansion -} - -// quotaSubtreeLister implements the QuotaSubtreeLister interface. -type quotaSubtreeLister struct { - indexer cache.Indexer -} - -// NewQuotaSubtreeLister returns a new QuotaSubtreeLister. -func NewQuotaSubtreeLister(indexer cache.Indexer) QuotaSubtreeLister { - return "aSubtreeLister{indexer: indexer} -} - -// List lists all QuotaSubtrees in the indexer. -func (s *quotaSubtreeLister) List(selector labels.Selector) (ret []*v1.QuotaSubtree, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1.QuotaSubtree)) - }) - return ret, err -} - -// QuotaSubtrees returns an object that can list and get QuotaSubtrees. -func (s *quotaSubtreeLister) QuotaSubtrees(namespace string) QuotaSubtreeNamespaceLister { - return quotaSubtreeNamespaceLister{indexer: s.indexer, namespace: namespace} -} - -// QuotaSubtreeNamespaceLister helps list and get QuotaSubtrees. -// All objects returned here must be treated as read-only. -type QuotaSubtreeNamespaceLister interface { - // List lists all QuotaSubtrees in the indexer for a given namespace. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1.QuotaSubtree, err error) - // Get retrieves the QuotaSubtree from the indexer for a given namespace and name. - // Objects returned here must be treated as read-only. - Get(name string) (*v1.QuotaSubtree, error) - QuotaSubtreeNamespaceListerExpansion -} - -// quotaSubtreeNamespaceLister implements the QuotaSubtreeNamespaceLister -// interface. -type quotaSubtreeNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all QuotaSubtrees in the indexer for a given namespace. -func (s quotaSubtreeNamespaceLister) List(selector labels.Selector) (ret []*v1.QuotaSubtree, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1.QuotaSubtree)) - }) - return ret, err -} - -// Get retrieves the QuotaSubtree from the indexer for a given namespace and name. -func (s quotaSubtreeNamespaceLister) Get(name string) (*v1.QuotaSubtree, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1.Resource("quotasubtree"), name) - } - return obj.(*v1.QuotaSubtree), nil -} diff --git a/pkg/controller/queuejob/queuejob_controller_ex.go b/pkg/controller/queuejob/queuejob_controller_ex.go index 6ffbfb220..8f1a71f8e 100644 --- a/pkg/controller/queuejob/queuejob_controller_ex.go +++ b/pkg/controller/queuejob/queuejob_controller_ex.go @@ -190,7 +190,7 @@ func NewJobController(config *rest.Config, serverOption *options.ServerOption) * appWrapperClient, err := clientset.NewForConfig(cc.config) if err != nil { - klog.Fatalf("Could not instantiate k8s client") + klog.Fatalf("Could not instantiate k8s client, err=%v", err) } cc.appwrapperInformer = informerFactory.NewSharedInformerFactory(appWrapperClient, 0).Mcad().V1beta1().AppWrappers() cc.appwrapperInformer.Informer().AddEventHandler( diff --git a/pkg/controller/queuejob/utils.go b/pkg/controller/queuejob/utils.go index 750010814..7468d14cf 100644 --- a/pkg/controller/queuejob/utils.go +++ b/pkg/controller/queuejob/utils.go @@ -42,7 +42,7 @@ import ( "k8s.io/client-go/rest" arbv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" - "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/controller-versioned/clients" + "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client" ) var queueJobKind = arbv1.SchemeGroupVersion.WithKind("QueueJob") @@ -157,7 +157,7 @@ func createQueueJobKind(config *rest.Config) error { if err != nil { return err } - _, err = clients.CreateQueueJobKind(extensionscs) + _, err = client.CreateQueueJobKind(extensionscs) if err != nil && !apierrors.IsAlreadyExists(err) { return err } @@ -169,7 +169,7 @@ func createAppWrapperKind(config *rest.Config) error { if err != nil { return err } - _, err = clients.CreateAppWrapperKind(extensionscs) + _, err = client.CreateAppWrapperKind(extensionscs) if err != nil && !apierrors.IsAlreadyExists(err) { return err } @@ -179,24 +179,24 @@ func createAppWrapperKind(config *rest.Config) error { // AppWrapperCondition returns condition of a AppWrapper condition. func GenerateAppWrapperCondition(condType arbv1.AppWrapperConditionType, condStatus corev1.ConditionStatus, condReason string, condMsg string) arbv1.AppWrapperCondition { return arbv1.AppWrapperCondition{ - Type: condType, - Status: condStatus, - LastUpdateMicroTime: metav1.NowMicro(), + Type: condType, + Status: condStatus, + LastUpdateMicroTime: metav1.NowMicro(), LastTransitionMicroTime: metav1.NowMicro(), - Reason: condReason, - Message: condMsg, + Reason: condReason, + Message: condMsg, } } // AppWrapperCondition returns condition of a AppWrapper condition. func isLastConditionDuplicate(aw *arbv1.AppWrapper, condType arbv1.AppWrapperConditionType, condStatus corev1.ConditionStatus, condReason string, condMsg string) bool { - if (aw.Status.Conditions == nil) { + if aw.Status.Conditions == nil { return false } lastIndex := len(aw.Status.Conditions) - 1 - if (lastIndex < 0) { + if lastIndex < 0 { return false } diff --git a/pkg/controller/queuejobdispatch/queuejobagent.go b/pkg/controller/queuejobdispatch/queuejobagent.go index 213d80bf5..ad341cf39 100644 --- a/pkg/controller/queuejobdispatch/queuejobagent.go +++ b/pkg/controller/queuejobdispatch/queuejobagent.go @@ -25,22 +25,22 @@ import ( "time" arbv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" - clientset "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned" clusterstateapi "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/controller/clusterstate/api" v1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/resource" "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/clientcmd" "k8s.io/klog/v2" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - arbinformers "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/controller-externalversion" - informersv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/controller-externalversion/v1" - listersv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers/controller/v1" "k8s.io/client-go/tools/cache" - clients "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/controller-versioned/clients" + clientset "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned" + + informerFactory "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/externalversions" + arbinformers "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/informers/externalversions/controller/v1beta1" + arblisters "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers/controller/v1beta1" + _ "k8s.io/client-go/plugin/pkg/client/auth/oidc" ) @@ -51,8 +51,8 @@ type JobClusterAgent struct { k8sClients *kubernetes.Clientset // for the update of aggr resouces AggrResources *clusterstateapi.Resource - jobInformer informersv1.AppWrapperInformer - jobLister listersv1.AppWrapperLister + jobInformer arbinformers.AppWrapperInformer + jobLister arblisters.AppWrapperLister jobSynced func() bool agentEventQueue *cache.FIFO @@ -86,16 +86,16 @@ func NewJobClusterAgent(config string, agentEventQueue *cache.FIFO) *JobClusterA klog.V(2).Infof("[Dispatcher: Agent] %s: Create Clients Suceessfully\n", qa.AgentId) } - queueJobClientForInformer, _, err := clients.NewClient(agent_config) + appWrapperClient, err := clientset.NewForConfig(agent_config) if err != nil { - panic(err) + klog.Fatalf("Could not instantiate k8s client, err=%v", err) } - qa.jobInformer = arbinformers.NewFilteredSharedInformerFactory(queueJobClientForInformer, 0, + qa.jobInformer = informerFactory.NewFilteredSharedInformerFactory(appWrapperClient, 0, v1.NamespaceAll, func(opt *metav1.ListOptions) { opt.LabelSelector = "IsDispatched=true" }, - ).AppWrapper().AppWrappers() + ).Mcad().V1beta1().AppWrappers() qa.jobInformer.Informer().AddEventHandler( cache.FilteringResourceEventHandler{ FilterFunc: func(obj interface{}) bool { @@ -162,7 +162,6 @@ func (qa *JobClusterAgent) DeleteJob(ctx context.Context, cqj *arbv1.AppWrapper) qj_temp := cqj.DeepCopy() klog.V(2).Infof("[Dispatcher: Agent] Request deletion of XQJ %s to Agent %s\n", qj_temp.Name, qa.AgentId) qa.queuejobclients.McadV1beta1().AppWrappers(qj_temp.Namespace).Delete(ctx, qj_temp.Name, metav1.DeleteOptions{}) - return } func (qa *JobClusterAgent) CreateJob(ctx context.Context, cqj *arbv1.AppWrapper) { @@ -306,10 +305,3 @@ func getInt64String(num string) (int64, error) { } return validatedNum, err } - -func buildResource(cpu string, memory string) *clusterstateapi.Resource { - return clusterstateapi.NewResource(v1.ResourceList{ - v1.ResourceCPU: resource.MustParse(cpu), - v1.ResourceMemory: resource.MustParse(memory), - }) -} diff --git a/pkg/controller/queuejobresources/pod/pod.go b/pkg/controller/queuejobresources/pod/pod.go index da56aac19..d9bde095f 100644 --- a/pkg/controller/queuejobresources/pod/pod.go +++ b/pkg/controller/queuejobresources/pod/pod.go @@ -32,7 +32,7 @@ import ( "k8s.io/klog/v2" arbv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" - clientset "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/controller-versioned" + clientset "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned" clusterstateapi "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/controller/clusterstate/api" "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/controller/maputils" "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/controller/queuejobresources" From 630df6d108e4b86c809c1dbb9f06f4cd1cf6459b Mon Sep 17 00:00:00 2001 From: Laurentiu Bradin <109964136+z103cb@users.noreply.github.com> Date: Wed, 2 Aug 2023 12:06:50 +0300 Subject: [PATCH 5/5] Fixed compiler failures. --- .../quota-simple-rest/quota_rest_manager.go | 9 +- test/e2e/queue.go | 16 ++-- test/e2e/util.go | 92 ++++++++----------- 3 files changed, 54 insertions(+), 63 deletions(-) diff --git a/pkg/quotaplugins/quota-simple-rest/quota_rest_manager.go b/pkg/quotaplugins/quota-simple-rest/quota_rest_manager.go index 855ee1372..13ccab71e 100644 --- a/pkg/quotaplugins/quota-simple-rest/quota_rest_manager.go +++ b/pkg/quotaplugins/quota-simple-rest/quota_rest_manager.go @@ -26,7 +26,7 @@ import ( "github.com/project-codeflare/multi-cluster-app-dispatcher/cmd/kar-controllers/app/options" arbv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" - listersv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers/controller/v1" + listersv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/listers/controller/v1beta1" clusterstateapi "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/controller/clusterstate/api" "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/controller/quota" "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/quotaplugins/util" @@ -119,7 +119,7 @@ func createId(ns string, n string) string { func NewQuotaManager(dispatchedAWDemands map[string]*clusterstateapi.Resource, dispatchedAWs map[string]*arbv1.AppWrapper, awJobLister listersv1.AppWrapperLister, config *rest.Config, serverOptions *options.ServerOption) (*QuotaManager, error) { - if serverOptions.QuotaEnabled == false { + if !serverOptions.QuotaEnabled { klog.Infof("[NewQuotaManager] Quota management is not enabled.") return nil, nil } @@ -304,6 +304,11 @@ func (qm *QuotaManager) Fits(aw *arbv1.AppWrapper, awResDemands *clusterstateapi var preemptIds []*arbv1.AppWrapper klog.V(4).Infof("[Fits] Sending request: %v in buffer: %v, buffer size: %v, to uri: %s", req, buf, buf.Len(), uri) response, err := http.Post(uri, "application/json; charset=utf-8", buf) + if err != nil { + klog.Errorf("[Fits] Fail to add access quotaforestmanager: %s, err=%#v.", uri, err) + preemptIds = nil + return false, preemptIds, err.Error() + } defer response.Body.Close() dump, err := httputil.DumpResponse(response, true) klog.V(10).Infof("[getQuotaTreeIDs] POST Response dump: %q", dump) diff --git a/test/e2e/queue.go b/test/e2e/queue.go index 4f8fbc207..6a8387713 100644 --- a/test/e2e/queue.go +++ b/test/e2e/queue.go @@ -297,7 +297,7 @@ var _ = Describe("AppWrapper E2E Test", func() { Expect(err).NotTo(HaveOccurred()) pass := false for true { - aw1, err := context.karclient.ArbV1().AppWrappers(aw.Namespace).Get(aw.Name, metav1.GetOptions{}) + aw1, err := context.karclient.McadV1beta1().AppWrappers(aw.Namespace).Get(context.ctx, aw.Name, metav1.GetOptions{}) if err != nil { fmt.Fprint(GinkgoWriter, "Error getting status") } @@ -470,7 +470,7 @@ var _ = Describe("AppWrapper E2E Test", func() { // Make sure pods from AW aw-deployment-1-850-cpu have preempted var pass = false for true { - aw2Update, err := context.karclient.ArbV1().AppWrappers(aw2.Namespace).Get(aw2.Name, metav1.GetOptions{}) + aw2Update, err := context.karclient.McadV1beta1().AppWrappers(aw2.Namespace).Get(context.ctx, aw2.Name, metav1.GetOptions{}) if err != nil { fmt.Fprintf(GinkgoWriter, "[e2e] MCAD Scheduling Fail Fast Preemption Test - Error getting AW update %v", err) } @@ -557,7 +557,7 @@ var _ = Describe("AppWrapper E2E Test", func() { err1 := waitAWPodsReady(context, aw) Expect(err1).NotTo(HaveOccurred(), "Expecting pods to be ready for app wrapper: aw-test-jobtimeout-with-comp-1") time.Sleep(90 * time.Second) - aw1, err := context.karclient.ArbV1().AppWrappers(aw.Namespace).Get(aw.Name, metav1.GetOptions{}) + aw1, err := context.karclient.McadV1beta1().AppWrappers(aw.Namespace).Get(context.ctx, aw.Name, metav1.GetOptions{}) Expect(err).NotTo(HaveOccurred(), "Expecting no error when getting app wrapper status") fmt.Fprintf(GinkgoWriter, "[e2e] status of app wrapper: %v.\n", aw1.Status) Expect(aw1.Status.State).To(Equal(arbv1.AppWrapperStateFailed), "Expecting a failed state") @@ -575,7 +575,7 @@ var _ = Describe("AppWrapper E2E Test", func() { err1 := waitAWPodsReady(context, aw) Expect(err1).NotTo(HaveOccurred()) time.Sleep(1 * time.Minute) - aw1, err := context.karclient.ArbV1().AppWrappers(aw.Namespace).Get(aw.Name, metav1.GetOptions{}) + aw1, err := context.karclient.McadV1beta1().AppWrappers(aw.Namespace).Get(context.ctx, aw.Name, metav1.GetOptions{}) if err != nil { fmt.Fprintf(GinkgoWriter, "Error getting status, %v\n", err) } @@ -597,7 +597,7 @@ var _ = Describe("AppWrapper E2E Test", func() { err1 := waitAWPodsReady(context, aw) Expect(err1).NotTo(HaveOccurred(), "Expecting pods to be ready for app wrapper: 'aw-test-job-with-comp-ms-21'") time.Sleep(1 * time.Minute) - aw1, err := context.karclient.ArbV1().AppWrappers(aw.Namespace).Get(aw.Name, metav1.GetOptions{}) + aw1, err := context.karclient.McadV1beta1().AppWrappers(aw.Namespace).Get(context.ctx, aw.Name, metav1.GetOptions{}) Expect(err).NotTo(HaveOccurred(), "No error is expected when getting status") fmt.Fprintf(GinkgoWriter, "[e2e] MCAD Multi-Item Job Completion Test status of AW %v.\n", aw1.Status) Expect(aw1.Status.State).To(Equal(arbv1.AppWrapperStateCompleted), "Expecting a completed app wrapper status") @@ -655,7 +655,7 @@ var _ = Describe("AppWrapper E2E Test", func() { err1 := waitAWPodsReady(context, aw) Expect(err1).NotTo(HaveOccurred()) time.Sleep(1 * time.Minute) - aw1, err := context.karclient.ArbV1().AppWrappers(aw.Namespace).Get(aw.Name, metav1.GetOptions{}) + aw1, err := context.karclient.McadV1beta1().AppWrappers(aw.Namespace).Get(context.ctx, aw.Name, metav1.GetOptions{}) if err != nil { fmt.Fprintf(GinkgoWriter, "Error getting status, %v", err) } @@ -704,7 +704,7 @@ var _ = Describe("AppWrapper E2E Test", func() { time.Sleep(30 * time.Second) err1 := waitAWPodsReady(context, aw) Expect(err1).NotTo(HaveOccurred(), "Expecting pods to be ready for app wrapper: aw-deployment-rhc") - aw1, err := context.karclient.ArbV1().AppWrappers(aw.Namespace).Get(aw.Name, metav1.GetOptions{}) + aw1, err := context.karclient.McadV1beta1().AppWrappers(aw.Namespace).Get(context.ctx, aw.Name, metav1.GetOptions{}) Expect(err).NotTo(HaveOccurred(), "Expecting to get app wrapper status") fmt.Fprintf(GinkgoWriter, "[e2e] status of AW %v.\n", aw1.Status.State) Expect(aw1.Status.State).To(Equal(arbv1.AppWrapperStateRunningHoldCompletion)) @@ -722,7 +722,7 @@ var _ = Describe("AppWrapper E2E Test", func() { time.Sleep(1 * time.Minute) err1 := waitAWPodsReady(context, aw) Expect(err1).NotTo(HaveOccurred()) - aw1, err := context.karclient.ArbV1().AppWrappers(aw.Namespace).Get(aw.Name, metav1.GetOptions{}) + aw1, err := context.karclient.McadV1beta1().AppWrappers(aw.Namespace).Get(context.ctx, aw.Name, metav1.GetOptions{}) if err != nil { fmt.Fprintf(GinkgoWriter, "Error getting status, %v", err) } diff --git a/test/e2e/util.go b/test/e2e/util.go index 0e7a4050d..2bd566940 100644 --- a/test/e2e/util.go +++ b/test/e2e/util.go @@ -1,26 +1,11 @@ /* -Copyright 2017 The Kubernetes Authors. +Copyright 2019, 2021, 2022, 2023 The Multi-Cluster App Dispatcher Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -/* -Copyright 2019, 2021 The Multi-Cluster App Dispatcher Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -52,7 +37,7 @@ import ( "k8s.io/client-go/tools/clientcmd" arbv1 "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/apis/controller/v1beta1" - versioned "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/controller-versioned" + versioned "github.com/project-codeflare/multi-cluster-app-dispatcher/pkg/client/clientset/versioned" ) var ninetySeconds = 90 * time.Second @@ -78,6 +63,7 @@ type context struct { namespace string queues []string enableNamespaceAsQueue bool + ctx gcontext.Context } func initTestContext() *context { @@ -122,7 +108,7 @@ func initTestContext() *context { GlobalDefault: false, }, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) */ - + cxt.ctx = gcontext.Background() return cxt } @@ -261,7 +247,7 @@ func createGenericAWTimeoutWithStatus(context *context, name string) *arbv1.AppW }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper @@ -403,7 +389,7 @@ func awPodPhase(ctx *context, aw *arbv1.AppWrapper, phase []v1.PodPhase, taskNum return func() (bool, error) { defer GinkgoRecover() - aw, err := ctx.karclient.ArbV1().AppWrappers(aw.Namespace).Get(aw.Name, metav1.GetOptions{}) + aw, err := ctx.karclient.McadV1beta1().AppWrappers(aw.Namespace).Get(ctx.ctx, aw.Name, metav1.GetOptions{}) Expect(err).NotTo(HaveOccurred()) podList, err := ctx.kubeclient.CoreV1().Pods(aw.Namespace).List(gcontext.Background(), metav1.ListOptions{}) @@ -472,7 +458,7 @@ func waitAWNamespaceActive(ctx *context, aw *arbv1.AppWrapper) error { func awNamespacePhase(ctx *context, aw *arbv1.AppWrapper, phase []v1.NamespacePhase) wait.ConditionFunc { return func() (bool, error) { - aw, err := ctx.karclient.ArbV1().AppWrappers(aw.Namespace).Get(aw.Name, metav1.GetOptions{}) + aw, err := ctx.karclient.McadV1beta1().AppWrappers(aw.Namespace).Get(ctx.ctx, aw.Name, metav1.GetOptions{}) Expect(err).NotTo(HaveOccurred()) namespaces, err := ctx.kubeclient.CoreV1().Namespaces().List(gcontext.Background(), metav1.ListOptions{}) @@ -652,7 +638,7 @@ func createJobAWWithInitContainer(context *context, name string, requeuingTimeIn }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper @@ -723,7 +709,7 @@ func createDeploymentAW(context *context, name string) *arbv1.AppWrapper { }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper @@ -799,7 +785,7 @@ func createDeploymentAWwith550CPU(context *context, name string) *arbv1.AppWrapp }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper @@ -875,7 +861,7 @@ func createDeploymentAWwith350CPU(context *context, name string) *arbv1.AppWrapp }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper @@ -951,7 +937,7 @@ func createDeploymentAWwith426CPU(context *context, name string) *arbv1.AppWrapp }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper @@ -1027,7 +1013,7 @@ func createDeploymentAWwith425CPU(context *context, name string) *arbv1.AppWrapp }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper @@ -1099,7 +1085,7 @@ func createGenericDeploymentAW(context *context, name string) *arbv1.AppWrapper }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper @@ -1178,7 +1164,7 @@ func createGenericJobAWWithStatus(context *context, name string) *arbv1.AppWrapp }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper @@ -1308,7 +1294,7 @@ func createGenericJobAWWithMultipleStatus(context *context, name string) *arbv1. }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper @@ -1352,7 +1338,7 @@ func createAWGenericItemWithoutStatus(context *context, name string) *arbv1.AppW }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper @@ -1430,7 +1416,7 @@ func createGenericJobAWWithScheduleSpec(context *context, name string) *arbv1.Ap }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper @@ -1511,7 +1497,7 @@ func createGenericJobAWtWithLargeCompute(context *context, name string) *arbv1.A }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper @@ -1582,7 +1568,7 @@ func createGenericServiceAWWithNoStatus(context *context, name string) *arbv1.Ap }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper @@ -1714,7 +1700,7 @@ func createGenericDeploymentAWWithMultipleItems(context *context, name string) * }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper @@ -1792,7 +1778,7 @@ func createGenericDeploymentWithCPUAW(context *context, name string, cpuDemand s }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper @@ -1879,7 +1865,7 @@ func createGenericDeploymentCustomPodResourcesWithCPUAW(context *context, name s }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper @@ -1917,7 +1903,7 @@ func createNamespaceAW(context *context, name string) *arbv1.AppWrapper { }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper @@ -1955,7 +1941,7 @@ func createGenericNamespaceAW(context *context, name string) *arbv1.AppWrapper { }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper @@ -2027,7 +2013,7 @@ func createStatefulSetAW(context *context, name string) *arbv1.AppWrapper { }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper @@ -2098,7 +2084,7 @@ func createGenericStatefulSetAW(context *context, name string) *arbv1.AppWrapper }, }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper @@ -2158,7 +2144,7 @@ func createBadPodTemplateAW(context *context, name string) *arbv1.AppWrapper { }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper @@ -2240,7 +2226,7 @@ func createPodTemplateAW(context *context, name string) *arbv1.AppWrapper { }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper @@ -2304,7 +2290,7 @@ func createPodCheckFailedStatusAW(context *context, name string) *arbv1.AppWrapp }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper @@ -2375,7 +2361,7 @@ func createGenericPodAWCustomDemand(context *context, name string, cpuDemand str }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper @@ -2445,7 +2431,7 @@ func createGenericPodAW(context *context, name string) *arbv1.AppWrapper { }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper @@ -2517,7 +2503,7 @@ func createGenericPodTooBigAW(context *context, name string) *arbv1.AppWrapper { }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper @@ -2572,7 +2558,7 @@ func createBadGenericPodAW(context *context, name string) *arbv1.AppWrapper { }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper @@ -2603,7 +2589,7 @@ func createBadGenericItemAW(context *context, name string) *arbv1.AppWrapper { }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).NotTo(HaveOccurred()) return appwrapper @@ -2665,20 +2651,20 @@ func createBadGenericPodTemplateAW(context *context, name string) (*arbv1.AppWra }, } - appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw) + appwrapper, err := context.karclient.McadV1beta1().AppWrappers(context.namespace).Create(context.ctx, aw, metav1.CreateOptions{}) Expect(err).To(HaveOccurred()) return appwrapper, err } func deleteAppWrapper(ctx *context, name string) error { foreground := metav1.DeletePropagationForeground - return ctx.karclient.ArbV1().AppWrappers(ctx.namespace).Delete(name, &metav1.DeleteOptions{ + return ctx.karclient.McadV1beta1().AppWrappers(ctx.namespace).Delete(ctx.ctx, name, metav1.DeleteOptions{ PropagationPolicy: &foreground, }) } func getPodsOfAppWrapper(ctx *context, aw *arbv1.AppWrapper) []*v1.Pod { - aw, err := ctx.karclient.ArbV1().AppWrappers(aw.Namespace).Get(aw.Name, metav1.GetOptions{}) + aw, err := ctx.karclient.McadV1beta1().AppWrappers(aw.Namespace).Get(ctx.ctx, aw.Name, metav1.GetOptions{}) Expect(err).NotTo(HaveOccurred()) pods, err := ctx.kubeclient.CoreV1().Pods(aw.Namespace).List(gcontext.Background(), metav1.ListOptions{})