Skip to content

Commit 3c1edd3

Browse files
committed
replace ObjectReference on local PodReference; cleanup bundle
Signed-off-by: vaspahomov <vas2142553@gmail.com>
1 parent 6bf506f commit 3c1edd3

File tree

6 files changed

+24
-110
lines changed

6 files changed

+24
-110
lines changed

api/v1beta1/nodemaintenance_types.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ limitations under the License.
1717
package v1beta1
1818

1919
import (
20-
corev1 "k8s.io/api/core/v1"
2120
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2221
)
2322

@@ -54,6 +53,17 @@ type NodeMaintenanceSpec struct {
5453
Reason string `json:"reason,omitempty"`
5554
}
5655

56+
type PodReference struct {
57+
// Namespace of the referent pod.
58+
// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
59+
// +optional
60+
Namespace string `json:"namespace,omitempty" protobuf:"bytes,2,opt,name=namespace"`
61+
// Name of the referent pod.
62+
// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
63+
// +optional
64+
Name string `json:"name,omitempty" protobuf:"bytes,3,opt,name=name"`
65+
}
66+
5767
// NodeMaintenanceStatus defines the observed state of NodeMaintenance
5868
type NodeMaintenanceStatus struct {
5969
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
@@ -76,7 +86,7 @@ type NodeMaintenanceStatus struct {
7686
PendingPods []string `json:"pendingPods,omitempty"`
7787
// PendingPodsRefs is a list of refs of pending pods for eviction
7888
//+operator-sdk:csv:customresourcedefinitions:type=status
79-
PendingPodsRefs []corev1.ObjectReference `json:"pendingPodsRefs,omitempty"`
89+
PendingPodsRefs []PodReference `json:"pendingPodsRefs,omitempty"`
8090
// TotalPods is the total number of all pods on the node from the start
8191
//+operator-sdk:csv:customresourcedefinitions:type=status
8292
TotalPods int `json:"totalpods,omitempty"`

bundle/manifests/node-maintenance-operator.clusterserviceversion.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ metadata:
1919
capabilities: Basic Install
2020
categories: OpenShift Optional
2121
containerImage: ""
22-
createdAt: "2025-06-19T09:34:59Z"
22+
createdAt: ""
2323
description: Node Maintenance Operator for cordoning and draining nodes.
2424
olm.skipRange: '>=0.12.0'
2525
operatorframework.io/suggested-namespace: openshift-workload-availability

bundle/manifests/nodemaintenance.medik8s.io_nodemaintenances.yaml

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -82,66 +82,18 @@ spec:
8282
description: PendingPodsRefs is a list of refs of pending pods for
8383
eviction
8484
items:
85-
description: |-
86-
ObjectReference contains enough information to let you inspect or modify the referred object.
87-
---
88-
New uses of this type are discouraged because of difficulty describing its usage when embedded in APIs.
89-
1. Ignored fields. It includes many fields which are not generally honored. For instance, ResourceVersion and FieldPath are both very rarely valid in actual usage.
90-
2. Invalid usage help. It is impossible to add specific help for individual usage. In most embedded usages, there are particular
91-
restrictions like, "must refer only to types A and B" or "UID not honored" or "name must be restricted".
92-
Those cannot be well described when embedded.
93-
3. Inconsistent validation. Because the usages are different, the validation rules are different by usage, which makes it hard for users to predict what will happen.
94-
4. The fields are both imprecise and overly precise. Kind is not a precise mapping to a URL. This can produce ambiguity
95-
during interpretation and require a REST mapping. In most cases, the dependency is on the group,resource tuple
96-
and the version of the actual struct is irrelevant.
97-
5. We cannot easily change it. Because this type is embedded in many locations, updates to this type
98-
will affect numerous schemas. Don't make new APIs embed an underspecified API type they do not control.
99-
100-
101-
Instead of using this type, create a locally provided and used type that is well-focused on your reference.
102-
For example, ServiceReferences for admission registration: https://github.com/kubernetes/api/blob/release-1.17/admissionregistration/v1/types.go#L533 .
10385
properties:
104-
apiVersion:
105-
description: API version of the referent.
106-
type: string
107-
fieldPath:
108-
description: |-
109-
If referring to a piece of an object instead of an entire object, this string
110-
should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2].
111-
For example, if the object reference is to a container within a pod, this would take on a value like:
112-
"spec.containers{name}" (where "name" refers to the name of the container that triggered
113-
the event) or if no container name is specified "spec.containers[2]" (container with
114-
index 2 in this pod). This syntax is chosen only to have some well-defined way of
115-
referencing a part of an object.
116-
TODO: this design is not final and this field is subject to change in the future.
117-
type: string
118-
kind:
119-
description: |-
120-
Kind of the referent.
121-
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
122-
type: string
12386
name:
12487
description: |-
125-
Name of the referent.
88+
Name of the referent pod.
12689
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
12790
type: string
12891
namespace:
12992
description: |-
130-
Namespace of the referent.
93+
Namespace of the referent pod.
13194
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
13295
type: string
133-
resourceVersion:
134-
description: |-
135-
Specific resourceVersion to which this reference is made, if any.
136-
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency
137-
type: string
138-
uid:
139-
description: |-
140-
UID of the referent.
141-
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids
142-
type: string
14396
type: object
144-
x-kubernetes-map-type: atomic
14597
type: array
14698
phase:
14799
description: Phase is the represtation of the maintenance progress

config/crd/bases/nodemaintenance.medik8s.io_nodemaintenances.yaml

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -80,66 +80,18 @@ spec:
8080
description: PendingPodsRefs is a list of refs of pending pods for
8181
eviction
8282
items:
83-
description: |-
84-
ObjectReference contains enough information to let you inspect or modify the referred object.
85-
---
86-
New uses of this type are discouraged because of difficulty describing its usage when embedded in APIs.
87-
1. Ignored fields. It includes many fields which are not generally honored. For instance, ResourceVersion and FieldPath are both very rarely valid in actual usage.
88-
2. Invalid usage help. It is impossible to add specific help for individual usage. In most embedded usages, there are particular
89-
restrictions like, "must refer only to types A and B" or "UID not honored" or "name must be restricted".
90-
Those cannot be well described when embedded.
91-
3. Inconsistent validation. Because the usages are different, the validation rules are different by usage, which makes it hard for users to predict what will happen.
92-
4. The fields are both imprecise and overly precise. Kind is not a precise mapping to a URL. This can produce ambiguity
93-
during interpretation and require a REST mapping. In most cases, the dependency is on the group,resource tuple
94-
and the version of the actual struct is irrelevant.
95-
5. We cannot easily change it. Because this type is embedded in many locations, updates to this type
96-
will affect numerous schemas. Don't make new APIs embed an underspecified API type they do not control.
97-
98-
99-
Instead of using this type, create a locally provided and used type that is well-focused on your reference.
100-
For example, ServiceReferences for admission registration: https://github.com/kubernetes/api/blob/release-1.17/admissionregistration/v1/types.go#L533 .
10183
properties:
102-
apiVersion:
103-
description: API version of the referent.
104-
type: string
105-
fieldPath:
106-
description: |-
107-
If referring to a piece of an object instead of an entire object, this string
108-
should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2].
109-
For example, if the object reference is to a container within a pod, this would take on a value like:
110-
"spec.containers{name}" (where "name" refers to the name of the container that triggered
111-
the event) or if no container name is specified "spec.containers[2]" (container with
112-
index 2 in this pod). This syntax is chosen only to have some well-defined way of
113-
referencing a part of an object.
114-
TODO: this design is not final and this field is subject to change in the future.
115-
type: string
116-
kind:
117-
description: |-
118-
Kind of the referent.
119-
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
120-
type: string
12184
name:
12285
description: |-
123-
Name of the referent.
86+
Name of the referent pod.
12487
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
12588
type: string
12689
namespace:
12790
description: |-
128-
Namespace of the referent.
91+
Namespace of the referent pod.
12992
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
13093
type: string
131-
resourceVersion:
132-
description: |-
133-
Specific resourceVersion to which this reference is made, if any.
134-
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency
135-
type: string
136-
uid:
137-
description: |-
138-
UID of the referent.
139-
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids
140-
type: string
14194
type: object
142-
x-kubernetes-map-type: atomic
14395
type: array
14496
phase:
14597
description: Phase is the represtation of the maintenance progress

