From 931bf9931fdf8d488363d8b3c3a8393c56b9bcc4 Mon Sep 17 00:00:00 2001 From: Howard Gao Date: Sun, 28 Apr 2024 17:21:51 +0800 Subject: [PATCH] [#910] Remove Scaledown CRD --- api/v1beta1/activemqartemisscaledown_types.go | 82 ----- api/v1beta1/zz_generated.deepcopy.go | 97 ------ .../activemqartemisscaledown_types.go | 76 ----- api/v2alpha1/zz_generated.deepcopy.go | 96 ------ ...rtemis-operator.clusterserviceversion.yaml | 102 ------ ...oker.amq.io_activemqartemisscaledowns.yaml | 295 ------------------ ...oker.amq.io_activemqartemisscaledowns.yaml | 290 ----------------- config/crd/kustomization.yaml | 11 - ...njection_in_activemqartemisscaledowns.yaml | 7 - .../webhook_in_activemqartemisscaledowns.yaml | 16 - .../broker_activemqartemisscaledown_cr.yaml | 6 - ...rtemis-operator.clusterserviceversion.yaml | 50 --- .../activemqartemisscaledown_editor_role.yaml | 24 -- .../activemqartemisscaledown_viewer_role.yaml | 20 -- config/rbac/role.yaml | 26 -- ...r_activemqartemisscaledown_v1beta1_cr.yaml | 8 - ..._activemqartemisscaledown_v2alpha1_cr.yaml | 8 - config/samples/kustomization.yaml | 2 - controllers/activemqartemis_controller.go | 5 +- .../activemqartemis_controller_test.go | 7 +- .../activemqartemis_controller_unit_test.go | 8 +- .../activemqartemis_messagemigration.go | 138 ++++++++ controllers/activemqartemis_reconciler.go | 82 ++--- .../activemqartemis_reconciler_test.go | 22 +- .../activemqartemisscaledown_controller.go | 164 ---------- controllers/suite_test.go | 19 +- deploy/activemq-artemis-operator.yaml | 235 -------------- deploy/cluster_role.yaml | 26 -- .../broker_activemqartemisscaledown_crd.yaml | 208 ------------ deploy/role.yaml | 26 -- main.go | 30 +- .../v2alpha1/activemqartemisscaledown.go | 176 ----------- .../typed/broker/v2alpha1/broker_client.go | 5 - .../fake/fake_activemqartemisscaledown.go | 140 --------- .../v2alpha1/fake/fake_broker_client.go | 4 - .../v2alpha1/activemqartemisscaledown.go | 89 ------ .../broker/v2alpha1/interface.go | 7 - .../informers/externalversions/generic.go | 3 - .../v2alpha1/activemqartemisscaledown.go | 94 ------ pkg/draincontroller/controller.go | 35 ++- 40 files changed, 231 insertions(+), 2508 deletions(-) delete mode 100644 api/v1beta1/activemqartemisscaledown_types.go delete mode 100644 api/v2alpha1/activemqartemisscaledown_types.go delete mode 100644 bundle/manifests/broker.amq.io_activemqartemisscaledowns.yaml delete mode 100644 config/crd/bases/broker.amq.io_activemqartemisscaledowns.yaml delete mode 100644 config/crd/patches/cainjection_in_activemqartemisscaledowns.yaml delete mode 100644 config/crd/patches/webhook_in_activemqartemisscaledowns.yaml delete mode 100644 config/crs/broker_activemqartemisscaledown_cr.yaml delete mode 100644 config/rbac/activemqartemisscaledown_editor_role.yaml delete mode 100644 config/rbac/activemqartemisscaledown_viewer_role.yaml delete mode 100644 config/samples/broker_activemqartemisscaledown_v1beta1_cr.yaml delete mode 100644 config/samples/broker_activemqartemisscaledown_v2alpha1_cr.yaml create mode 100644 controllers/activemqartemis_messagemigration.go delete mode 100644 controllers/activemqartemisscaledown_controller.go delete mode 100644 deploy/crds/broker_activemqartemisscaledown_crd.yaml delete mode 100644 pkg/client/clientset/versioned/typed/broker/v2alpha1/activemqartemisscaledown.go delete mode 100644 pkg/client/clientset/versioned/typed/broker/v2alpha1/fake/fake_activemqartemisscaledown.go delete mode 100644 pkg/client/informers/externalversions/broker/v2alpha1/activemqartemisscaledown.go delete mode 100644 pkg/client/listers/broker/v2alpha1/activemqartemisscaledown.go diff --git a/api/v1beta1/activemqartemisscaledown_types.go b/api/v1beta1/activemqartemisscaledown_types.go deleted file mode 100644 index c4e62885b..000000000 --- a/api/v1beta1/activemqartemisscaledown_types.go +++ /dev/null @@ -1,82 +0,0 @@ -/* -Copyright 2021. - -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 v1beta1 - -import ( - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - -// ActiveMQArtemisScaledownSpec defines the desired state of ActiveMQArtemisScaledown -type ActiveMQArtemisScaledownSpec struct { - // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster - // Important: Run "make" to regenerate code after modifying this file - - // Triggered by main ActiveMQArtemis CRD messageMigration entry - //+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Temporary",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"} - LocalOnly bool `json:"localOnly"` - // Specifies the minimum/maximum amount of compute resources required/allowed - //+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Resource Requirements",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:resourceRequirements"} - Resources corev1.ResourceRequirements `json:"resources,omitempty"` -} - -// ActiveMQArtemisScaledownStatus defines the observed state of ActiveMQArtemisScaledown -type ActiveMQArtemisScaledownStatus struct { - // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster - // Important: Run "make" to regenerate code after modifying this file - - // Current state of the resource - // Conditions represent the latest available observations of an object's state - //+optional - //+patchMergeKey=type - //+patchStrategy=merge - //+operator-sdk:csv:customresourcedefinitions:type=status,displayName="Conditions",xDescriptors="urn:alm:descriptor:io.kubernetes.conditions" - Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,2,rep,name=conditions"` -} - -//+kubebuilder:object:root=true -//+kubebuilder:storageversion -//+kubebuilder:subresource:status -//+kubebuilder:resource:path=activemqartemisscaledowns,shortName=aad -//+operator-sdk:csv:customresourcedefinitions:resources={{"Secret", "v1"}} - -// +kubebuilder:deprecatedversion:warning="The ActiveMQArtemisScaledown CRD is deprecated, it is an internal only api" -// Provides internal message migration on clustered broker scaledown -// +operator-sdk:csv:customresourcedefinitions:displayName="ActiveMQ Artemis Scaledown" -type ActiveMQArtemisScaledown struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec ActiveMQArtemisScaledownSpec `json:"spec,omitempty"` - Status ActiveMQArtemisScaledownStatus `json:"status,omitempty"` -} - -//+kubebuilder:object:root=true - -// ActiveMQArtemisScaledownList contains a list of ActiveMQArtemisScaledown -type ActiveMQArtemisScaledownList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []ActiveMQArtemisScaledown `json:"items"` -} - -func init() { - SchemeBuilder.Register(&ActiveMQArtemisScaledown{}, &ActiveMQArtemisScaledownList{}) -} diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 0df8e2efd..3f3323e96 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -253,103 +253,6 @@ func (in *ActiveMQArtemisList) DeepCopyObject() runtime.Object { return nil } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ActiveMQArtemisScaledown) DeepCopyInto(out *ActiveMQArtemisScaledown) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ActiveMQArtemisScaledown. -func (in *ActiveMQArtemisScaledown) DeepCopy() *ActiveMQArtemisScaledown { - if in == nil { - return nil - } - out := new(ActiveMQArtemisScaledown) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ActiveMQArtemisScaledown) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ActiveMQArtemisScaledownList) DeepCopyInto(out *ActiveMQArtemisScaledownList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]ActiveMQArtemisScaledown, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ActiveMQArtemisScaledownList. -func (in *ActiveMQArtemisScaledownList) DeepCopy() *ActiveMQArtemisScaledownList { - if in == nil { - return nil - } - out := new(ActiveMQArtemisScaledownList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ActiveMQArtemisScaledownList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ActiveMQArtemisScaledownSpec) DeepCopyInto(out *ActiveMQArtemisScaledownSpec) { - *out = *in - in.Resources.DeepCopyInto(&out.Resources) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ActiveMQArtemisScaledownSpec. -func (in *ActiveMQArtemisScaledownSpec) DeepCopy() *ActiveMQArtemisScaledownSpec { - if in == nil { - return nil - } - out := new(ActiveMQArtemisScaledownSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ActiveMQArtemisScaledownStatus) DeepCopyInto(out *ActiveMQArtemisScaledownStatus) { - *out = *in - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]metav1.Condition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ActiveMQArtemisScaledownStatus. -func (in *ActiveMQArtemisScaledownStatus) DeepCopy() *ActiveMQArtemisScaledownStatus { - if in == nil { - return nil - } - out := new(ActiveMQArtemisScaledownStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ActiveMQArtemisSecurity) DeepCopyInto(out *ActiveMQArtemisSecurity) { *out = *in diff --git a/api/v2alpha1/activemqartemisscaledown_types.go b/api/v2alpha1/activemqartemisscaledown_types.go deleted file mode 100644 index 27f0c2547..000000000 --- a/api/v2alpha1/activemqartemisscaledown_types.go +++ /dev/null @@ -1,76 +0,0 @@ -/* -Copyright 2021. - -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 v2alpha1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - -// ActiveMQArtemisScaledownSpec defines the desired state of ActiveMQArtemisScaledown -type ActiveMQArtemisScaledownSpec struct { - // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster - // Important: Run "make" to regenerate code after modifying this file - - // Triggered by main ActiveMQArtemis CRD messageMigration entry - //+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Temporary",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"} - LocalOnly bool `json:"localOnly"` -} - -// ActiveMQArtemisScaledownStatus defines the observed state of ActiveMQArtemisScaledown -type ActiveMQArtemisScaledownStatus struct { - // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster - // Important: Run "make" to regenerate code after modifying this file - - // Current state of the resource - // Conditions represent the latest available observations of an object's state - //+optional - //+patchMergeKey=type - //+patchStrategy=merge - //+operator-sdk:csv:customresourcedefinitions:type=status,displayName="Conditions",xDescriptors="urn:alm:descriptor:io.kubernetes.conditions" - Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,2,rep,name=conditions"` -} - -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status -//+kubebuilder:resource:path=activemqartemisscaledowns,shortName=aad -//+operator-sdk:csv:customresourcedefinitions:resources={{"Secret", "v1"}} - -// +kubebuilder:deprecatedversion:warning="The ActiveMQArtemisScaledown CRD is deprecated, it is an internal only api" -// ActiveMQArtemisScaledown is the Schema for the activemqartemisscaledowns API -type ActiveMQArtemisScaledown struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec ActiveMQArtemisScaledownSpec `json:"spec,omitempty"` - Status ActiveMQArtemisScaledownStatus `json:"status,omitempty"` -} - -//+kubebuilder:object:root=true - -// ActiveMQArtemisScaledownList contains a list of ActiveMQArtemisScaledown -type ActiveMQArtemisScaledownList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []ActiveMQArtemisScaledown `json:"items"` -} - -func init() { - SchemeBuilder.Register(&ActiveMQArtemisScaledown{}, &ActiveMQArtemisScaledownList{}) -} diff --git a/api/v2alpha1/zz_generated.deepcopy.go b/api/v2alpha1/zz_generated.deepcopy.go index 67c7f55aa..378915d54 100644 --- a/api/v2alpha1/zz_generated.deepcopy.go +++ b/api/v2alpha1/zz_generated.deepcopy.go @@ -196,102 +196,6 @@ func (in *ActiveMQArtemisList) DeepCopyObject() runtime.Object { return nil } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ActiveMQArtemisScaledown) DeepCopyInto(out *ActiveMQArtemisScaledown) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ActiveMQArtemisScaledown. -func (in *ActiveMQArtemisScaledown) DeepCopy() *ActiveMQArtemisScaledown { - if in == nil { - return nil - } - out := new(ActiveMQArtemisScaledown) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ActiveMQArtemisScaledown) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ActiveMQArtemisScaledownList) DeepCopyInto(out *ActiveMQArtemisScaledownList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]ActiveMQArtemisScaledown, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ActiveMQArtemisScaledownList. -func (in *ActiveMQArtemisScaledownList) DeepCopy() *ActiveMQArtemisScaledownList { - if in == nil { - return nil - } - out := new(ActiveMQArtemisScaledownList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ActiveMQArtemisScaledownList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ActiveMQArtemisScaledownSpec) DeepCopyInto(out *ActiveMQArtemisScaledownSpec) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ActiveMQArtemisScaledownSpec. -func (in *ActiveMQArtemisScaledownSpec) DeepCopy() *ActiveMQArtemisScaledownSpec { - if in == nil { - return nil - } - out := new(ActiveMQArtemisScaledownSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ActiveMQArtemisScaledownStatus) DeepCopyInto(out *ActiveMQArtemisScaledownStatus) { - *out = *in - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]v1.Condition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ActiveMQArtemisScaledownStatus. -func (in *ActiveMQArtemisScaledownStatus) DeepCopy() *ActiveMQArtemisScaledownStatus { - if in == nil { - return nil - } - out := new(ActiveMQArtemisScaledownStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ActiveMQArtemisSpec) DeepCopyInto(out *ActiveMQArtemisSpec) { *out = *in diff --git a/bundle/manifests/activemq-artemis-operator.clusterserviceversion.yaml b/bundle/manifests/activemq-artemis-operator.clusterserviceversion.yaml index e11043642..d94c5143e 100644 --- a/bundle/manifests/activemq-artemis-operator.clusterserviceversion.yaml +++ b/bundle/manifests/activemq-artemis-operator.clusterserviceversion.yaml @@ -79,19 +79,6 @@ metadata: "conditions": [] } }, - { - "apiVersion": "broker.amq.io/v1beta1", - "kind": "ActiveMQArtemisScaledown", - "metadata": { - "name": "ex-aaoscaledown" - }, - "spec": { - "localOnly": true - }, - "status": { - "conditions": [] - } - }, { "apiVersion": "broker.amq.io/v1beta1", "kind": "ActiveMQArtemisSecurity", @@ -161,19 +148,6 @@ metadata: "conditions": [] } }, - { - "apiVersion": "broker.amq.io/v2alpha1", - "kind": "ActiveMQArtemisScaledown", - "metadata": { - "name": "ex-aaoscaledown" - }, - "spec": { - "localOnly": true - }, - "status": { - "conditions": [] - } - }, { "apiVersion": "broker.amq.io/v2alpha2", "kind": "ActiveMQArtemis", @@ -1657,56 +1631,6 @@ spec: x-descriptors: - urn:alm:descriptor:io.kubernetes.conditions version: v2alpha5 - - description: Provides internal message migration on clustered broker scaledown - displayName: ActiveMQ Artemis Scaledown - kind: ActiveMQArtemisScaledown - name: activemqartemisscaledowns.broker.amq.io - resources: - - kind: Secret - name: "" - version: v1 - specDescriptors: - - description: Triggered by main ActiveMQArtemis CRD messageMigration entry - displayName: Temporary - path: localOnly - x-descriptors: - - urn:alm:descriptor:com.tectonic.ui:booleanSwitch - - description: Specifies the minimum/maximum amount of compute resources required/allowed - displayName: Resource Requirements - path: resources - x-descriptors: - - urn:alm:descriptor:com.tectonic.ui:resourceRequirements - statusDescriptors: - - description: Current state of the resource Conditions represent the latest - available observations of an object's state - displayName: Conditions - path: conditions - x-descriptors: - - urn:alm:descriptor:io.kubernetes.conditions - version: v1beta1 - - description: ActiveMQArtemisScaledown is the Schema for the activemqartemisscaledowns - API - displayName: Active MQArtemis Scaledown - kind: ActiveMQArtemisScaledown - name: activemqartemisscaledowns.broker.amq.io - resources: - - kind: Secret - name: "" - version: v1 - specDescriptors: - - description: Triggered by main ActiveMQArtemis CRD messageMigration entry - displayName: Temporary - path: localOnly - x-descriptors: - - urn:alm:descriptor:com.tectonic.ui:booleanSwitch - statusDescriptors: - - description: Current state of the resource Conditions represent the latest - available observations of an object's state - displayName: Conditions - path: conditions - x-descriptors: - - urn:alm:descriptor:io.kubernetes.conditions - version: v2alpha1 - description: Security configuration for the broker displayName: ActiveMQ Artemis Security kind: ActiveMQArtemisSecurity @@ -3051,32 +2975,6 @@ spec: - get - patch - update - - apiGroups: - - broker.amq.io - resources: - - activemqartemisscaledowns - verbs: - - create - - delete - - get - - list - - patch - - update - - watch - - apiGroups: - - broker.amq.io - resources: - - activemqartemisscaledowns/finalizers - verbs: - - update - - apiGroups: - - broker.amq.io - resources: - - activemqartemisscaledowns/status - verbs: - - get - - patch - - update - apiGroups: - broker.amq.io resources: diff --git a/bundle/manifests/broker.amq.io_activemqartemisscaledowns.yaml b/bundle/manifests/broker.amq.io_activemqartemisscaledowns.yaml deleted file mode 100644 index bb0d49f59..000000000 --- a/bundle/manifests/broker.amq.io_activemqartemisscaledowns.yaml +++ /dev/null @@ -1,295 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.11.2 - name: activemqartemisscaledowns.broker.amq.io -spec: - group: broker.amq.io - names: - kind: ActiveMQArtemisScaledown - listKind: ActiveMQArtemisScaledownList - plural: activemqartemisscaledowns - shortNames: - - aad - singular: activemqartemisscaledown - scope: Namespaced - versions: - - deprecated: true - deprecationWarning: The ActiveMQArtemisScaledown CRD is deprecated, it is an internal - only api - name: v1beta1 - schema: - openAPIV3Schema: - description: Provides internal message migration on clustered broker scaledown - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - description: ActiveMQArtemisScaledownSpec defines the desired state of - ActiveMQArtemisScaledown - properties: - localOnly: - description: Triggered by main ActiveMQArtemis CRD messageMigration - entry - type: boolean - resources: - description: Specifies the minimum/maximum amount of compute resources - required/allowed - properties: - claims: - description: "Claims lists the names of resources, defined in - spec.resourceClaims, that are used by this container. \n This - is an alpha field and requires enabling the DynamicResourceAllocation - feature gate. \n This field is immutable. It can only be set - for containers." - items: - description: ResourceClaim references one entry in PodSpec.ResourceClaims. - properties: - name: - description: Name must match the name of one entry in pod.spec.resourceClaims - of the Pod where this field is used. It makes that resource - available inside a container. - type: string - required: - - name - type: object - type: array - x-kubernetes-list-map-keys: - - name - x-kubernetes-list-type: map - limits: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: 'Limits describes the maximum amount of compute resources - allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' - type: object - requests: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: 'Requests describes the minimum amount of compute - resources required. If Requests is omitted for a container, - it defaults to Limits if that is explicitly specified, otherwise - to an implementation-defined value. Requests cannot exceed Limits. - More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' - type: object - type: object - required: - - localOnly - type: object - status: - description: ActiveMQArtemisScaledownStatus defines the observed state - of ActiveMQArtemisScaledown - properties: - conditions: - description: Current state of the resource Conditions represent the - latest available observations of an object's state - items: - description: "Condition contains details for one aspect of the current - state of this API Resource. --- This struct is intended for direct - use as an array at the field path .status.conditions. For example, - \n type FooStatus struct{ // Represents the observations of a - foo's current state. // Known .status.conditions.type are: \"Available\", - \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge - // +listType=map // +listMapKey=type Conditions []metav1.Condition - `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" - protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }" - properties: - lastTransitionTime: - description: lastTransitionTime is the last time the condition - transitioned from one status to another. This should be when - the underlying condition changed. If that is not known, then - using the time when the API field changed is acceptable. - format: date-time - type: string - message: - description: message is a human readable message indicating - details about the transition. This may be an empty string. - maxLength: 32768 - type: string - observedGeneration: - description: observedGeneration represents the .metadata.generation - that the condition was set based upon. For instance, if .metadata.generation - is currently 12, but the .status.conditions[x].observedGeneration - is 9, the condition is out of date with respect to the current - state of the instance. - format: int64 - minimum: 0 - type: integer - reason: - description: reason contains a programmatic identifier indicating - the reason for the condition's last transition. Producers - of specific condition types may define expected values and - meanings for this field, and whether the values are considered - a guaranteed API. The value should be a CamelCase string. - This field may not be empty. - maxLength: 1024 - minLength: 1 - pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ - type: string - status: - description: status of the condition, one of True, False, Unknown. - enum: - - "True" - - "False" - - Unknown - type: string - type: - description: type of condition in CamelCase or in foo.example.com/CamelCase. - --- Many .condition.type values are consistent across resources - like Available, but because arbitrary conditions can be useful - (see .node.status.conditions), the ability to deconflict is - important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) - maxLength: 316 - pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - type: array - type: object - type: object - served: true - storage: true - subresources: - status: {} - - deprecated: true - deprecationWarning: The ActiveMQArtemisScaledown CRD is deprecated, it is an internal - only api - name: v2alpha1 - schema: - openAPIV3Schema: - description: ActiveMQArtemisScaledown is the Schema for the activemqartemisscaledowns - API - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - description: ActiveMQArtemisScaledownSpec defines the desired state of - ActiveMQArtemisScaledown - properties: - localOnly: - description: Triggered by main ActiveMQArtemis CRD messageMigration - entry - type: boolean - required: - - localOnly - type: object - status: - description: ActiveMQArtemisScaledownStatus defines the observed state - of ActiveMQArtemisScaledown - properties: - conditions: - description: Current state of the resource Conditions represent the - latest available observations of an object's state - items: - description: "Condition contains details for one aspect of the current - state of this API Resource. --- This struct is intended for direct - use as an array at the field path .status.conditions. For example, - \n type FooStatus struct{ // Represents the observations of a - foo's current state. // Known .status.conditions.type are: \"Available\", - \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge - // +listType=map // +listMapKey=type Conditions []metav1.Condition - `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" - protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }" - properties: - lastTransitionTime: - description: lastTransitionTime is the last time the condition - transitioned from one status to another. This should be when - the underlying condition changed. If that is not known, then - using the time when the API field changed is acceptable. - format: date-time - type: string - message: - description: message is a human readable message indicating - details about the transition. This may be an empty string. - maxLength: 32768 - type: string - observedGeneration: - description: observedGeneration represents the .metadata.generation - that the condition was set based upon. For instance, if .metadata.generation - is currently 12, but the .status.conditions[x].observedGeneration - is 9, the condition is out of date with respect to the current - state of the instance. - format: int64 - minimum: 0 - type: integer - reason: - description: reason contains a programmatic identifier indicating - the reason for the condition's last transition. Producers - of specific condition types may define expected values and - meanings for this field, and whether the values are considered - a guaranteed API. The value should be a CamelCase string. - This field may not be empty. - maxLength: 1024 - minLength: 1 - pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ - type: string - status: - description: status of the condition, one of True, False, Unknown. - enum: - - "True" - - "False" - - Unknown - type: string - type: - description: type of condition in CamelCase or in foo.example.com/CamelCase. - --- Many .condition.type values are consistent across resources - like Available, but because arbitrary conditions can be useful - (see .node.status.conditions), the ability to deconflict is - important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) - maxLength: 316 - pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - type: array - type: object - type: object - served: true - storage: false - subresources: - status: {} -status: - acceptedNames: - kind: "" - plural: "" - conditions: null - storedVersions: null diff --git a/config/crd/bases/broker.amq.io_activemqartemisscaledowns.yaml b/config/crd/bases/broker.amq.io_activemqartemisscaledowns.yaml deleted file mode 100644 index 5690bbe1c..000000000 --- a/config/crd/bases/broker.amq.io_activemqartemisscaledowns.yaml +++ /dev/null @@ -1,290 +0,0 @@ ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.11.2 - name: activemqartemisscaledowns.broker.amq.io -spec: - group: broker.amq.io - names: - kind: ActiveMQArtemisScaledown - listKind: ActiveMQArtemisScaledownList - plural: activemqartemisscaledowns - shortNames: - - aad - singular: activemqartemisscaledown - scope: Namespaced - versions: - - deprecated: true - deprecationWarning: The ActiveMQArtemisScaledown CRD is deprecated, it is an internal - only api - name: v1beta1 - schema: - openAPIV3Schema: - description: Provides internal message migration on clustered broker scaledown - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - description: ActiveMQArtemisScaledownSpec defines the desired state of - ActiveMQArtemisScaledown - properties: - localOnly: - description: Triggered by main ActiveMQArtemis CRD messageMigration - entry - type: boolean - resources: - description: Specifies the minimum/maximum amount of compute resources - required/allowed - properties: - claims: - description: "Claims lists the names of resources, defined in - spec.resourceClaims, that are used by this container. \n This - is an alpha field and requires enabling the DynamicResourceAllocation - feature gate. \n This field is immutable. It can only be set - for containers." - items: - description: ResourceClaim references one entry in PodSpec.ResourceClaims. - properties: - name: - description: Name must match the name of one entry in pod.spec.resourceClaims - of the Pod where this field is used. It makes that resource - available inside a container. - type: string - required: - - name - type: object - type: array - x-kubernetes-list-map-keys: - - name - x-kubernetes-list-type: map - limits: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: 'Limits describes the maximum amount of compute resources - allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' - type: object - requests: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: 'Requests describes the minimum amount of compute - resources required. If Requests is omitted for a container, - it defaults to Limits if that is explicitly specified, otherwise - to an implementation-defined value. Requests cannot exceed Limits. - More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' - type: object - type: object - required: - - localOnly - type: object - status: - description: ActiveMQArtemisScaledownStatus defines the observed state - of ActiveMQArtemisScaledown - properties: - conditions: - description: Current state of the resource Conditions represent the - latest available observations of an object's state - items: - description: "Condition contains details for one aspect of the current - state of this API Resource. --- This struct is intended for direct - use as an array at the field path .status.conditions. For example, - \n type FooStatus struct{ // Represents the observations of a - foo's current state. // Known .status.conditions.type are: \"Available\", - \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge - // +listType=map // +listMapKey=type Conditions []metav1.Condition - `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" - protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }" - properties: - lastTransitionTime: - description: lastTransitionTime is the last time the condition - transitioned from one status to another. This should be when - the underlying condition changed. If that is not known, then - using the time when the API field changed is acceptable. - format: date-time - type: string - message: - description: message is a human readable message indicating - details about the transition. This may be an empty string. - maxLength: 32768 - type: string - observedGeneration: - description: observedGeneration represents the .metadata.generation - that the condition was set based upon. For instance, if .metadata.generation - is currently 12, but the .status.conditions[x].observedGeneration - is 9, the condition is out of date with respect to the current - state of the instance. - format: int64 - minimum: 0 - type: integer - reason: - description: reason contains a programmatic identifier indicating - the reason for the condition's last transition. Producers - of specific condition types may define expected values and - meanings for this field, and whether the values are considered - a guaranteed API. The value should be a CamelCase string. - This field may not be empty. - maxLength: 1024 - minLength: 1 - pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ - type: string - status: - description: status of the condition, one of True, False, Unknown. - enum: - - "True" - - "False" - - Unknown - type: string - type: - description: type of condition in CamelCase or in foo.example.com/CamelCase. - --- Many .condition.type values are consistent across resources - like Available, but because arbitrary conditions can be useful - (see .node.status.conditions), the ability to deconflict is - important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) - maxLength: 316 - pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - type: array - type: object - type: object - served: true - storage: true - subresources: - status: {} - - deprecated: true - deprecationWarning: The ActiveMQArtemisScaledown CRD is deprecated, it is an internal - only api - name: v2alpha1 - schema: - openAPIV3Schema: - description: ActiveMQArtemisScaledown is the Schema for the activemqartemisscaledowns - API - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - description: ActiveMQArtemisScaledownSpec defines the desired state of - ActiveMQArtemisScaledown - properties: - localOnly: - description: Triggered by main ActiveMQArtemis CRD messageMigration - entry - type: boolean - required: - - localOnly - type: object - status: - description: ActiveMQArtemisScaledownStatus defines the observed state - of ActiveMQArtemisScaledown - properties: - conditions: - description: Current state of the resource Conditions represent the - latest available observations of an object's state - items: - description: "Condition contains details for one aspect of the current - state of this API Resource. --- This struct is intended for direct - use as an array at the field path .status.conditions. For example, - \n type FooStatus struct{ // Represents the observations of a - foo's current state. // Known .status.conditions.type are: \"Available\", - \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge - // +listType=map // +listMapKey=type Conditions []metav1.Condition - `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" - protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }" - properties: - lastTransitionTime: - description: lastTransitionTime is the last time the condition - transitioned from one status to another. This should be when - the underlying condition changed. If that is not known, then - using the time when the API field changed is acceptable. - format: date-time - type: string - message: - description: message is a human readable message indicating - details about the transition. This may be an empty string. - maxLength: 32768 - type: string - observedGeneration: - description: observedGeneration represents the .metadata.generation - that the condition was set based upon. For instance, if .metadata.generation - is currently 12, but the .status.conditions[x].observedGeneration - is 9, the condition is out of date with respect to the current - state of the instance. - format: int64 - minimum: 0 - type: integer - reason: - description: reason contains a programmatic identifier indicating - the reason for the condition's last transition. Producers - of specific condition types may define expected values and - meanings for this field, and whether the values are considered - a guaranteed API. The value should be a CamelCase string. - This field may not be empty. - maxLength: 1024 - minLength: 1 - pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ - type: string - status: - description: status of the condition, one of True, False, Unknown. - enum: - - "True" - - "False" - - Unknown - type: string - type: - description: type of condition in CamelCase or in foo.example.com/CamelCase. - --- Many .condition.type values are consistent across resources - like Available, but because arbitrary conditions can be useful - (see .node.status.conditions), the ability to deconflict is - important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) - maxLength: 316 - pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - type: array - type: object - type: object - served: true - storage: false - subresources: - status: {} diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index 726dd353e..c358677cc 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -4,7 +4,6 @@ resources: - bases/broker.amq.io_activemqartemises.yaml - bases/broker.amq.io_activemqartemisaddresses.yaml -- bases/broker.amq.io_activemqartemisscaledowns.yaml - bases/broker.amq.io_activemqartemissecurities.yaml #+kubebuilder:scaffold:crdkustomizeresource @@ -12,9 +11,6 @@ resources: # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix. # patches here are for enabling the conversion webhook for each CRD #- patches/webhook_in_activemqartemises.yaml -#- patches/webhook_in_activemqartemisaddresses.yaml -#- patches/webhook_in_activemqartemisscaledowns.yaml -#- patches/webhook_in_activemqartemissecurities.yaml #- patches/webhook_in_activemqartemissecurities.yaml #- patches/webhook_in_activemqartemisaddresses.yaml #+kubebuilder:scaffold:crdkustomizewebhookpatch @@ -23,7 +19,6 @@ resources: # patches here are for enabling the CA injection for each CRD #- patches/cainjection_in_activemqartemises.yaml #- patches/cainjection_in_activemqartemisaddresses.yaml -#- patches/cainjection_in_activemqartemisscaledowns.yaml #- patches/cainjection_in_activemqartemissecurities.yaml #+kubebuilder:scaffold:crdkustomizecainjectionpatch @@ -44,12 +39,6 @@ resources: # group: "apiextensions.k8s.io" # version: v1 # apiVersion # kind: CustomResourceDefinition -# name: activemqartemisscaledowns.broker.amq.io -# path: patches/patch_conversion_webhook_client_ca_bundles.yaml -#- target: -# group: "apiextensions.k8s.io" -# version: v1 # apiVersion -# kind: CustomResourceDefinition # name: activemqartemissecurities.broker.amq.io # path: patches/patch_conversion_webhook_client_ca_bundles.yaml diff --git a/config/crd/patches/cainjection_in_activemqartemisscaledowns.yaml b/config/crd/patches/cainjection_in_activemqartemisscaledowns.yaml deleted file mode 100644 index 60ff3a4f8..000000000 --- a/config/crd/patches/cainjection_in_activemqartemisscaledowns.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# The following patch adds a directive for certmanager to inject CA into the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) - name: activemqartemisscaledowns.broker.amq.io diff --git a/config/crd/patches/webhook_in_activemqartemisscaledowns.yaml b/config/crd/patches/webhook_in_activemqartemisscaledowns.yaml deleted file mode 100644 index dafb852fe..000000000 --- a/config/crd/patches/webhook_in_activemqartemisscaledowns.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# The following patch enables a conversion webhook for the CRD -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: activemqartemisscaledowns.broker.amq.io -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - namespace: system - name: webhook-service - path: /convert - conversionReviewVersions: - - v1beta1 diff --git a/config/crs/broker_activemqartemisscaledown_cr.yaml b/config/crs/broker_activemqartemisscaledown_cr.yaml deleted file mode 100644 index 534dd9abd..000000000 --- a/config/crs/broker_activemqartemisscaledown_cr.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: broker.amq.io/v2alpha1 -kind: ActiveMQArtemisScaledown -metadata: - name: ex-aaoscaledown -spec: - localOnly: true diff --git a/config/manifests/bases/activemq-artemis-operator.clusterserviceversion.yaml b/config/manifests/bases/activemq-artemis-operator.clusterserviceversion.yaml index b7d63e483..f3660a217 100644 --- a/config/manifests/bases/activemq-artemis-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/activemq-artemis-operator.clusterserviceversion.yaml @@ -1389,56 +1389,6 @@ spec: x-descriptors: - urn:alm:descriptor:io.kubernetes.conditions version: v2alpha1 - - description: Provides internal message migration on clustered broker scaledown - displayName: ActiveMQ Artemis Scaledown - kind: ActiveMQArtemisScaledown - name: activemqartemisscaledowns.broker.amq.io - resources: - - kind: Secret - name: "" - version: v1 - specDescriptors: - - description: Triggered by main ActiveMQArtemis CRD messageMigration entry - displayName: Temporary - path: localOnly - x-descriptors: - - urn:alm:descriptor:com.tectonic.ui:booleanSwitch - - description: Specifies the minimum/maximum amount of compute resources required/allowed - displayName: Resource Requirements - path: resources - x-descriptors: - - urn:alm:descriptor:com.tectonic.ui:resourceRequirements - statusDescriptors: - - description: Current state of the resource Conditions represent the latest - available observations of an object's state - displayName: Conditions - path: conditions - x-descriptors: - - urn:alm:descriptor:io.kubernetes.conditions - version: v1beta1 - - description: ActiveMQArtemisScaledown is the Schema for the activemqartemisscaledowns - API - displayName: Active MQArtemis Scaledown - kind: ActiveMQArtemisScaledown - name: activemqartemisscaledowns.broker.amq.io - resources: - - kind: Secret - name: "" - version: v1 - specDescriptors: - - description: Triggered by main ActiveMQArtemis CRD messageMigration entry - displayName: Temporary - path: localOnly - x-descriptors: - - urn:alm:descriptor:com.tectonic.ui:booleanSwitch - statusDescriptors: - - description: Current state of the resource Conditions represent the latest - available observations of an object's state - displayName: Conditions - path: conditions - x-descriptors: - - urn:alm:descriptor:io.kubernetes.conditions - version: v2alpha1 - description: Security configuration for the broker displayName: ActiveMQ Artemis Security kind: ActiveMQArtemisSecurity diff --git a/config/rbac/activemqartemisscaledown_editor_role.yaml b/config/rbac/activemqartemisscaledown_editor_role.yaml deleted file mode 100644 index 42edd34fb..000000000 --- a/config/rbac/activemqartemisscaledown_editor_role.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# permissions for end users to edit activemqartemisscaledowns. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: activemqartemisscaledown-editor-role -rules: -- apiGroups: - - broker.amq.io - resources: - - activemqartemisscaledowns - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - broker.amq.io - resources: - - activemqartemisscaledowns/status - verbs: - - get diff --git a/config/rbac/activemqartemisscaledown_viewer_role.yaml b/config/rbac/activemqartemisscaledown_viewer_role.yaml deleted file mode 100644 index d0587a7cb..000000000 --- a/config/rbac/activemqartemisscaledown_viewer_role.yaml +++ /dev/null @@ -1,20 +0,0 @@ -# permissions for end users to view activemqartemisscaledowns. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: activemqartemisscaledown-viewer-role -rules: -- apiGroups: - - broker.amq.io - resources: - - activemqartemisscaledowns - verbs: - - get - - list - - watch -- apiGroups: - - broker.amq.io - resources: - - activemqartemisscaledowns/status - verbs: - - get diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index addf225ea..1afb1ef22 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -92,32 +92,6 @@ rules: - get - patch - update -- apiGroups: - - broker.amq.io - resources: - - activemqartemisscaledowns - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - broker.amq.io - resources: - - activemqartemisscaledowns/finalizers - verbs: - - update -- apiGroups: - - broker.amq.io - resources: - - activemqartemisscaledowns/status - verbs: - - get - - patch - - update - apiGroups: - broker.amq.io resources: diff --git a/config/samples/broker_activemqartemisscaledown_v1beta1_cr.yaml b/config/samples/broker_activemqartemisscaledown_v1beta1_cr.yaml deleted file mode 100644 index 8a52ca606..000000000 --- a/config/samples/broker_activemqartemisscaledown_v1beta1_cr.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: broker.amq.io/v1beta1 -kind: ActiveMQArtemisScaledown -metadata: - name: ex-aaoscaledown -spec: - localOnly: true -status: - conditions: [] \ No newline at end of file diff --git a/config/samples/broker_activemqartemisscaledown_v2alpha1_cr.yaml b/config/samples/broker_activemqartemisscaledown_v2alpha1_cr.yaml deleted file mode 100644 index 11aa0ec42..000000000 --- a/config/samples/broker_activemqartemisscaledown_v2alpha1_cr.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: broker.amq.io/v2alpha1 -kind: ActiveMQArtemisScaledown -metadata: - name: ex-aaoscaledown -spec: - localOnly: true -status: - conditions: [] \ No newline at end of file diff --git a/config/samples/kustomization.yaml b/config/samples/kustomization.yaml index 8ee3c629a..a2c2677fc 100644 --- a/config/samples/kustomization.yaml +++ b/config/samples/kustomization.yaml @@ -12,8 +12,6 @@ resources: - broker_activemqartemisaddress_v1beta1_cr.yaml - broker_activemqartemissecurity_v1alpha1_cr.yaml - broker_activemqartemissecurity_v1beta1_cr.yaml -- broker_activemqartemisscaledown_v2alpha1_cr.yaml -- broker_activemqartemisscaledown_v1beta1_cr.yaml #+kubebuilder:scaffold:manifestskustomizesamples diff --git a/controllers/activemqartemis_controller.go b/controllers/activemqartemis_controller.go index 0d997d11f..11c58691e 100644 --- a/controllers/activemqartemis_controller.go +++ b/controllers/activemqartemis_controller.go @@ -110,15 +110,17 @@ type ActiveMQArtemisReconciler struct { Scheme *runtime.Scheme events chan event.GenericEvent log logr.Logger + MmControl *ActiveMQArtemisMessageMigrationControl isOnOpenShift bool } -func NewActiveMQArtemisReconciler(cluster cluster.Cluster, logger logr.Logger, isOpenShift bool) *ActiveMQArtemisReconciler { +func NewActiveMQArtemisReconciler(cluster cluster.Cluster, logger logr.Logger, isOpenShift bool, mmControl *ActiveMQArtemisMessageMigrationControl) *ActiveMQArtemisReconciler { return &ActiveMQArtemisReconciler{ isOnOpenShift: isOpenShift, Client: cluster.GetClient(), Scheme: cluster.GetScheme(), log: logger, + MmControl: mmControl, } } @@ -158,6 +160,7 @@ func (r *ActiveMQArtemisReconciler) Reconcile(ctx context.Context, request ctrl. if err != nil { if apierrors.IsNotFound(err) { reqLogger.V(1).Info("ActiveMQArtemis Controller Reconcile encountered a IsNotFound, for request NamespacedName " + request.NamespacedName.String()) + r.MmControl.Cancel(&request.NamespacedName) return result, nil } reqLogger.Error(err, "unable to retrieve the ActiveMQArtemis") diff --git a/controllers/activemqartemis_controller_test.go b/controllers/activemqartemis_controller_test.go index 332869bd4..6b5407a01 100644 --- a/controllers/activemqartemis_controller_test.go +++ b/controllers/activemqartemis_controller_test.go @@ -3716,7 +3716,7 @@ var _ = Describe("artemis controller", func() { crd.Spec.Console.Expose = true crd.Spec.Console.SSLEnabled = true - outer := NewActiveMQArtemisReconciler(k8Manager, ctrl.Log, isOpenshift) + outer := NewActiveMQArtemisReconciler(k8Manager, ctrl.Log, isOpenshift, brokerReconciler.MmControl) reconcilerImpl := NewActiveMQArtemisReconcilerImpl(&crd, outer) defaultConsoleSecretName := crd.Name + "-console-secret" @@ -3809,7 +3809,7 @@ var _ = Describe("artemis controller", func() { g.Expect(createdCrd.ResourceVersion).ShouldNot(BeEmpty()) }, timeout, interval).Should(Succeed()) - outer := NewActiveMQArtemisReconciler(k8Manager, ctrl.Log, isOpenshift) + outer := NewActiveMQArtemisReconciler(k8Manager, ctrl.Log, isOpenshift, brokerReconciler.MmControl) reconcilerImpl := NewActiveMQArtemisReconcilerImpl(&crd, outer) namer := MakeNamers(&crd) @@ -3914,8 +3914,9 @@ var _ = Describe("artemis controller", func() { }, timeout, interval).Should(Succeed()) - outer := NewActiveMQArtemisReconciler(k8Manager, ctrl.Log, isOpenshift) + outer := NewActiveMQArtemisReconciler(k8Manager, ctrl.Log, isOpenshift, brokerReconciler.MmControl) reconcilerImpl := NewActiveMQArtemisReconcilerImpl(&crd, outer) + reconcilerImpl.deployed = make(map[reflect.Type][]client.Object) namer := MakeNamers(&crd) diff --git a/controllers/activemqartemis_controller_unit_test.go b/controllers/activemqartemis_controller_unit_test.go index 38238943d..bac586476 100644 --- a/controllers/activemqartemis_controller_unit_test.go +++ b/controllers/activemqartemis_controller_unit_test.go @@ -41,7 +41,7 @@ func TestValidate(t *testing.T) { namer := MakeNamers(cr) - r := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log, isOpenshift) + r := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log, isOpenshift, nil) ri := NewActiveMQArtemisReconcilerImpl(cr, r) valid, retry := ri.validate(cr, k8sClient, *namer) @@ -69,7 +69,7 @@ func TestValidateBrokerPropsDuplicate(t *testing.T) { namer := MakeNamers(cr) - r := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log, isOpenshift) + r := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log, isOpenshift, nil) ri := NewActiveMQArtemisReconcilerImpl(cr, r) valid, retry := ri.validate(cr, k8sClient, *namer) @@ -97,7 +97,7 @@ func TestValidateBrokerPropsDuplicateOnFirstEquals(t *testing.T) { namer := MakeNamers(cr) - r := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log, isOpenshift) + r := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log, isOpenshift, nil) ri := NewActiveMQArtemisReconcilerImpl(cr, r) valid, retry := ri.validate(cr, k8sClient, *namer) @@ -125,7 +125,7 @@ func TestValidateBrokerPropsDuplicateOnFirstEqualsIncorrectButUnrealisticForOurB namer := MakeNamers(cr) - r := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log, isOpenshift) + r := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log, isOpenshift, nil) ri := NewActiveMQArtemisReconcilerImpl(cr, r) valid, retry := ri.validate(cr, k8sClient, *namer) diff --git a/controllers/activemqartemis_messagemigration.go b/controllers/activemqartemis_messagemigration.go new file mode 100644 index 000000000..69cc9c4d8 --- /dev/null +++ b/controllers/activemqartemis_messagemigration.go @@ -0,0 +1,138 @@ +/* +Copyright 2021. + +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 controllers + +import ( + "time" + + brokerv1beta1 "github.com/artemiscloud/activemq-artemis-operator/api/v1beta1" + "github.com/artemiscloud/activemq-artemis-operator/pkg/draincontroller" + "github.com/go-logr/logr" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/types" + kubeinformers "k8s.io/client-go/informers" + "k8s.io/client-go/kubernetes" + "k8s.io/client-go/rest" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +var StopCh chan struct{} + +var controllers map[string]*draincontroller.Controller = make(map[string]*draincontroller.Controller) + +type ActiveMQArtemisMessageMigrationControl struct { + client.Client + Scheme *runtime.Scheme + Config *rest.Config + log logr.Logger + localOnly bool +} + +func NewActiveMQArtemisMessageMigrationControl(client client.Client, scheme *runtime.Scheme, config *rest.Config, logger logr.Logger, localOnly bool) *ActiveMQArtemisMessageMigrationControl { + return &ActiveMQArtemisMessageMigrationControl{ + Client: client, + Scheme: scheme, + Config: config, + log: logger, + localOnly: localOnly, + } +} + +func (mm *ActiveMQArtemisMessageMigrationControl) Setup(brokerCr *brokerv1beta1.ActiveMQArtemis, params map[string]string) error { + + reqLogger := mm.log.WithValues("Setup", brokerCr.Name, "Namespace", brokerCr.Namespace) + + kubeClient, err := kubernetes.NewForConfig(mm.Config) + if err != nil { + reqLogger.Error(err, "Error building kubernetes clientset") + return err + } + + kubeInformerFactory, drainControllerInstance, isNewController := mm.getDrainController(kubeClient, brokerCr, params) + + if isNewController { + reqLogger.V(2).Info("Starting async factory...") + go kubeInformerFactory.Start(*drainControllerInstance.GetStopCh()) + + reqLogger.V(2).Info("Running drain controller async so multiple controllers can run...") + go mm.runDrainController(drainControllerInstance) + } + + reqLogger.V(2).Info("Message Migration is set up") + return nil +} + +func (mm *ActiveMQArtemisMessageMigrationControl) Cancel(brokerNs *types.NamespacedName) { + reqLogger := mm.log.WithValues("Cancel", brokerNs.Name, "Namespace", brokerNs.Namespace) + if drainer := mm.findDrainerController(brokerNs); drainer != nil { + reqLogger.V(1).Info("Cancel message migration") + drainer.RemoveInstance(brokerNs) + } +} + +func (mm *ActiveMQArtemisMessageMigrationControl) findDrainerController(brokerNs *types.NamespacedName) *draincontroller.Controller { + controllerKey := mm.getControllerKey(brokerNs.Namespace) + if inst, ok := controllers[controllerKey]; ok { + return inst + } + return nil +} + +func (mm *ActiveMQArtemisMessageMigrationControl) getControllerKey(ns string) string { + controllerKey := "*" + if mm.localOnly { + controllerKey = ns + } + return controllerKey +} + +func (mm *ActiveMQArtemisMessageMigrationControl) getDrainController(kubeClient *kubernetes.Clientset, instance *brokerv1beta1.ActiveMQArtemis, params map[string]string) (kubeinformers.SharedInformerFactory, *draincontroller.Controller, bool) { + var kubeInformerFactory kubeinformers.SharedInformerFactory + var controllerInstance *draincontroller.Controller + + controllerKey := mm.getControllerKey(instance.Namespace) + + if inst, ok := controllers[controllerKey]; ok { + mm.log.V(2).Info("Drain controller already exists", "namespace", controllerKey) + inst.AddInstance(instance, params) + return nil, nil, false + } + + if mm.localOnly { + // localOnly means there is only one target namespace and it is the same as operator's + mm.log.V(2).Info("getting localOnly informer factory", "namespace", controllerKey) + kubeInformerFactory = kubeinformers.NewSharedInformerFactoryWithOptions(kubeClient, time.Second*30, kubeinformers.WithNamespace(instance.Namespace)) + } else { + mm.log.V(2).Info("Creating informer factory to operate on StatefulSets across all namespaces") + kubeInformerFactory = kubeinformers.NewSharedInformerFactory(kubeClient, time.Second*30) + } + + mm.log.V(2).Info("new drain controller...", "labels", instance.Labels) + controllerInstance = draincontroller.NewController(controllerKey, instance, kubeClient, kubeInformerFactory, instance.Namespace, mm.Client, mm.log, mm.localOnly) + controllers[controllerKey] = controllerInstance + + mm.log.V(2).Info("Adding scaledown instance to controller", "controller", controllerInstance, "scaledown", instance) + controllerInstance.AddInstance(instance, params) + + return kubeInformerFactory, controllerInstance, true +} + +func (mm *ActiveMQArtemisMessageMigrationControl) runDrainController(controller *draincontroller.Controller) { + if err := controller.Run(1); err != nil { + mm.log.Error(err, "Error running controller") + } +} diff --git a/controllers/activemqartemis_reconciler.go b/controllers/activemqartemis_reconciler.go index a3688a4cb..0ecc6af4e 100644 --- a/controllers/activemqartemis_reconciler.go +++ b/controllers/activemqartemis_reconciler.go @@ -108,13 +108,16 @@ type ActiveMQArtemisReconcilerImpl struct { customResource *brokerv1beta1.ActiveMQArtemis scheme *runtime.Scheme isOnOpenShift bool + mmControl *ActiveMQArtemisMessageMigrationControl } func NewActiveMQArtemisReconcilerImpl(customResource *brokerv1beta1.ActiveMQArtemis, parent *ActiveMQArtemisReconciler) *ActiveMQArtemisReconcilerImpl { + return &ActiveMQArtemisReconcilerImpl{ log: parent.log, customResource: customResource, scheme: parent.Scheme, + mmControl: parent.MmControl, requestedResources: make(map[reflect.Type]map[string]rtclient.Object), isOnOpenShift: parent.isOnOpenShift, } @@ -363,7 +366,7 @@ func (reconciler *ActiveMQArtemisReconcilerImpl) ProcessDeploymentPlan(customRes currentStatefulSet.Spec.Replicas = &replicas reconciler.log.V(2).Info("Now sync Message migration", "for cr", customResource.Name) - reconciler.syncMessageMigration(customResource, namer, client, scheme) + reconciler.syncMessageMigration(customResource, namer, scheme) if customResource.Spec.DeploymentPlan.PodDisruptionBudget != nil { reconciler.applyPodDisruptionBudget(customResource) @@ -477,44 +480,7 @@ func (reconciler *ActiveMQArtemisReconcilerImpl) appendSystemPropertiesForConsol environments.CreateOrAppend(currentSS.Spec.Template.Spec.Containers, &consoleProps) } -func (reconciler *ActiveMQArtemisReconcilerImpl) syncMessageMigration(customResource *brokerv1beta1.ActiveMQArtemis, namer common.Namers, client rtclient.Client, scheme *runtime.Scheme) { - - var err error = nil - var retrieveError error = nil - - namespacedName := types.NamespacedName{ - Name: customResource.Name, - Namespace: customResource.Namespace, - } - - ssNames := make(map[string]string) - ssNames["CRNAMESPACE"] = customResource.Namespace - ssNames["CRNAME"] = customResource.Name - ssNames["CLUSTERUSER"] = environments.GLOBAL_AMQ_CLUSTER_USER - ssNames["CLUSTERPASS"] = environments.GLOBAL_AMQ_CLUSTER_PASSWORD - ssNames["HEADLESSSVCNAMEVALUE"] = namer.SvcHeadlessNameBuilder.Name() - ssNames["PINGSVCNAMEVALUE"] = namer.SvcPingNameBuilder.Name() - ssNames["SERVICE_ACCOUNT"] = os.Getenv("SERVICE_ACCOUNT") - ssNames["SERVICE_ACCOUNT_NAME"] = os.Getenv("SERVICE_ACCOUNT") - ssNames["AMQ_CREDENTIALS_SECRET_NAME"] = namer.SecretsCredentialsNameBuilder.Name() - - scaledown := &brokerv1beta1.ActiveMQArtemisScaledown{ - TypeMeta: metav1.TypeMeta{ - APIVersion: "v1", - Kind: "ActiveMQArtemisScaledown", - }, - ObjectMeta: metav1.ObjectMeta{ - Labels: namer.LabelBuilder.Labels(), - Name: customResource.Name, - Namespace: customResource.Namespace, - Annotations: ssNames, - }, - Spec: brokerv1beta1.ActiveMQArtemisScaledownSpec{ - LocalOnly: isLocalOnly(), - Resources: customResource.Spec.DeploymentPlan.Resources, - }, - Status: brokerv1beta1.ActiveMQArtemisScaledownStatus{}, - } +func (reconciler *ActiveMQArtemisReconcilerImpl) syncMessageMigration(customResource *brokerv1beta1.ActiveMQArtemis, namer common.Namers, scheme *runtime.Scheme) { if nil == customResource.Spec.DeploymentPlan.MessageMigration { customResource.Spec.DeploymentPlan.MessageMigration = &defaultMessageMigration @@ -523,35 +489,31 @@ func (reconciler *ActiveMQArtemisReconcilerImpl) syncMessageMigration(customReso clustered := isClustered(customResource) if *customResource.Spec.DeploymentPlan.MessageMigration && clustered { + if !customResource.Spec.DeploymentPlan.PersistenceEnabled { reconciler.log.V(2).Info("Won't set up scaledown for non persistent deployment") return } - reconciler.log.V(2).Info("we need scaledown for this cr", "crName", customResource.Name, "scheme", scheme) - if err = resources.Retrieve(namespacedName, client, scaledown); err != nil { - // err means not found so create - reconciler.log.V(2).Info("Creating builtin drainer CR ", "scaledown", scaledown) - if retrieveError = resources.Create(customResource, client, scheme, scaledown); retrieveError == nil { - reconciler.log.V(2).Info("drainer created successfully", "drainer", scaledown) - } else { - reconciler.log.Error(retrieveError, "we have error retrieving drainer", "drainer", scaledown, "scheme", scheme) - } - } + + ssNames := make(map[string]string) + ssNames["CRNAMESPACE"] = customResource.Namespace + ssNames["CRNAME"] = customResource.Name + ssNames["CLUSTERUSER"] = environments.GLOBAL_AMQ_CLUSTER_USER + ssNames["CLUSTERPASS"] = environments.GLOBAL_AMQ_CLUSTER_PASSWORD + ssNames["HEADLESSSVCNAMEVALUE"] = namer.SvcHeadlessNameBuilder.Name() + ssNames["PINGSVCNAMEVALUE"] = namer.SvcPingNameBuilder.Name() + ssNames["SERVICE_ACCOUNT"] = os.Getenv("SERVICE_ACCOUNT") + ssNames["SERVICE_ACCOUNT_NAME"] = os.Getenv("SERVICE_ACCOUNT") + ssNames["AMQ_CREDENTIALS_SECRET_NAME"] = namer.SecretsCredentialsNameBuilder.Name() + + reconciler.mmControl.Setup(customResource, ssNames) + + reconciler.log.V(2).Info("set up message migration for this cr", "crName", customResource.Name, "scheme", scheme) } else { - if err = resources.Retrieve(namespacedName, client, scaledown); err == nil { - // ReleaseController(customResource.Name) - // err means not found so delete - resources.Delete(client, scaledown) - } + reconciler.mmControl.Cancel(&types.NamespacedName{Name: customResource.Name, Namespace: customResource.Namespace}) } } -func isLocalOnly() bool { - oprNamespace := os.Getenv("OPERATOR_NAMESPACE") - watchNamespace := os.Getenv("OPERATOR_WATCH_NAMESPACE") - return oprNamespace == watchNamespace -} - func (reconciler *ActiveMQArtemisReconcilerImpl) sourceEnvVarFromSecret(customResource *brokerv1beta1.ActiveMQArtemis, namer common.Namers, currentStatefulSet *appsv1.StatefulSet, envVars *map[string]ValueInfo, secretName string, client rtclient.Client) { var log = reconciler.log.WithName("controller_v1beta1activemqartemis").WithName("sourceEnvVarFromSecret") diff --git a/controllers/activemqartemis_reconciler_test.go b/controllers/activemqartemis_reconciler_test.go index b1f35eb9d..5fedd95ba 100644 --- a/controllers/activemqartemis_reconciler_test.go +++ b/controllers/activemqartemis_reconciler_test.go @@ -539,7 +539,7 @@ func TestProcess_TemplateIncludesLabelsServiceAndSecret(t *testing.T) { }}, }, } - outer := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log.WithName("TestProcess_TemplateIncludesLabelsServiceAndSecret"), isOpenshift) + outer := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log.WithName("TestProcess_TemplateIncludesLabelsServiceAndSecret"), isOpenshift, nil) reconciler := NewActiveMQArtemisReconcilerImpl(cr, outer) namer := MakeNamers(cr) @@ -616,7 +616,7 @@ func TestProcess_TemplateIncludesLabelsSecretRegexp(t *testing.T) { }, } - outer := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log.WithName("TestProcess_TemplateIncludesLabelsServiceAndSecret"), isOpenshift) + outer := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log.WithName("TestProcess_TemplateIncludesLabelsServiceAndSecret"), isOpenshift, nil) reconciler := NewActiveMQArtemisReconcilerImpl(cr, outer) namer := MakeNamers(cr) @@ -668,7 +668,7 @@ func TestProcess_TemplateDuplicateKeyReplacesOk(t *testing.T) { }, } - outer := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log.WithName("TestProcess_TemplateDuplicateKeyReplacesOk"), isOpenshift) + outer := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log.WithName("TestProcess_TemplateDuplicateKeyReplacesOk"), isOpenshift, nil) reconciler := NewActiveMQArtemisReconcilerImpl(cr, outer) namer := MakeNamers(cr) @@ -728,7 +728,7 @@ func TestProcess_TemplateKeyValue(t *testing.T) { }, } - outer := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log.WithName("test"), isOpenshift) + outer := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log.WithName("test"), isOpenshift, nil) reconciler := NewActiveMQArtemisReconcilerImpl(cr, outer) namer := MakeNamers(cr) @@ -817,7 +817,7 @@ func TestProcess_TemplateCustomAttributeIngress(t *testing.T) { }, } - outer := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log.WithName("test"), isOpenshift) + outer := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log.WithName("test"), isOpenshift, nil) reconciler := NewActiveMQArtemisReconcilerImpl(cr, outer) namer := MakeNamers(cr) @@ -878,7 +878,7 @@ func TestProcess_TemplateCustomAttributeMisSpellingIngress(t *testing.T) { }, } - outer := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log.WithName("test"), isOpenshift) + outer := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log.WithName("test"), isOpenshift, nil) reconciler := NewActiveMQArtemisReconcilerImpl(cr, outer) namer := MakeNamers(cr) @@ -928,7 +928,7 @@ func TestProcess_TemplateCustomAttributeContainerSecurityContext(t *testing.T) { }, } - outer := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log.WithName("test"), isOpenshift) + outer := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log.WithName("test"), isOpenshift, nil) reconciler := NewActiveMQArtemisReconcilerImpl(cr, outer) namer := MakeNamers(cr) @@ -981,7 +981,7 @@ func TestProcess_TemplateCustomAttributePriorityClassName(t *testing.T) { }, } - outer := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log.WithName("test"), isOpenshift) + outer := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log.WithName("test"), isOpenshift, nil) reconciler := NewActiveMQArtemisReconcilerImpl(cr, outer) namer := MakeNamers(cr) @@ -1029,7 +1029,7 @@ func TestNewPodTemplateSpecForCR_AppendsDebugArgs(t *testing.T) { }, } - outer := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log.WithName("test"), isOpenshift) + outer := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log.WithName("test"), isOpenshift, nil) reconciler := NewActiveMQArtemisReconcilerImpl(cr, outer) newSpec, err := reconciler.NewPodTemplateSpecForCR(cr, common.Namers{}, &v1.PodTemplateSpec{}, k8sClient) @@ -1056,7 +1056,7 @@ func TestNewPodTemplateSpecForCR_IncludesImagePullSecret(t *testing.T) { }, }, } - outer := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log, isOpenshift) + outer := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log, isOpenshift, nil) reconciler := NewActiveMQArtemisReconcilerImpl(cr, outer) newSpec, err := reconciler.NewPodTemplateSpecForCR(cr, common.Namers{}, &v1.PodTemplateSpec{}, k8sClient) @@ -1092,7 +1092,7 @@ func TestNewPodTemplateSpecForCR_IncludesTopologySpreadConstraints(t *testing.T) }, }, } - outer := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log, isOpenshift) + outer := NewActiveMQArtemisReconciler(&NillCluster{}, ctrl.Log, isOpenshift, nil) reconciler := NewActiveMQArtemisReconcilerImpl(cr, outer) newSpec, err := reconciler.NewPodTemplateSpecForCR(cr, common.Namers{}, &v1.PodTemplateSpec{}, k8sClient) diff --git a/controllers/activemqartemisscaledown_controller.go b/controllers/activemqartemisscaledown_controller.go deleted file mode 100644 index 55c8cec35..000000000 --- a/controllers/activemqartemisscaledown_controller.go +++ /dev/null @@ -1,164 +0,0 @@ -/* -Copyright 2021. - -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 controllers - -import ( - "context" - "os" - "time" - - brokerv1beta1 "github.com/artemiscloud/activemq-artemis-operator/api/v1beta1" - "github.com/artemiscloud/activemq-artemis-operator/pkg/draincontroller" - "github.com/go-logr/logr" - corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/runtime" - kubeinformers "k8s.io/client-go/informers" - "k8s.io/client-go/kubernetes" - "k8s.io/client-go/rest" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/client" -) - -var StopCh chan struct{} - -var controllers map[string]*draincontroller.Controller = make(map[string]*draincontroller.Controller) - -var kubeClient *kubernetes.Clientset - -// ActiveMQArtemisScaledownReconciler reconciles a ActiveMQArtemisScaledown object -type ActiveMQArtemisScaledownReconciler struct { - client.Client - Scheme *runtime.Scheme - Config *rest.Config - log logr.Logger -} - -func NewActiveMQArtemisScaledownReconciler(client client.Client, scheme *runtime.Scheme, config *rest.Config, logger logr.Logger) *ActiveMQArtemisScaledownReconciler { - return &ActiveMQArtemisScaledownReconciler{ - Client: client, - Scheme: scheme, - Config: config, - log: logger, - } -} - -//+kubebuilder:rbac:groups=broker.amq.io,namespace=activemq-artemis-operator,resources=activemqartemisscaledowns,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=broker.amq.io,namespace=activemq-artemis-operator,resources=activemqartemisscaledowns/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=broker.amq.io,namespace=activemq-artemis-operator,resources=activemqartemisscaledowns/finalizers,verbs=update - -// Reconcile is part of the main kubernetes reconciliation loop which aims to -// move the current state of the cluster closer to the desired state. -// TODO(user): Modify the Reconcile function to compare the state specified by -// the ActiveMQArtemisScaledown object against the actual cluster state, and then -// perform operations to make the cluster state reflect the state specified by -// the user. -// -// For more details, check Reconcile and its Result here: -// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.10.0/pkg/reconcile -func (r *ActiveMQArtemisScaledownReconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.Result, error) { - reqLogger := r.log.WithValues("Request.Namespace", request.Namespace, "Request.Name", request.Name, "Reconciling", "ActiveMQArtemisScaledown") - - // Fetch the ActiveMQArtemisScaledown instance - instance := &brokerv1beta1.ActiveMQArtemisScaledown{} - err := r.Client.Get(context.TODO(), request.NamespacedName, instance) - if err != nil { - if errors.IsNotFound(err) { - // Request object not found, could have been deleted after reconcile request. - // Owned objects are automatically garbage collected. For additional cleanup logic use finalizers. - // Return and don't requeue - return ctrl.Result{}, nil - } - // Error reading the object - requeue the request. - return ctrl.Result{}, err - } - - reqLogger.V(2).Info("scaling down", "localOnly:", instance.Spec.LocalOnly) - - kubeClient, err = kubernetes.NewForConfig(r.Config) - if err != nil { - reqLogger.Error(err, "Error building kubernetes clientset") - } - - kubeInformerFactory, drainControllerInstance, isNewController := r.getDrainController(instance.Spec.LocalOnly, request.Namespace, kubeClient, instance) - - if isNewController { - reqLogger.V(2).Info("Starting async factory...") - go kubeInformerFactory.Start(*drainControllerInstance.GetStopCh()) - - reqLogger.V(2).Info("Running drain controller async so multiple controllers can run...") - go r.runDrainController(drainControllerInstance) - } - - reqLogger.V(1).Info("OK, return result") - return ctrl.Result{}, nil -} - -func (r *ActiveMQArtemisScaledownReconciler) getDrainController(localOnly bool, namespace string, kubeClient *kubernetes.Clientset, instance *brokerv1beta1.ActiveMQArtemisScaledown) (kubeinformers.SharedInformerFactory, *draincontroller.Controller, bool) { - var kubeInformerFactory kubeinformers.SharedInformerFactory - var controllerInstance *draincontroller.Controller - controllerKey := "*" - if localOnly { - if namespace == "" { - bytes, err := os.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace") - if err != nil { - r.log.Error(err, "Using --localOnly without --namespace, but unable to determine namespace") - } - namespace = string(bytes) - r.log.V(2).Info("reading ns from file", "namespace", namespace) - } - controllerKey = namespace - } - if inst, ok := controllers[controllerKey]; ok { - r.log.V(2).Info("Drain controller already exists", "namespace", namespace) - inst.AddInstance(instance) - return nil, nil, false - } - - if localOnly { - // localOnly means there is only one target namespace and it is the same as operator's - r.log.V(2).Info("getting localOnly informer factory", "namespace", controllerKey) - r.log.V(2).Info("Configured to only operate on StatefulSets", "namespace", namespace) - kubeInformerFactory = kubeinformers.NewFilteredSharedInformerFactory(kubeClient, time.Second*30, namespace, nil) - } else { - r.log.V(2).Info("Creating informer factory to operate on StatefulSets across all namespaces") - kubeInformerFactory = kubeinformers.NewSharedInformerFactory(kubeClient, time.Second*30) - } - - r.log.V(2).Info("new drain controller...", "labels", instance.Labels) - controllerInstance = draincontroller.NewController(controllerKey, kubeClient, kubeInformerFactory, namespace, r.Client, instance, r.log) - controllers[controllerKey] = controllerInstance - - r.log.V(2).Info("Adding scaledown instance to controller", "controller", controllerInstance, "scaledown", instance) - controllerInstance.AddInstance(instance) - - return kubeInformerFactory, controllerInstance, true -} - -func (r *ActiveMQArtemisScaledownReconciler) runDrainController(controller *draincontroller.Controller) { - if err := controller.Run(1); err != nil { - r.log.Error(err, "Error running controller") - } -} - -// SetupWithManager sets up the controller with the Manager. -func (r *ActiveMQArtemisScaledownReconciler) SetupWithManager(mgr ctrl.Manager) error { - return ctrl.NewControllerManagedBy(mgr). - For(&brokerv1beta1.ActiveMQArtemisScaledown{}). - Owns(&corev1.Pod{}). - Complete(r) -} diff --git a/controllers/suite_test.go b/controllers/suite_test.go index 596c9cf3c..a06769df9 100644 --- a/controllers/suite_test.go +++ b/controllers/suite_test.go @@ -437,7 +437,14 @@ func createControllerManager(disableMetrics bool, watchNamespace string) { k8Manager, err = ctrl.NewManager(restConfig, mgrOptions) Expect(err).ToNot(HaveOccurred()) - brokerReconciler = NewActiveMQArtemisReconciler(k8Manager, ctrl.Log, isOpenshift) + messageMigrationControl := NewActiveMQArtemisMessageMigrationControl( + k8Manager.GetClient(), + k8Manager.GetScheme(), + k8Manager.GetConfig(), + ctrl.Log.WithName("ActiveMQArtemisMessageMigration"), + isLocal) + + brokerReconciler = NewActiveMQArtemisReconciler(k8Manager, ctrl.Log, isOpenshift, messageMigrationControl) if err = brokerReconciler.SetupWithManager(k8Manager); err != nil { ctrl.Log.Error(err, "unable to create controller", "controller", "ActiveMQArtemisReconciler") @@ -462,16 +469,6 @@ func createControllerManager(disableMetrics bool, watchNamespace string) { err = addressReconciler.SetupWithManager(k8Manager, managerCtx) Expect(err).ToNot(HaveOccurred(), "failed to create address reconciler") - scaleDownRconciler := &ActiveMQArtemisScaledownReconciler{ - Client: k8Manager.GetClient(), - Scheme: k8Manager.GetScheme(), - Config: k8Manager.GetConfig(), - log: ctrl.Log, - } - - err = scaleDownRconciler.SetupWithManager(k8Manager) - Expect(err).ShouldNot(HaveOccurred(), "failed to create scale down reconciler") - managerChannel = make(chan struct{}, 1) go func() { defer GinkgoRecover() diff --git a/deploy/activemq-artemis-operator.yaml b/deploy/activemq-artemis-operator.yaml index 918af0be5..b49ac7f24 100644 --- a/deploy/activemq-artemis-operator.yaml +++ b/deploy/activemq-artemis-operator.yaml @@ -5340,215 +5340,6 @@ spec: --- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.11.2 - name: activemqartemisscaledowns.broker.amq.io -spec: - group: broker.amq.io - names: - kind: ActiveMQArtemisScaledown - listKind: ActiveMQArtemisScaledownList - plural: activemqartemisscaledowns - shortNames: - - aad - singular: activemqartemisscaledown - scope: Namespaced - versions: - - deprecated: true - deprecationWarning: The ActiveMQArtemisScaledown CRD is deprecated, it is an internal only api - name: v1beta1 - schema: - openAPIV3Schema: - description: Provides internal message migration on clustered broker scaledown - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - description: ActiveMQArtemisScaledownSpec defines the desired state of ActiveMQArtemisScaledown - properties: - localOnly: - description: Triggered by main ActiveMQArtemis CRD messageMigration entry - type: boolean - resources: - description: Specifies the minimum/maximum amount of compute resources required/allowed - properties: - claims: - description: "Claims lists the names of resources, defined in spec.resourceClaims, that are used by this container. \n This is an alpha field and requires enabling the DynamicResourceAllocation feature gate. \n This field is immutable. It can only be set for containers." - items: - description: ResourceClaim references one entry in PodSpec.ResourceClaims. - properties: - name: - description: Name must match the name of one entry in pod.spec.resourceClaims of the Pod where this field is used. It makes that resource available inside a container. - type: string - required: - - name - type: object - type: array - x-kubernetes-list-map-keys: - - name - x-kubernetes-list-type: map - limits: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' - type: object - requests: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. Requests cannot exceed Limits. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' - type: object - type: object - required: - - localOnly - type: object - status: - description: ActiveMQArtemisScaledownStatus defines the observed state of ActiveMQArtemisScaledown - properties: - conditions: - description: Current state of the resource Conditions represent the latest available observations of an object's state - items: - description: "Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example, \n type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }" - properties: - lastTransitionTime: - description: lastTransitionTime is the last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. - format: date-time - type: string - message: - description: message is a human readable message indicating details about the transition. This may be an empty string. - maxLength: 32768 - type: string - observedGeneration: - description: observedGeneration represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance. - format: int64 - minimum: 0 - type: integer - reason: - description: reason contains a programmatic identifier indicating the reason for the condition's last transition. Producers of specific condition types may define expected values and meanings for this field, and whether the values are considered a guaranteed API. The value should be a CamelCase string. This field may not be empty. - maxLength: 1024 - minLength: 1 - pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ - type: string - status: - description: status of the condition, one of True, False, Unknown. - enum: - - "True" - - "False" - - Unknown - type: string - type: - description: type of condition in CamelCase or in foo.example.com/CamelCase. --- Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be useful (see .node.status.conditions), the ability to deconflict is important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) - maxLength: 316 - pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - type: array - type: object - type: object - served: true - storage: true - subresources: - status: {} - - deprecated: true - deprecationWarning: The ActiveMQArtemisScaledown CRD is deprecated, it is an internal only api - name: v2alpha1 - schema: - openAPIV3Schema: - description: ActiveMQArtemisScaledown is the Schema for the activemqartemisscaledowns API - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - description: ActiveMQArtemisScaledownSpec defines the desired state of ActiveMQArtemisScaledown - properties: - localOnly: - description: Triggered by main ActiveMQArtemis CRD messageMigration entry - type: boolean - required: - - localOnly - type: object - status: - description: ActiveMQArtemisScaledownStatus defines the observed state of ActiveMQArtemisScaledown - properties: - conditions: - description: Current state of the resource Conditions represent the latest available observations of an object's state - items: - description: "Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example, \n type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }" - properties: - lastTransitionTime: - description: lastTransitionTime is the last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. - format: date-time - type: string - message: - description: message is a human readable message indicating details about the transition. This may be an empty string. - maxLength: 32768 - type: string - observedGeneration: - description: observedGeneration represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance. - format: int64 - minimum: 0 - type: integer - reason: - description: reason contains a programmatic identifier indicating the reason for the condition's last transition. Producers of specific condition types may define expected values and meanings for this field, and whether the values are considered a guaranteed API. The value should be a CamelCase string. This field may not be empty. - maxLength: 1024 - minLength: 1 - pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ - type: string - status: - description: status of the condition, one of True, False, Unknown. - enum: - - "True" - - "False" - - Unknown - type: string - type: - description: type of condition in CamelCase or in foo.example.com/CamelCase. --- Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be useful (see .node.status.conditions), the ability to deconflict is important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) - maxLength: 316 - pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - type: array - type: object - type: object - served: true - storage: false - subresources: - status: {} ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.11.2 @@ -6672,32 +6463,6 @@ rules: - get - patch - update -- apiGroups: - - broker.amq.io - resources: - - activemqartemisscaledowns - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - broker.amq.io - resources: - - activemqartemisscaledowns/finalizers - verbs: - - update -- apiGroups: - - broker.amq.io - resources: - - activemqartemisscaledowns/status - verbs: - - get - - patch - - update - apiGroups: - broker.amq.io resources: diff --git a/deploy/cluster_role.yaml b/deploy/cluster_role.yaml index 04bbf9e29..09a4b18a7 100644 --- a/deploy/cluster_role.yaml +++ b/deploy/cluster_role.yaml @@ -90,32 +90,6 @@ rules: - get - patch - update -- apiGroups: - - broker.amq.io - resources: - - activemqartemisscaledowns - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - broker.amq.io - resources: - - activemqartemisscaledowns/finalizers - verbs: - - update -- apiGroups: - - broker.amq.io - resources: - - activemqartemisscaledowns/status - verbs: - - get - - patch - - update - apiGroups: - broker.amq.io resources: diff --git a/deploy/crds/broker_activemqartemisscaledown_crd.yaml b/deploy/crds/broker_activemqartemisscaledown_crd.yaml deleted file mode 100644 index 27c310ce0..000000000 --- a/deploy/crds/broker_activemqartemisscaledown_crd.yaml +++ /dev/null @@ -1,208 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - annotations: - controller-gen.kubebuilder.io/version: v0.11.2 - name: activemqartemisscaledowns.broker.amq.io -spec: - group: broker.amq.io - names: - kind: ActiveMQArtemisScaledown - listKind: ActiveMQArtemisScaledownList - plural: activemqartemisscaledowns - shortNames: - - aad - singular: activemqartemisscaledown - scope: Namespaced - versions: - - deprecated: true - deprecationWarning: The ActiveMQArtemisScaledown CRD is deprecated, it is an internal only api - name: v1beta1 - schema: - openAPIV3Schema: - description: Provides internal message migration on clustered broker scaledown - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - description: ActiveMQArtemisScaledownSpec defines the desired state of ActiveMQArtemisScaledown - properties: - localOnly: - description: Triggered by main ActiveMQArtemis CRD messageMigration entry - type: boolean - resources: - description: Specifies the minimum/maximum amount of compute resources required/allowed - properties: - claims: - description: "Claims lists the names of resources, defined in spec.resourceClaims, that are used by this container. \n This is an alpha field and requires enabling the DynamicResourceAllocation feature gate. \n This field is immutable. It can only be set for containers." - items: - description: ResourceClaim references one entry in PodSpec.ResourceClaims. - properties: - name: - description: Name must match the name of one entry in pod.spec.resourceClaims of the Pod where this field is used. It makes that resource available inside a container. - type: string - required: - - name - type: object - type: array - x-kubernetes-list-map-keys: - - name - x-kubernetes-list-type: map - limits: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: 'Limits describes the maximum amount of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' - type: object - requests: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. Requests cannot exceed Limits. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' - type: object - type: object - required: - - localOnly - type: object - status: - description: ActiveMQArtemisScaledownStatus defines the observed state of ActiveMQArtemisScaledown - properties: - conditions: - description: Current state of the resource Conditions represent the latest available observations of an object's state - items: - description: "Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example, \n type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }" - properties: - lastTransitionTime: - description: lastTransitionTime is the last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. - format: date-time - type: string - message: - description: message is a human readable message indicating details about the transition. This may be an empty string. - maxLength: 32768 - type: string - observedGeneration: - description: observedGeneration represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance. - format: int64 - minimum: 0 - type: integer - reason: - description: reason contains a programmatic identifier indicating the reason for the condition's last transition. Producers of specific condition types may define expected values and meanings for this field, and whether the values are considered a guaranteed API. The value should be a CamelCase string. This field may not be empty. - maxLength: 1024 - minLength: 1 - pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ - type: string - status: - description: status of the condition, one of True, False, Unknown. - enum: - - "True" - - "False" - - Unknown - type: string - type: - description: type of condition in CamelCase or in foo.example.com/CamelCase. --- Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be useful (see .node.status.conditions), the ability to deconflict is important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) - maxLength: 316 - pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - type: array - type: object - type: object - served: true - storage: true - subresources: - status: {} - - deprecated: true - deprecationWarning: The ActiveMQArtemisScaledown CRD is deprecated, it is an internal only api - name: v2alpha1 - schema: - openAPIV3Schema: - description: ActiveMQArtemisScaledown is the Schema for the activemqartemisscaledowns API - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - description: ActiveMQArtemisScaledownSpec defines the desired state of ActiveMQArtemisScaledown - properties: - localOnly: - description: Triggered by main ActiveMQArtemis CRD messageMigration entry - type: boolean - required: - - localOnly - type: object - status: - description: ActiveMQArtemisScaledownStatus defines the observed state of ActiveMQArtemisScaledown - properties: - conditions: - description: Current state of the resource Conditions represent the latest available observations of an object's state - items: - description: "Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example, \n type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }" - properties: - lastTransitionTime: - description: lastTransitionTime is the last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. - format: date-time - type: string - message: - description: message is a human readable message indicating details about the transition. This may be an empty string. - maxLength: 32768 - type: string - observedGeneration: - description: observedGeneration represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance. - format: int64 - minimum: 0 - type: integer - reason: - description: reason contains a programmatic identifier indicating the reason for the condition's last transition. Producers of specific condition types may define expected values and meanings for this field, and whether the values are considered a guaranteed API. The value should be a CamelCase string. This field may not be empty. - maxLength: 1024 - minLength: 1 - pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ - type: string - status: - description: status of the condition, one of True, False, Unknown. - enum: - - "True" - - "False" - - Unknown - type: string - type: - description: type of condition in CamelCase or in foo.example.com/CamelCase. --- Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be useful (see .node.status.conditions), the ability to deconflict is important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) - maxLength: 316 - pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - type: array - type: object - type: object - served: true - storage: false - subresources: - status: {} diff --git a/deploy/role.yaml b/deploy/role.yaml index d938bd98f..3131d7448 100644 --- a/deploy/role.yaml +++ b/deploy/role.yaml @@ -90,32 +90,6 @@ rules: - get - patch - update -- apiGroups: - - broker.amq.io - resources: - - activemqartemisscaledowns - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - broker.amq.io - resources: - - activemqartemisscaledowns/finalizers - verbs: - - update -- apiGroups: - - broker.amq.io - resources: - - activemqartemisscaledowns/status - verbs: - - get - - patch - - update - apiGroups: - broker.amq.io resources: diff --git a/main.go b/main.go index 5f6d8b0cf..315c576b3 100644 --- a/main.go +++ b/main.go @@ -235,6 +235,13 @@ func main() { setupAccountName(clnt, context.TODO(), oprNamespace, name) } + messageMigrationControl := controllers.NewActiveMQArtemisMessageMigrationControl( + mgr.GetClient(), + mgr.GetScheme(), + mgr.GetConfig(), + ctrl.Log.WithName("ActiveMQArtemisMessageMigration"), + isLocal) + isOpenshift, err := common.DetectOpenshiftWith(cfg) if err != nil { setupLog.Error(err, "can't determine api server type") @@ -244,7 +251,8 @@ func main() { brokerReconciler := controllers.NewActiveMQArtemisReconciler( mgr, ctrl.Log.WithName("ActiveMQArtemisReconciler"), - isOpenshift) + isOpenshift, + messageMigrationControl) if err = brokerReconciler.SetupWithManager(mgr); err != nil { setupLog.Error(err, "unable to create controller", "controller", "ActiveMQArtemis") @@ -261,16 +269,18 @@ func main() { os.Exit(1) } - scaledownReconciler := controllers.NewActiveMQArtemisScaledownReconciler( - mgr.GetClient(), - mgr.GetScheme(), - mgr.GetConfig(), - ctrl.Log.WithName("ActiveMQArtemisScaledownReconciler")) + /* + scaledownReconciler := controllers.NewActiveMQArtemisScaledownReconciler( + mgr.GetClient(), + mgr.GetScheme(), + mgr.GetConfig(), + ctrl.Log.WithName("ActiveMQArtemisScaledownReconciler")) - if err = scaledownReconciler.SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "ActiveMQArtemisScaledown") - os.Exit(1) - } + if err = scaledownReconciler.SetupWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "ActiveMQArtemisScaledown") + os.Exit(1) + } + */ securityReconciler := controllers.NewActiveMQArtemisSecurityReconciler( mgr.GetClient(), diff --git a/pkg/client/clientset/versioned/typed/broker/v2alpha1/activemqartemisscaledown.go b/pkg/client/clientset/versioned/typed/broker/v2alpha1/activemqartemisscaledown.go deleted file mode 100644 index 5fe9f7867..000000000 --- a/pkg/client/clientset/versioned/typed/broker/v2alpha1/activemqartemisscaledown.go +++ /dev/null @@ -1,176 +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 v2alpha1 - -import ( - "context" - - v2alpha1 "github.com/artemiscloud/activemq-artemis-operator/api/v2alpha1" - scheme "github.com/artemiscloud/activemq-artemis-operator/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" -) - -// ActiveMQArtemisScaledownsGetter has a method to return a ActiveMQArtemisScaledownInterface. -// A group's client should implement this interface. -type ActiveMQArtemisScaledownsGetter interface { - ActiveMQArtemisScaledowns(namespace string) ActiveMQArtemisScaledownInterface -} - -// ActiveMQArtemisScaledownInterface has methods to work with ActiveMQArtemisScaledown resources. -type ActiveMQArtemisScaledownInterface interface { - Create(*v2alpha1.ActiveMQArtemisScaledown) (*v2alpha1.ActiveMQArtemisScaledown, error) - Update(*v2alpha1.ActiveMQArtemisScaledown) (*v2alpha1.ActiveMQArtemisScaledown, error) - UpdateStatus(*v2alpha1.ActiveMQArtemisScaledown) (*v2alpha1.ActiveMQArtemisScaledown, error) - Delete(name string, options *v1.DeleteOptions) error - DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error - Get(name string, options v1.GetOptions) (*v2alpha1.ActiveMQArtemisScaledown, error) - List(opts v1.ListOptions) (*v2alpha1.ActiveMQArtemisScaledownList, error) - Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v2alpha1.ActiveMQArtemisScaledown, err error) - //ActiveMQArtemisScaledownExpansion -} - -// activeMQArtemisScaledowns implements ActiveMQArtemisScaledownInterface -type activeMQArtemisScaledowns struct { - client rest.Interface - ns string -} - -// newActiveMQArtemisScaledowns returns a ActiveMQArtemisScaledowns -func newActiveMQArtemisScaledowns(c *BrokerV2alpha1Client, namespace string) *activeMQArtemisScaledowns { - return &activeMQArtemisScaledowns{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the activeMQArtemisScaledown, and returns the corresponding activeMQArtemisScaledown object, and an error if there is any. -func (c *activeMQArtemisScaledowns) Get(name string, options v1.GetOptions) (result *v2alpha1.ActiveMQArtemisScaledown, err error) { - result = &v2alpha1.ActiveMQArtemisScaledown{} - err = c.client.Get(). - Namespace(c.ns). - Resource("activemqartemisscaledowns"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(context.TODO()). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of ActiveMQArtemisScaledowns that match those selectors. -func (c *activeMQArtemisScaledowns) List(opts v1.ListOptions) (result *v2alpha1.ActiveMQArtemisScaledownList, err error) { - result = &v2alpha1.ActiveMQArtemisScaledownList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("activemqartemisscaledowns"). - VersionedParams(&opts, scheme.ParameterCodec). - Do(context.TODO()). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested activeMQArtemisScaledowns. -func (c *activeMQArtemisScaledowns) Watch(opts v1.ListOptions) (watch.Interface, error) { - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("activemqartemisscaledowns"). - VersionedParams(&opts, scheme.ParameterCodec). - Watch(context.TODO()) -} - -// Create takes the representation of a activeMQArtemisScaledown and creates it. Returns the server's representation of the activeMQArtemisScaledown, and an error, if there is any. -func (c *activeMQArtemisScaledowns) Create(activeMQArtemisScaledown *v2alpha1.ActiveMQArtemisScaledown) (result *v2alpha1.ActiveMQArtemisScaledown, err error) { - result = &v2alpha1.ActiveMQArtemisScaledown{} - err = c.client.Post(). - Namespace(c.ns). - Resource("activemqartemisscaledowns"). - Body(activeMQArtemisScaledown). - Do(context.TODO()). - Into(result) - return -} - -// Update takes the representation of a activeMQArtemisScaledown and updates it. Returns the server's representation of the activeMQArtemisScaledown, and an error, if there is any. -func (c *activeMQArtemisScaledowns) Update(activeMQArtemisScaledown *v2alpha1.ActiveMQArtemisScaledown) (result *v2alpha1.ActiveMQArtemisScaledown, err error) { - result = &v2alpha1.ActiveMQArtemisScaledown{} - err = c.client.Put(). - Namespace(c.ns). - Resource("activemqartemisscaledowns"). - Name(activeMQArtemisScaledown.Name). - Body(activeMQArtemisScaledown). - Do(context.TODO()). - 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 *activeMQArtemisScaledowns) UpdateStatus(activeMQArtemisScaledown *v2alpha1.ActiveMQArtemisScaledown) (result *v2alpha1.ActiveMQArtemisScaledown, err error) { - result = &v2alpha1.ActiveMQArtemisScaledown{} - err = c.client.Put(). - Namespace(c.ns). - Resource("activemqartemisscaledowns"). - Name(activeMQArtemisScaledown.Name). - SubResource("status"). - Body(activeMQArtemisScaledown). - Do(context.TODO()). - Into(result) - return -} - -// Delete takes name of the activeMQArtemisScaledown and deletes it. Returns an error if one occurs. -func (c *activeMQArtemisScaledowns) Delete(name string, options *v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("activemqartemisscaledowns"). - Name(name). - Body(options). - Do(context.TODO()). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *activeMQArtemisScaledowns) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("activemqartemisscaledowns"). - VersionedParams(&listOptions, scheme.ParameterCodec). - Body(options). - Do(context.TODO()). - Error() -} - -// Patch applies the patch and returns the patched activeMQArtemisScaledown. -func (c *activeMQArtemisScaledowns) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v2alpha1.ActiveMQArtemisScaledown, err error) { - result = &v2alpha1.ActiveMQArtemisScaledown{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("activemqartemisscaledowns"). - SubResource(subresources...). - Name(name). - Body(data). - Do(context.TODO()). - Into(result) - return -} diff --git a/pkg/client/clientset/versioned/typed/broker/v2alpha1/broker_client.go b/pkg/client/clientset/versioned/typed/broker/v2alpha1/broker_client.go index c2ae72c06..1cb9cb2d2 100644 --- a/pkg/client/clientset/versioned/typed/broker/v2alpha1/broker_client.go +++ b/pkg/client/clientset/versioned/typed/broker/v2alpha1/broker_client.go @@ -25,7 +25,6 @@ type BrokerV2alpha1Interface interface { RESTClient() rest.Interface ActiveMQArtemisesGetter ActiveMQArtemisAddressesGetter - ActiveMQArtemisScaledownsGetter } // BrokerV2alpha1Client is used to interact with features provided by the broker.amq.io group. @@ -41,10 +40,6 @@ func (c *BrokerV2alpha1Client) ActiveMQArtemisAddresses(namespace string) Active return newActiveMQArtemisAddresses(c, namespace) } -func (c *BrokerV2alpha1Client) ActiveMQArtemisScaledowns(namespace string) ActiveMQArtemisScaledownInterface { - return newActiveMQArtemisScaledowns(c, namespace) -} - // NewForConfig creates a new BrokerV2alpha1Client for the given config. func NewForConfig(c *rest.Config) (*BrokerV2alpha1Client, error) { config := *c diff --git a/pkg/client/clientset/versioned/typed/broker/v2alpha1/fake/fake_activemqartemisscaledown.go b/pkg/client/clientset/versioned/typed/broker/v2alpha1/fake/fake_activemqartemisscaledown.go deleted file mode 100644 index 3d491088b..000000000 --- a/pkg/client/clientset/versioned/typed/broker/v2alpha1/fake/fake_activemqartemisscaledown.go +++ /dev/null @@ -1,140 +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 ( - v2alpha1 "github.com/artemiscloud/activemq-artemis-operator/api/v2alpha1" - 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" -) - -// FakeActiveMQArtemisScaledowns implements ActiveMQArtemisScaledownInterface -type FakeActiveMQArtemisScaledowns struct { - Fake *FakeBrokerV2alpha1 - ns string -} - -var activemqartemisscaledownsResource = schema.GroupVersionResource{Group: "broker.amq.io", Version: "v2alpha1", Resource: "activemqartemisscaledowns"} - -var activemqartemisscaledownsKind = schema.GroupVersionKind{Group: "broker.amq.io", Version: "v2alpha1", Kind: "ActiveMQArtemisScaledown"} - -// Get takes name of the activeMQArtemisScaledown, and returns the corresponding activeMQArtemisScaledown object, and an error if there is any. -func (c *FakeActiveMQArtemisScaledowns) Get(name string, options v1.GetOptions) (result *v2alpha1.ActiveMQArtemisScaledown, err error) { - obj, err := c.Fake. - Invokes(testing.NewGetAction(activemqartemisscaledownsResource, c.ns, name), &v2alpha1.ActiveMQArtemisScaledown{}) - - if obj == nil { - return nil, err - } - return obj.(*v2alpha1.ActiveMQArtemisScaledown), err -} - -// List takes label and field selectors, and returns the list of ActiveMQArtemisScaledowns that match those selectors. -func (c *FakeActiveMQArtemisScaledowns) List(opts v1.ListOptions) (result *v2alpha1.ActiveMQArtemisScaledownList, err error) { - obj, err := c.Fake. - Invokes(testing.NewListAction(activemqartemisscaledownsResource, activemqartemisscaledownsKind, c.ns, opts), &v2alpha1.ActiveMQArtemisScaledownList{}) - - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v2alpha1.ActiveMQArtemisScaledownList{ListMeta: obj.(*v2alpha1.ActiveMQArtemisScaledownList).ListMeta} - for _, item := range obj.(*v2alpha1.ActiveMQArtemisScaledownList).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 activeMQArtemisScaledowns. -func (c *FakeActiveMQArtemisScaledowns) Watch(opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewWatchAction(activemqartemisscaledownsResource, c.ns, opts)) - -} - -// Create takes the representation of a activeMQArtemisScaledown and creates it. Returns the server's representation of the activeMQArtemisScaledown, and an error, if there is any. -func (c *FakeActiveMQArtemisScaledowns) Create(activeMQArtemisScaledown *v2alpha1.ActiveMQArtemisScaledown) (result *v2alpha1.ActiveMQArtemisScaledown, err error) { - obj, err := c.Fake. - Invokes(testing.NewCreateAction(activemqartemisscaledownsResource, c.ns, activeMQArtemisScaledown), &v2alpha1.ActiveMQArtemisScaledown{}) - - if obj == nil { - return nil, err - } - return obj.(*v2alpha1.ActiveMQArtemisScaledown), err -} - -// Update takes the representation of a activeMQArtemisScaledown and updates it. Returns the server's representation of the activeMQArtemisScaledown, and an error, if there is any. -func (c *FakeActiveMQArtemisScaledowns) Update(activeMQArtemisScaledown *v2alpha1.ActiveMQArtemisScaledown) (result *v2alpha1.ActiveMQArtemisScaledown, err error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateAction(activemqartemisscaledownsResource, c.ns, activeMQArtemisScaledown), &v2alpha1.ActiveMQArtemisScaledown{}) - - if obj == nil { - return nil, err - } - return obj.(*v2alpha1.ActiveMQArtemisScaledown), 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 *FakeActiveMQArtemisScaledowns) UpdateStatus(activeMQArtemisScaledown *v2alpha1.ActiveMQArtemisScaledown) (*v2alpha1.ActiveMQArtemisScaledown, error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(activemqartemisscaledownsResource, "status", c.ns, activeMQArtemisScaledown), &v2alpha1.ActiveMQArtemisScaledown{}) - - if obj == nil { - return nil, err - } - return obj.(*v2alpha1.ActiveMQArtemisScaledown), err -} - -// Delete takes name of the activeMQArtemisScaledown and deletes it. Returns an error if one occurs. -func (c *FakeActiveMQArtemisScaledowns) Delete(name string, options *v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewDeleteAction(activemqartemisscaledownsResource, c.ns, name), &v2alpha1.ActiveMQArtemisScaledown{}) - - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeActiveMQArtemisScaledowns) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(activemqartemisscaledownsResource, c.ns, listOptions) - - _, err := c.Fake.Invokes(action, &v2alpha1.ActiveMQArtemisScaledownList{}) - return err -} - -// Patch applies the patch and returns the patched activeMQArtemisScaledown. -func (c *FakeActiveMQArtemisScaledowns) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v2alpha1.ActiveMQArtemisScaledown, err error) { - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(activemqartemisscaledownsResource, c.ns, name, pt, data, subresources...), &v2alpha1.ActiveMQArtemisScaledown{}) - - if obj == nil { - return nil, err - } - return obj.(*v2alpha1.ActiveMQArtemisScaledown), err -} diff --git a/pkg/client/clientset/versioned/typed/broker/v2alpha1/fake/fake_broker_client.go b/pkg/client/clientset/versioned/typed/broker/v2alpha1/fake/fake_broker_client.go index 53bc6f2b0..29a38ed13 100644 --- a/pkg/client/clientset/versioned/typed/broker/v2alpha1/fake/fake_broker_client.go +++ b/pkg/client/clientset/versioned/typed/broker/v2alpha1/fake/fake_broker_client.go @@ -34,10 +34,6 @@ func (c *FakeBrokerV2alpha1) ActiveMQArtemisAddresses(namespace string) v2alpha1 return &FakeActiveMQArtemisAddresses{c, namespace} } -func (c *FakeBrokerV2alpha1) ActiveMQArtemisScaledowns(namespace string) v2alpha1.ActiveMQArtemisScaledownInterface { - return &FakeActiveMQArtemisScaledowns{c, namespace} -} - // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. func (c *FakeBrokerV2alpha1) RESTClient() rest.Interface { diff --git a/pkg/client/informers/externalversions/broker/v2alpha1/activemqartemisscaledown.go b/pkg/client/informers/externalversions/broker/v2alpha1/activemqartemisscaledown.go deleted file mode 100644 index b4d386c17..000000000 --- a/pkg/client/informers/externalversions/broker/v2alpha1/activemqartemisscaledown.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 informer-gen. DO NOT EDIT. - -package v2alpha1 - -import ( - time "time" - - brokerv2alpha1 "github.com/artemiscloud/activemq-artemis-operator/api/v2alpha1" - versioned "github.com/artemiscloud/activemq-artemis-operator/pkg/client/clientset/versioned" - internalinterfaces "github.com/artemiscloud/activemq-artemis-operator/pkg/client/informers/externalversions/internalinterfaces" - v2alpha1 "github.com/artemiscloud/activemq-artemis-operator/pkg/client/listers/broker/v2alpha1" - 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" -) - -// ActiveMQArtemisScaledownInformer provides access to a shared informer and lister for -// ActiveMQArtemisScaledowns. -type ActiveMQArtemisScaledownInformer interface { - Informer() cache.SharedIndexInformer - Lister() v2alpha1.ActiveMQArtemisScaledownLister -} - -type activeMQArtemisScaledownInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc - namespace string -} - -// NewActiveMQArtemisScaledownInformer constructs a new informer for ActiveMQArtemisScaledown 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 NewActiveMQArtemisScaledownInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredActiveMQArtemisScaledownInformer(client, namespace, resyncPeriod, indexers, nil) -} - -// NewFilteredActiveMQArtemisScaledownInformer constructs a new informer for ActiveMQArtemisScaledown 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 NewFilteredActiveMQArtemisScaledownInformer(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.BrokerV2alpha1().ActiveMQArtemisScaledowns(namespace).List(options) - }, - WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.BrokerV2alpha1().ActiveMQArtemisScaledowns(namespace).Watch(options) - }, - }, - &brokerv2alpha1.ActiveMQArtemisScaledown{}, - resyncPeriod, - indexers, - ) -} - -func (f *activeMQArtemisScaledownInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredActiveMQArtemisScaledownInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) -} - -func (f *activeMQArtemisScaledownInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&brokerv2alpha1.ActiveMQArtemisScaledown{}, f.defaultInformer) -} - -func (f *activeMQArtemisScaledownInformer) Lister() v2alpha1.ActiveMQArtemisScaledownLister { - return v2alpha1.NewActiveMQArtemisScaledownLister(f.Informer().GetIndexer()) -} diff --git a/pkg/client/informers/externalversions/broker/v2alpha1/interface.go b/pkg/client/informers/externalversions/broker/v2alpha1/interface.go index 806a58cf9..d93682afa 100644 --- a/pkg/client/informers/externalversions/broker/v2alpha1/interface.go +++ b/pkg/client/informers/externalversions/broker/v2alpha1/interface.go @@ -28,8 +28,6 @@ type Interface interface { ActiveMQArtemises() ActiveMQArtemisInformer // ActiveMQArtemisAddresses returns a ActiveMQArtemisAddressInformer. ActiveMQArtemisAddresses() ActiveMQArtemisAddressInformer - // ActiveMQArtemisScaledowns returns a ActiveMQArtemisScaledownInformer. - ActiveMQArtemisScaledowns() ActiveMQArtemisScaledownInformer } type version struct { @@ -52,8 +50,3 @@ func (v *version) ActiveMQArtemises() ActiveMQArtemisInformer { func (v *version) ActiveMQArtemisAddresses() ActiveMQArtemisAddressInformer { return &activeMQArtemisAddressInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } - -// ActiveMQArtemisScaledowns returns a ActiveMQArtemisScaledownInformer. -func (v *version) ActiveMQArtemisScaledowns() ActiveMQArtemisScaledownInformer { - return &activeMQArtemisScaledownInformer{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 index b3df8e498..2d5aba45d 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -57,9 +57,6 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Broker().V2alpha1().ActiveMQArtemises().Informer()}, nil case v2alpha1.GroupVersion.WithResource("activemqartemisaddresses"): return &genericInformer{resource: resource.GroupResource(), informer: f.Broker().V2alpha1().ActiveMQArtemisAddresses().Informer()}, nil - case v2alpha1.GroupVersion.WithResource("activemqartemisscaledowns"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Broker().V2alpha1().ActiveMQArtemisScaledowns().Informer()}, nil - } return nil, fmt.Errorf("no informer found for %v", resource) diff --git a/pkg/client/listers/broker/v2alpha1/activemqartemisscaledown.go b/pkg/client/listers/broker/v2alpha1/activemqartemisscaledown.go deleted file mode 100644 index d18421b92..000000000 --- a/pkg/client/listers/broker/v2alpha1/activemqartemisscaledown.go +++ /dev/null @@ -1,94 +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 v2alpha1 - -import ( - "fmt" - v2alpha1 "github.com/artemiscloud/activemq-artemis-operator/api/v2alpha1" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/tools/cache" -) - -// ActiveMQArtemisScaledownLister helps list ActiveMQArtemisScaledowns. -type ActiveMQArtemisScaledownLister interface { - // List lists all ActiveMQArtemisScaledowns in the indexer. - List(selector labels.Selector) (ret []*v2alpha1.ActiveMQArtemisScaledown, err error) - // ActiveMQArtemisScaledowns returns an object that can list and get ActiveMQArtemisScaledowns. - ActiveMQArtemisScaledowns(namespace string) ActiveMQArtemisScaledownNamespaceLister - ActiveMQArtemisScaledownListerExpansion -} - -// activeMQArtemisScaledownLister implements the ActiveMQArtemisScaledownLister interface. -type activeMQArtemisScaledownLister struct { - indexer cache.Indexer -} - -// NewActiveMQArtemisScaledownLister returns a new ActiveMQArtemisScaledownLister. -func NewActiveMQArtemisScaledownLister(indexer cache.Indexer) ActiveMQArtemisScaledownLister { - return &activeMQArtemisScaledownLister{indexer: indexer} -} - -// List lists all ActiveMQArtemisScaledowns in the indexer. -func (s *activeMQArtemisScaledownLister) List(selector labels.Selector) (ret []*v2alpha1.ActiveMQArtemisScaledown, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v2alpha1.ActiveMQArtemisScaledown)) - }) - return ret, err -} - -// ActiveMQArtemisScaledowns returns an object that can list and get ActiveMQArtemisScaledowns. -func (s *activeMQArtemisScaledownLister) ActiveMQArtemisScaledowns(namespace string) ActiveMQArtemisScaledownNamespaceLister { - return activeMQArtemisScaledownNamespaceLister{indexer: s.indexer, namespace: namespace} -} - -// ActiveMQArtemisScaledownNamespaceLister helps list and get ActiveMQArtemisScaledowns. -type ActiveMQArtemisScaledownNamespaceLister interface { - // List lists all ActiveMQArtemisScaledowns in the indexer for a given namespace. - List(selector labels.Selector) (ret []*v2alpha1.ActiveMQArtemisScaledown, err error) - // Get retrieves the ActiveMQArtemisScaledown from the indexer for a given namespace and name. - Get(name string) (*v2alpha1.ActiveMQArtemisScaledown, error) - ActiveMQArtemisScaledownNamespaceListerExpansion -} - -// activeMQArtemisScaledownNamespaceLister implements the ActiveMQArtemisScaledownNamespaceLister -// interface. -type activeMQArtemisScaledownNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all ActiveMQArtemisScaledowns in the indexer for a given namespace. -func (s activeMQArtemisScaledownNamespaceLister) List(selector labels.Selector) (ret []*v2alpha1.ActiveMQArtemisScaledown, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v2alpha1.ActiveMQArtemisScaledown)) - }) - return ret, err -} - -// Get retrieves the ActiveMQArtemisScaledown from the indexer for a given namespace and name. -func (s activeMQArtemisScaledownNamespaceLister) Get(name string) (*v2alpha1.ActiveMQArtemisScaledown, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, fmt.Errorf("activemqartemisscaledown not found: %s", name) - } - return obj.(*v2alpha1.ActiveMQArtemisScaledown), nil -} diff --git a/pkg/draincontroller/controller.go b/pkg/draincontroller/controller.go index b2d4cc5f8..2ff0ad63a 100644 --- a/pkg/draincontroller/controller.go +++ b/pkg/draincontroller/controller.go @@ -115,7 +115,7 @@ type Controller struct { // sts --> ssNames ssNamesMap map[types.NamespacedName]map[string]string - ssToCrMap map[types.NamespacedName]*brokerv1beta1.ActiveMQArtemisScaledown + ssToCrMap map[types.NamespacedName]*brokerv1beta1.ActiveMQArtemis ssLabels map[string]string @@ -136,12 +136,13 @@ func NewController( // controller name is the target namespace // or "*" for all namespaces case controllerName string, + instance *brokerv1beta1.ActiveMQArtemis, kubeclientset kubernetes.Interface, kubeInformerFactory kubeinformers.SharedInformerFactory, namespace string, client client.Client, - instance *brokerv1beta1.ActiveMQArtemisScaledown, - logger logr.Logger) *Controller { + logger logr.Logger, + localOnly bool) *Controller { // obtain references to shared index informers for the Deployment and Foo // types. @@ -170,10 +171,10 @@ func NewController( podsSynced: podInformer.Informer().HasSynced, workqueue: workqueue.NewNamedRateLimitingQueue(itemExponentialFailureRateLimiter, "StatefulSets"), recorder: recorder, - localOnly: instance.Spec.LocalOnly, - resources: instance.Spec.Resources, + localOnly: localOnly, + resources: instance.Spec.DeploymentPlan.Resources, ssNamesMap: make(map[types.NamespacedName]map[string]string), - ssToCrMap: make(map[types.NamespacedName]*brokerv1beta1.ActiveMQArtemisScaledown), + ssToCrMap: make(map[types.NamespacedName]*brokerv1beta1.ActiveMQArtemis), ssLabels: instance.Labels, stopCh: make(chan struct{}), @@ -213,13 +214,22 @@ func NewController( return controller } -func (c *Controller) AddInstance(instance *brokerv1beta1.ActiveMQArtemisScaledown) { +func (c *Controller) RemoveInstance(instance *types.NamespacedName) { namespacedName := types.NamespacedName{ - Namespace: instance.Annotations["CRNAMESPACE"], - Name: namer.CrToSS(instance.Annotations["CRNAME"]), + Namespace: instance.Namespace, + Name: namer.CrToSS(instance.Name), + } + delete(c.ssNamesMap, namespacedName) + delete(c.ssToCrMap, namespacedName) +} + +func (c *Controller) AddInstance(instance *brokerv1beta1.ActiveMQArtemis, params map[string]string) { + namespacedName := types.NamespacedName{ + Namespace: params["CRNAMESPACE"], + Name: namer.CrToSS(params["CRNAME"]), } c.log.V(1).Info("adding a new scaledown instance", "key", namespacedName) - c.ssNamesMap[namespacedName] = instance.Annotations + c.ssNamesMap[namespacedName] = params c.log.V(2).Info("Added new instance", "key", namespacedName, "now values", len(c.ssNamesMap)) c.ssToCrMap[namespacedName] = instance } @@ -372,11 +382,6 @@ func (c *Controller) processStatefulSet(sts *appsv1.StatefulSet) error { } c.log.V(2).Info("Statefulset " + sts.Name + " Spec.VolumeClaimTemplates is " + strconv.Itoa((len(sts.Spec.VolumeClaimTemplates)))) - //if sts.Annotations[AnnotationDrainerPodTemplate] == "" { - // log.V(1).Info("Ignoring StatefulSet '%s' because it does not define a drain pod template.", sts.Name) - // return nil - //} - claimsGroupedByOrdinal, err := c.getClaims(sts) if err != nil { err = fmt.Errorf("error while getting list of PVCs in namespace %s: %s", sts.Namespace, err)