Skip to content

Commit

Permalink
rename podReconcile2 to probePodReconciler
Browse files Browse the repository at this point in the history
  • Loading branch information
ushitora-anqou committed Jan 26, 2024
1 parent 6f39887 commit 05fa840
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
4 changes: 2 additions & 2 deletions cmd/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ func subMain() error {
return err
}

podReconciler2 := controller.NewPodReconciler2(
probePodReconciler := controller.NewProbePodReconciler(
mgr.GetClient(),
exporter,
)
err = podReconciler2.SetupWithManager(mgr)
err = probePodReconciler.SetupWithManager(mgr)
if err != nil {
setupLog.Error(err, "unable to start podReconciler")
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,25 @@ import (
"sigs.k8s.io/controller-runtime/pkg/log"
)

// PodReconciler2 reconciles a Pod object
type PodReconciler2 struct {
// ProbePodReconciler reconciles a Pod object
type ProbePodReconciler struct {
client client.Client

startTime time.Time
po *provisionObserver2
}

func NewPodReconciler2(
func NewProbePodReconciler(
client client.Client,
exporter metrics.MetricsExporter,
) *PodReconciler2 {
return &PodReconciler2{
) *ProbePodReconciler {
return &ProbePodReconciler{
client: client,
startTime: time.Now(),
po: newProvisionObserver2(client, exporter),
}
}

func isProbePodName2(s string) bool {
return strings.HasPrefix(s, constants.ProvisionProbeNamePrefix) ||
strings.HasPrefix(s, constants.MountProbeNamePrefix)
}

//+kubebuilder:rbac:namespace=default,groups=core,resources=pods,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:namespace=default,groups=core,resources=pods/status,verbs=get;update;patch
//+kubebuilder:rbac:namespace=default,groups=core,resources=pods/finalizers,verbs=update
Expand All @@ -53,10 +48,11 @@ func isProbePodName2(s string) bool {
//
// For more details, check Reconcile and its Result here:
// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.13.0/pkg/reconcile
func (r *PodReconciler2) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
func (r *ProbePodReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
_ = log.FromContext(ctx)

if !isProbePodName2(req.Name) {
if !strings.HasPrefix(req.Name, constants.ProvisionProbeNamePrefix) &&
!strings.HasPrefix(req.Name, constants.MountProbeNamePrefix) {
return ctrl.Result{}, nil
}

Expand Down Expand Up @@ -113,7 +109,7 @@ func (r *PodReconciler2) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
}

// SetupWithManager sets up the controller with the Manager.
func (r *PodReconciler2) SetupWithManager(mgr ctrl.Manager) error {
func (r *ProbePodReconciler) SetupWithManager(mgr ctrl.Manager) error {
mgr.Add(r.po)
return ctrl.NewControllerManagedBy(mgr).
For(&corev1.Pod{}).
Expand Down

0 comments on commit 05fa840

Please sign in to comment.