Skip to content

Commit

Permalink
refactor: refactor controller logic
Browse files Browse the repository at this point in the history
Signed-off-by: iGxnon <[email protected]>
  • Loading branch information
iGxnon committed Aug 18, 2023
1 parent 43e9620 commit 252000b
Show file tree
Hide file tree
Showing 7 changed files with 372 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::time::Duration;

/// The default requeue duration to achieve eventual consistency
pub(super) const DEFAULT_REQUEUE_DURATION: Duration = Duration::from_secs(600);
pub(crate) const DEFAULT_REQUEUE_DURATION: Duration = Duration::from_secs(600);
/// The field manager identifier of xline operator
pub(super) const FIELD_MANAGER: &str = "xlineoperator.datenlord.io";
pub(crate) const FIELD_MANAGER: &str = "xlineoperator.datenlord.io";
/// The emptyDir volume name of each pod if there is no data pvc specified
pub(crate) const DATA_EMPTY_DIR_NAME: &str = "xline-data-empty-dir";
/// The image used for cronjob to trigger backup
Expand All @@ -21,3 +21,10 @@ pub(crate) const DEFAULT_XLINE_PORT: i32 = 2379;
pub(crate) const DEFAULT_SIDECAR_PORT: i32 = 2380;
/// The environment name of the xline pod name
pub(crate) const XLINE_POD_NAME_ENV: &str = "XLINE_POD_NAME";
/// The annotation used to inherit labels in `XlineCluster`
pub(crate) const ANNOTATION_INHERIT_LABELS_PREFIX: &str =
"xlineoperator.datenlord.io/inherit-label-prefix";
/// The label attach to subresources, indicate the xlinecluster name
pub(crate) const LABEL_CLUSTER_NAME: &str = "xlinecluster/name";
/// The label attach to subresources, indicate the component type of this subresource
pub(crate) const LABEL_CLUSTER_COMPONENT: &str = "xlinecluster/component";
2 changes: 1 addition & 1 deletion operator-k8s/src/controller/cluster/v1alpha.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use kube::{Api, Client, Resource, ResourceExt};
use tracing::{debug, error};
use utils::consts::{DEFAULT_BACKUP_DIR, DEFAULT_DATA_DIR};

use crate::controller::consts::{
use crate::consts::{
DATA_EMPTY_DIR_NAME, DEFAULT_XLINE_PORT, FIELD_MANAGER, XLINE_POD_NAME_ENV, XLINE_PORT_NAME,
};
use crate::controller::Controller;
Expand Down
2 changes: 1 addition & 1 deletion operator-k8s/src/controller/cluster/v1alpha1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use kube::{Api, Client, Resource, ResourceExt};
use tracing::{debug, error};
use utils::consts::{DEFAULT_BACKUP_DIR, DEFAULT_DATA_DIR};

use crate::controller::consts::{
use crate::consts::{
CRONJOB_IMAGE, DATA_EMPTY_DIR_NAME, DEFAULT_SIDECAR_PORT, DEFAULT_XLINE_PORT, FIELD_MANAGER,
SIDECAR_PORT_NAME, XLINE_POD_NAME_ENV, XLINE_PORT_NAME,
};
Expand Down
4 changes: 1 addition & 3 deletions operator-k8s/src/controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ use kube::runtime::watcher::Config as WatcherConfig;
use kube::{Api, Resource};
use serde::de::DeserializeOwned;

use crate::controller::consts::DEFAULT_REQUEUE_DURATION;
use crate::consts::DEFAULT_REQUEUE_DURATION;

/// Cluster controller
pub(crate) mod cluster;
/// CRD constants
mod consts;

/// The common context
pub(crate) struct Context<C> {
Expand Down
6 changes: 5 additions & 1 deletion operator-k8s/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,13 @@

/// Xline operator config
pub mod config;
/// Xline operator controller
/// Some constants
mod consts;
/// Custom resource controller
mod controller;
/// Custom resource definition
mod crd;
/// Custom resource manager
mod manager;
/// Xline operator
pub mod operator;
Loading

0 comments on commit 252000b

Please sign in to comment.