2018-02-09 16:21:06 +00:00
|
|
|
//
|
|
|
|
// DISCLAIMER
|
|
|
|
//
|
2022-01-10 11:35:49 +00:00
|
|
|
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
|
2018-02-09 16:21:06 +00:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
|
|
|
// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
|
|
|
//
|
|
|
|
|
2018-02-27 10:50:28 +00:00
|
|
|
package operator
|
2018-02-09 16:21:06 +00:00
|
|
|
|
|
|
|
import (
|
2022-01-06 20:27:01 +00:00
|
|
|
"time"
|
2021-03-23 15:47:28 +00:00
|
|
|
|
2018-03-13 15:25:33 +00:00
|
|
|
"github.com/arangodb/kube-arangodb/pkg/util/crd"
|
2018-02-09 16:21:06 +00:00
|
|
|
)
|
|
|
|
|
2022-01-06 20:27:01 +00:00
|
|
|
// waitForCRD waits for the CustomResourceDefinition (created externally) to be ready.
|
|
|
|
func (o *Operator) waitForCRD(crdName string, checkFn func() error) {
|
2022-06-14 07:26:07 +00:00
|
|
|
o.log.Debug("Waiting for %s CRD to be ready - ", crdName)
|
2018-02-13 12:49:04 +00:00
|
|
|
|
2022-01-06 20:27:01 +00:00
|
|
|
for {
|
|
|
|
var err error = nil
|
|
|
|
if o.Scope.IsNamespaced() {
|
|
|
|
if checkFn != nil {
|
|
|
|
err = crd.WaitReady(checkFn)
|
2020-08-14 07:35:11 +00:00
|
|
|
}
|
2022-01-06 20:27:01 +00:00
|
|
|
} else {
|
2022-02-28 18:53:01 +00:00
|
|
|
err = crd.WaitCRDReady(o.Client.KubernetesExtensions(), crdName)
|
2018-03-19 10:09:20 +00:00
|
|
|
}
|
2018-03-05 09:00:23 +00:00
|
|
|
|
2022-01-06 20:27:01 +00:00
|
|
|
if err == nil {
|
|
|
|
break
|
|
|
|
} else {
|
2022-06-14 07:26:07 +00:00
|
|
|
o.log.Err(err).Error("Resource initialization failed")
|
|
|
|
o.log.Info("Retrying in %s...", initRetryWaitTime)
|
2022-01-06 20:27:01 +00:00
|
|
|
time.Sleep(initRetryWaitTime)
|
2019-09-27 11:04:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-14 07:26:07 +00:00
|
|
|
o.log.Debug("CRDs ready")
|
2018-02-09 16:21:06 +00:00
|
|
|
}
|