controllers/nodemaintenance_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ func (r *NodeMaintenanceReconciler) Reconcile(ctx context.Context, req ctrl.Requ
245245
nm.Status.Phase = v1beta1.MaintenanceSucceeded
246246
nm.Status.DrainProgress = 100
247247
nm.Status.PendingPods = nil
248+
nm.Status.PendingPodsRefs = nil
248249
err = r.Client.Status().Update(ctx, nm)
249250
if err != nil {
250251
r.logger.Error(err, "Failed to update NodeMaintenance with \"Succeeded\" status")

controllers/utils.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package controllers
22

33
import (
44
corev1 "k8s.io/api/core/v1"
5+
6+
"github.com/medik8s/node-maintenance-operator/api/v1beta1"
57
)
68

79
// ContainsString checks if the string array contains the given string.
@@ -34,14 +36,11 @@ func GetPodNameList(pods []corev1.Pod) (result []string) {
3436
}
3537

3638
// GetPodRefList returns a list of pod references.
37-
func GetPodRefList(pods []corev1.Pod) (result []corev1.ObjectReference) {
39+
func GetPodRefList(pods []corev1.Pod) (result []v1beta1.PodReference) {
3840
for _, pod := range pods {
39-
result = append(result, corev1.ObjectReference{
40-
Kind: pod.Kind,
41-
APIVersion: pod.APIVersion,
42-
Namespace: pod.Namespace,
43-
Name: pod.Name,
44-
UID: pod.UID,
41+
result = append(result, v1beta1.PodReference{
42+
Namespace: pod.Namespace,
43+
Name: pod.Name,
4544
})
4645
}
4746
return result

0 commit comments

Comments
 (0)