Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
Fix after CR#1
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasiak committed Oct 2, 2019
1 parent 73baaca commit d18ff89
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions cmd/controller-manager/app/controller_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ func Run(controllerManagerOptions *options.ControllerManagerServer) error {
go func() {
mux := http.NewServeMux()
// liveness registered at /healthz indicates if the container is responding
healthz.InstallHandler(mux, healthz.PingHealthz, probe.NewCRDProbe(apiextensionsClient, probe.DelayCRDProbe))
healthz.InstallHandler(mux, healthz.PingHealthz, probe.NewCRDProbe(apiextensionsClient, probe.CRDProbeIterationGap))

// readiness registered at /healthz/ready indicates if traffic should be routed to this container
healthz.InstallPathHandler(mux, "/healthz/ready", probe.NewCRDProbe(apiextensionsClient, probe.DelayCRDProbe))
healthz.InstallPathHandler(mux, "/healthz/ready", probe.NewCRDProbe(apiextensionsClient, probe.CRDProbeIterationGap))

configz.InstallHandler(mux)
metrics.RegisterMetricsAndInstallHandler(mux)
Expand Down
4 changes: 2 additions & 2 deletions cmd/webhook/server/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ func run(opts *WebhookServerOptions, stopCh <-chan struct{}) error {
mux := http.NewServeMux()

// readiness registered at /healthz/ready indicates if traffic should be routed to this container
healthz.InstallPathHandler(mux, "/healthz/ready", probe.NewCRDProbe(apiextensionsClient, probe.DelayCRDProbe))
healthz.InstallPathHandler(mux, "/healthz/ready", probe.NewCRDProbe(apiextensionsClient, probe.CRDProbeIterationGap))

// liveness registered at /healthz indicates if the container is responding
healthz.InstallHandler(mux, healthz.PingHealthz, probe.NewCRDProbe(apiextensionsClient, probe.DelayCRDProbe))
healthz.InstallHandler(mux, healthz.PingHealthz, probe.NewCRDProbe(apiextensionsClient, probe.CRDProbeIterationGap))

server := &http.Server{
Addr: fmt.Sprintf(":%d", opts.HealthzServerBindPort),
Expand Down
13 changes: 7 additions & 6 deletions pkg/probe/crd_probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
apiextensionsclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/klog"
)

Expand All @@ -48,10 +49,10 @@ const (
// ServiceBinding define the name of the ServiceBinding CRD
ServiceBinding = "servicebindings.servicecatalog.k8s.io"

// DelayCRDProbe - readiness/liveness probe is run each period time defined in `periodSeconds` parameter in chart
// if the value is to short then `delay` can postpone checking CRDs which is resource-intensive
// period seconds for CRDProbe will be `periodSeconds` * delay
DelayCRDProbe = 60
// CRDProbeIterationGap - the number of iterations after which the CRD probe action is performed
// All probes are run after the time period defined in the `periodSeconds` parameter in the chart
// Time needed for the CRD Probe to execute is `periodSeconds` * CRDProbeIterationGap
CRDProbeIterationGap = 60
)

var customResourceDefinitionNames = []string{
Expand Down Expand Up @@ -86,7 +87,7 @@ func (r CRDProbe) Name() string {
func (r *CRDProbe) Check(_ *http.Request) error {
if r.counter < r.delay {
r.counter++
klog.V(4).Infof("CRDProbe %s skiped. Ckeck for %d iteration(s)", r.Name(), r.delay-r.counter)
klog.V(4).Infof("%s CRDProbe skipped. Will be executed in %d iteration", r.Name(), r.delay-r.counter)
return nil
}
r.counter = 0
Expand All @@ -104,7 +105,7 @@ func (r *CRDProbe) IsReady() (bool, error) {
}

func (r *CRDProbe) check() (bool, error) {
list, err := r.client.ApiextensionsV1beta1().CustomResourceDefinitions().List(v1.ListOptions{LabelSelector: "svcat=true"})
list, err := r.client.ApiextensionsV1beta1().CustomResourceDefinitions().List(v1.ListOptions{LabelSelector: labels.SelectorFromSet(labels.Set{"svcat": "true"}).String()})
if err != nil {
return false, fmt.Errorf("failed to list CustomResourceDefinition: %s", err)
}
Expand Down

0 comments on commit d18ff89

Please sign in to comment.