fix(cmd): should be ready when no CR exists
When no HCO resources exist. The Operator should be ready. Only when a
resource exists and one of the components is doing work (or in an error
state) should the Operator be marked !ready.
@@ -13,6 +13,7 @@ import (
"github.com/operator-framework/operator-sdk/pkg/leader"
"github.com/operator-framework/operator-sdk/pkg/log/zap"
"github.com/operator-framework/operator-sdk/pkg/metrics"
+ "github.com/operator-framework/operator-sdk/pkg/ready"
"github.com/operator-framework/operator-sdk/pkg/restmapper"
"github.com/spf13/pflag"
"k8s.io/apimachinery/pkg/util/intstr"
@@ -75,6 +76,15 @@ func main() {
os.Exit(1)
}
+ // Create a new file supporting readiness probe
+ r := ready.NewFileReady()
+ err = r.Set()
+ if err != nil {
+ log.Error(err, "")
+ os.Exit(1)
+ }
+ defer r.Unset()
+
// Get a config to talk to the apiserver
cfg, err := config.GetConfig()
if err != nil {
