@@ -17,6 +17,7 @@ use crate::{
17
17
} ,
18
18
kube:: { Resource , ResourceExt } ,
19
19
labels:: { APP_INSTANCE_LABEL , APP_MANAGED_BY_LABEL , APP_NAME_LABEL } ,
20
+ utils:: format_full_controller_name,
20
21
} ;
21
22
use k8s_openapi:: {
22
23
api:: { core:: v1:: Secret , core:: v1:: ServiceAccount , rbac:: v1:: RoleBinding } ,
@@ -72,7 +73,8 @@ impl ClusterResource for Secret {}
72
73
/// use std::sync::Arc;
73
74
///
74
75
/// const APP_NAME: &str = "app";
75
- /// const FIELD_MANAGER_SCOPE: &str = "appcluster";
76
+ /// const OPERATOR_NAME: &str = "app.stackable.tech";
77
+ /// const CONTROLLER_NAME: &str = "appcluster";
76
78
///
77
79
/// #[derive(Clone, CustomResource, Debug, Deserialize, JsonSchema, Serialize)]
78
80
/// #[kube(
@@ -101,7 +103,8 @@ impl ClusterResource for Secret {}
101
103
///
102
104
/// let mut cluster_resources = ClusterResources::new(
103
105
/// APP_NAME,
104
- /// FIELD_MANAGER_SCOPE,
106
+ /// OPERATOR_NAME,
107
+ /// CONTROLLER_NAME,
105
108
/// &app.object_ref(&()),
106
109
/// )
107
110
/// .map_err(|source| Error::CreateClusterResources { source })?;
@@ -166,19 +169,24 @@ impl ClusterResources {
166
169
///
167
170
/// * `app_name` - The lower-case application name used in the resource labels, e.g.
168
171
/// "zookeeper"
169
- /// * `manager` - The manager of these cluster resources, e.g.
170
- /// "zookeeper-operator_zk-controller". The added resources must contain the content of this
171
- /// field in the `app.kubernetes.io/managed-by` label. It must be different for each
172
- /// controller in the operator, otherwise resources created by another controller are detected
173
- /// as orphaned in this cluster and are deleted. This value is also used for the field manager
174
- /// scope when applying resources.
172
+ /// * `operator_name` - The FQDN-style name of the operator, such as ""zookeeper.stackable.tech""
173
+ /// * `controller_name` - The name of the lower-case name of the primary resource that
174
+ /// the controller manages, such as "zookeepercluster"
175
175
/// * `cluster` - A reference to the cluster containing the name and namespace of the cluster
176
176
///
177
+ /// The combination of (`operator_name`, `controller_name`) must be unique for each controller in the cluster,
178
+ /// otherwise resources created by another controller are detected as orphaned and deleted.
179
+ ///
177
180
/// # Errors
178
181
///
179
182
/// If `cluster` does not contain a namespace and a name then an `Error::MissingObjectKey` is
180
183
/// returned.
181
- pub fn new ( app_name : & str , manager : & str , cluster : & ObjectReference ) -> OperatorResult < Self > {
184
+ pub fn new (
185
+ app_name : & str ,
186
+ operator_name : & str ,
187
+ controller_name : & str ,
188
+ cluster : & ObjectReference ,
189
+ ) -> OperatorResult < Self > {
182
190
let namespace = cluster
183
191
. namespace
184
192
. to_owned ( )
@@ -192,7 +200,7 @@ impl ClusterResources {
192
200
namespace,
193
201
app_instance,
194
202
app_name : app_name. into ( ) ,
195
- manager : manager . into ( ) ,
203
+ manager : format_full_controller_name ( operator_name , controller_name ) ,
196
204
resource_ids : Default :: default ( ) ,
197
205
} )
198
206
}
0 commit comments