Skip to content

Commit

Permalink
Merge pull request #181 from gianlucam76/prep
Browse files Browse the repository at this point in the history
Prepare for release v0.29.0
  • Loading branch information
gianlucam76 authored May 6, 2024
2 parents d243f3f + 13d47eb commit ec305ee
Show file tree
Hide file tree
Showing 12 changed files with 389 additions and 443 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Image URL to use all building/pushing image targets
IMG ?= controller:latest
# KUBEBUILDER_ENVTEST_KUBERNETES_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
KUBEBUILDER_ENVTEST_KUBERNETES_VERSION = 1.28.0
KUBEBUILDER_ENVTEST_KUBERNETES_VERSION = 1.30.0

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand All @@ -25,7 +25,7 @@ ARCH ?= amd64
OS ?= $(shell uname -s | tr A-Z a-z)
K8S_LATEST_VER ?= $(shell curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)
export CONTROLLER_IMG ?= $(REGISTRY)/$(IMAGE_NAME)
TAG ?= main
TAG ?= v0.29.0

.PHONY: all
all: build
Expand Down Expand Up @@ -68,7 +68,7 @@ KIND := $(TOOLS_BIN_DIR)/kind
KUBECTL := $(TOOLS_BIN_DIR)/kubectl

GOLANGCI_LINT_VERSION := "v1.55.2"
CLUSTERCTL_VERSION := "v1.7.0"
CLUSTERCTL_VERSION := "v1.7.1"


KUSTOMIZE_VER := v4.5.2
Expand Down
2 changes: 1 addition & 1 deletion config/default/manager_image_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ spec:
spec:
containers:
# Change the value of image field below to your controller image URL
- image: projectsveltos/healthcheck-manager:main
- image: projectsveltos/healthcheck-manager:v0.29.0
name: manager
93 changes: 45 additions & 48 deletions controllers/clusterhealthcheck_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"k8s.io/apimachinery/pkg/types"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
Expand Down Expand Up @@ -275,69 +276,65 @@ func (r *ClusterHealthCheckReconciler) SetupWithManager(mgr ctrl.Manager) (contr
WithOptions(controller.Options{
MaxConcurrentReconciles: r.ConcurrentReconciles,
}).
Watches(&libsveltosv1alpha1.SveltosCluster{},
handler.EnqueueRequestsFromMapFunc(r.requeueClusterHealthCheckForSveltosCluster),
builder.WithPredicates(
SveltosClusterPredicates(mgr.GetLogger().WithValues("predicate", "sveltosclusterpredicate")),
),
).
Watches(&configv1alpha1.ClusterSummary{},
handler.EnqueueRequestsFromMapFunc(r.requeueClusterHealthCheckForClusterSummary),
builder.WithPredicates(
ClusterSummaryPredicates(mgr.GetLogger().WithValues("predicate", "clustersummarypredicate")),
),
).
Watches(&libsveltosv1alpha1.HealthCheckReport{},
handler.EnqueueRequestsFromMapFunc(r.requeueClusterHealthCheckForHealthCheckReport),
builder.WithPredicates(
HealthCheckReportPredicates(mgr.GetLogger().WithValues("predicate", "healthcheckreportpredicate")),
),
).
Watches(&libsveltosv1alpha1.HealthCheck{},
handler.EnqueueRequestsFromMapFunc(r.requeueClusterHealthCheckForHealthCheck),
builder.WithPredicates(
HealthCheckPredicates(mgr.GetLogger().WithValues("predicate", "healthcheckpredicate")),
),
).
Build(r)
if err != nil {
return nil, errors.Wrap(err, "error creating controller")
}
// When projectsveltos cluster changes, according to SveltosClusterPredicates,
// one or more ClusterHealthChecks need to be reconciled.
err = c.Watch(source.Kind(mgr.GetCache(), &libsveltosv1alpha1.SveltosCluster{}),
handler.EnqueueRequestsFromMapFunc(r.requeueClusterHealthCheckForCluster),
SveltosClusterPredicates(mgr.GetLogger().WithValues("predicate", "sveltosclusterpredicate")),
)
if err != nil {
return nil, errors.Wrap(err, "error creating controller")
}

// When projectsveltos clusterSummary changes, according to ClusterSummaryPredicates,
// one or more ClusterHealthChecks need to be reconciled.
err = c.Watch(source.Kind(mgr.GetCache(), &configv1alpha1.ClusterSummary{}),
handler.EnqueueRequestsFromMapFunc(r.requeueClusterHealthCheckForClusterSummary),
ClusterSummaryPredicates(mgr.GetLogger().WithValues("predicate", "clustersummarypredicate")),
)
if err != nil {
return nil, errors.Wrap(err, "error creating controller")
}

// When projectsveltos healthCheckReports changes, according to HealthCheckReportPredicates,
// one or more ClusterHealthChecks need to be reconciled.
err = c.Watch(source.Kind(mgr.GetCache(), &libsveltosv1alpha1.HealthCheckReport{}),
handler.EnqueueRequestsFromMapFunc(r.requeueClusterHealthCheckForHealthCheckReport),
HealthCheckReportPredicates(mgr.GetLogger().WithValues("predicate", "healthcheckreportpredicate")),
)
if err != nil {
return nil, errors.Wrap(err, "error creating controller")
}

// When projectsveltos healthChecks changes, according to HealthCheckPredicates,
// one or more ClusterHealthChecks need to be reconciled.
err = c.Watch(source.Kind(mgr.GetCache(), &libsveltosv1alpha1.HealthCheck{}),
handler.EnqueueRequestsFromMapFunc(r.requeueClusterHealthCheckForHealthCheck),
HealthCheckPredicates(mgr.GetLogger().WithValues("predicate", "healthcheckpredicate")),
)
if err != nil {
return nil, errors.Wrap(err, "error creating controller")
}
// At this point we don't know yet whether CAPI is present in the cluster.
// Later on, in main, we detect that and if CAPI is present WatchForCAPI will be invoked.

return c, nil
}

