@@ -56,13 +56,13 @@ func Add(mgr manager.Manager) error {
5656}
5757
5858// newReconciler returns a new reconcile.Reconciler
59- func newReconciler (mgr manager.Manager , sqlI newSQLInterface ) reconcile.Reconciler {
59+ func newReconciler (mgr manager.Manager , sqlI sqlFactoryFunc ) reconcile.Reconciler {
6060 return & ReconcileMysqlNode {
61- Client : mgr .GetClient (),
62- scheme : mgr .GetScheme (),
63- recorder : mgr .GetRecorder (controllerName ),
64- opt : options .GetOptions (),
65- newSQLInterface : sqlI ,
61+ Client : mgr .GetClient (),
62+ scheme : mgr .GetScheme (),
63+ recorder : mgr .GetRecorder (controllerName ),
64+ opt : options .GetOptions (),
65+ sqlFactory : sqlI ,
6666 }
6767}
6868
@@ -80,17 +80,6 @@ func isOwnedByMySQL(meta metav1.Object) bool {
8080 return false
8181}
8282
83- func podIsReady (obj runtime.Object ) bool {
84- pod := obj .(* corev1.Pod )
85-
86- for _ , cond := range pod .Status .Conditions {
87- if cond .Type == corev1 .PodReady {
88- return cond .Status == corev1 .ConditionTrue
89- }
90- }
91- return false
92- }
93-
9483func isInitialized (obj runtime.Object ) bool {
9584 pod := obj .(* corev1.Pod )
9685
@@ -113,11 +102,11 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error {
113102 // Watch for changes to MysqlCluster
114103 err = c .Watch (& source.Kind {Type : & corev1.Pod {}}, & handler.EnqueueRequestForObject {}, predicate.Funcs {
115104 CreateFunc : func (evt event.CreateEvent ) bool {
116- return isOwnedByMySQL (evt .Meta ) && ! podIsReady ( evt . Object ) && ! isInitialized (evt .Object )
105+ return isOwnedByMySQL (evt .Meta ) && ! isInitialized (evt .Object )
117106 },
118107 UpdateFunc : func (evt event.UpdateEvent ) bool {
119108 log .V (1 ).Info ("pod update event" , "meta" , evt .MetaNew )
120- return isOwnedByMySQL (evt .MetaNew ) && ! podIsReady ( evt . ObjectNew ) && ! isInitialized (evt .ObjectNew )
109+ return isOwnedByMySQL (evt .MetaNew ) && ! isInitialized (evt .ObjectNew )
121110 },
122111 DeleteFunc : func (evt event.DeleteEvent ) bool {
123112 return false
@@ -139,7 +128,7 @@ type ReconcileMysqlNode struct {
139128 recorder record.EventRecorder
140129 opt * options.Options
141130
142- newSQLInterface newSQLInterface
131+ sqlFactory sqlFactoryFunc
143132}
144133
145134// Reconcile reads that state of the cluster for a MysqlCluster object and makes changes based on the state read
@@ -257,7 +246,7 @@ func (r *ReconcileMysqlNode) getMySQLConnection(cluster *mysqlcluster.MysqlClust
257246 c .User , c .Password , host , constants .MysqlPort ,
258247 )
259248
260- return r .newSQLInterface (dsn , host )
249+ return r .sqlFactory (dsn , host )
261250}
262251
263252type credentials struct {
@@ -293,14 +282,14 @@ func (r *ReconcileMysqlNode) updatePod(pod *corev1.Pod) error {
293282}
294283
295284func (c * credentials ) Validate () error {
296- if anyZero (c .User , c .Password , c .ReplicationUser , c .ReplicationPassword ) {
285+ if anyIsEmpty (c .User , c .Password , c .ReplicationUser , c .ReplicationPassword ) {
297286 return fmt .Errorf ("validation error: some credentials are empty" )
298287 }
299288
300289 return nil
301290}
302291
303- func anyZero (ss ... string ) bool {
292+ func anyIsEmpty (ss ... string ) bool {
304293 zero := false
305294 for _ , s := range ss {
306295 zero = zero || len (s ) == 0
0 commit comments