Skip to content

Commit

Permalink
Merge pull request #125 from sunya-ch/v1.0.5
Browse files Browse the repository at this point in the history
remove zap stacktrace  and healthz handler
  • Loading branch information
sunya-ch authored Jul 7, 2023
2 parents c6451bb + 8b93aaa commit 7497d12
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 35 deletions.
5 changes: 1 addition & 4 deletions config/manifests/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ patchesJson6902:
patch: |-
- op: add
path: /spec/template/spec/containers/1/args/0
value: "--zap-stacktrace-level=error"
- op: add
path: /spec/template/spec/containers/1/args/1
value: "--zap-log-level=4"
- op: add
path: /spec/template/spec/containers/1/args/2
path: /spec/template/spec/containers/1/args/1
value: "--zap-time-encoding=iso8601"
22 changes: 0 additions & 22 deletions controllers/multinicnetwork_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,25 +273,3 @@ func (r *MultiNicNetworkReconciler) callFinalizer(reqLogger logr.Logger, instanc
r.CIDRHandler.MultiNicNetworkHandler.SafeCache.UnsetCache(instance.Name)
return nil
}

func (h *MultiNicNetworkReconciler) CheckHealth() error {
statuses := h.CIDRHandler.MultiNicNetworkHandler.ListStatusCache()
for name, status := range statuses {
discoverStatus := status.DiscoverStatus
hostInterfaceLen := len(h.CIDRHandler.HostInterfaceHandler.ListCache())
if discoverStatus.ExistDaemon != hostInterfaceLen {
return fmt.Errorf("existDaemon (%d) != hostInterface (%d), some host interface is missing", discoverStatus.ExistDaemon, hostInterfaceLen)
}
_, err := h.CIDRHandler.GetCache(name)
if err == nil {
// consider only multi-nic-ipam
if discoverStatus.InterfaceInfoAvailable > discoverStatus.ExistDaemon {
return fmt.Errorf("existDaemon (%d) < infoAvailable (%d), some daemon is missing", discoverStatus.ExistDaemon, discoverStatus.InterfaceInfoAvailable)
}
if discoverStatus.InterfaceInfoAvailable != discoverStatus.CIDRProcessedHost {
return fmt.Errorf("infoAvailable (%d) != processed (%d), some host may not be processed yet", discoverStatus.InterfaceInfoAvailable, discoverStatus.CIDRProcessedHost)
}
}
}
return nil
}
11 changes: 2 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

multinicv1 "github.com/foundation-model-stack/multi-nic-cni/api/v1"
Expand Down Expand Up @@ -56,14 +57,6 @@ func readyzHandler(r *http.Request) error {
return fmt.Errorf("wait for config")
}

// Handler for the health check endpoint
func healthzHandler(r *http.Request) error {
if MultiNicNetworkReconcilerPointer != nil && controllers.ConfigReady {
return MultiNicNetworkReconcilerPointer.CheckHealth()
}
return fmt.Errorf("initializing")
}

func main() {
var metricsAddr string
var enableLeaderElection bool
Expand Down Expand Up @@ -206,7 +199,7 @@ func main() {
}

//+kubebuilder:scaffold:builder
if err := mgr.AddHealthzCheck("healthz", healthzHandler); err != nil {
if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
setupLog.Error(err, "unable to set up health check")
os.Exit(1)
}
Expand Down

0 comments on commit 7497d12

Please sign in to comment.