func (r *ClusterHealthCheckReconciler) WatchForCAPI(mgr ctrl.Manager, c controller.Controller) error {
sourceCluster := source.Kind[*clusterv1.Cluster](
mgr.GetCache(),
&clusterv1.Cluster{},
handler.TypedEnqueueRequestsFromMapFunc(r.requeueClusterHealthCheckForCluster),
ClusterPredicate{Logger: mgr.GetLogger().WithValues("predicate", "clusterpredicate")},
)

// When cluster-api cluster changes, according to ClusterPredicates,
// one or more ClusterHealthChecks need to be reconciled.
if err := c.Watch(source.Kind(mgr.GetCache(), &clusterv1.Cluster{}),
handler.EnqueueRequestsFromMapFunc(r.requeueClusterHealthCheckForCluster),
ClusterPredicates(mgr.GetLogger().WithValues("predicate", "clusterpredicate")),
); err != nil {
if err := c.Watch(sourceCluster); err != nil {
return err
}

// When cluster-api machine changes, according to MachinePredicates,
// one or more ClusterHealthCheck need to be reconciled.
if err := c.Watch(source.Kind(mgr.GetCache(), &clusterv1.Machine{}),
handler.EnqueueRequestsFromMapFunc(r.requeueClusterHealthCheckForMachine),
MachinePredicates(mgr.GetLogger().WithValues("predicate", "machinepredicate")),
); err != nil {
sourceMachine := source.Kind[*clusterv1.Machine](
mgr.GetCache(),
&clusterv1.Machine{},
handler.TypedEnqueueRequestsFromMapFunc(r.requeueClusterHealthCheckForMachine),
MachinePredicate{Logger: mgr.GetLogger().WithValues("predicate", "machinepredicate")},
)

// When cluster-api machine changes, according to ClusterPredicates,
// one or more ClusterHealthChecks need to be reconciled.
if err := c.Watch(sourceMachine); err != nil {
return err
}

Expand Down
Loading

0 comments on commit ec305ee

Please sign in to comment.