allow it to disable CRD creation
This commit is contained in:
parent
65b0c91992
commit
d2daa4e2ac
1 changed files with 29 additions and 27 deletions
|
@ -40,6 +40,7 @@ type Config struct {
|
|||
InCluster bool `json:"inCluster"`
|
||||
KubeConfigFile string `json:"kubeConfigFile"`
|
||||
UseTPR bool `json:"useTPR"` // Flag option to use TPRs instead of CRDs
|
||||
NoCrdCreation bool `json:"noCrdCreation"` // Flag to disable creation of CRDs at cluster level
|
||||
}
|
||||
|
||||
// Open returns a storage using Kubernetes third party resource.
|
||||
|
@ -85,37 +86,38 @@ func (c *Config) open(logger logrus.FieldLogger, waitForResources bool) (*client
|
|||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
if !c.NoCrdCreation {
|
||||
logger.Info("creating custom Kubernetes resources")
|
||||
if !cli.registerCustomResources(c.UseTPR) {
|
||||
if waitForResources {
|
||||
cancel()
|
||||
return nil, fmt.Errorf("failed creating custom resources")
|
||||
}
|
||||
|
||||
logger.Info("creating custom Kubernetes resources")
|
||||
if !cli.registerCustomResources(c.UseTPR) {
|
||||
if waitForResources {
|
||||
cancel()
|
||||
return nil, fmt.Errorf("failed creating custom resources")
|
||||
// Try to synchronously create the custom resources once. This doesn't mean
|
||||
// they'll immediately be available, but ensures that the client will actually try
|
||||
// once.
|
||||
logger.Errorf("failed creating custom resources: %v", err)
|
||||
go func() {
|
||||
for {
|
||||
if cli.registerCustomResources(c.UseTPR) {
|
||||
return
|
||||
}
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-time.After(30 * time.Second):
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// Try to synchronously create the custom resources once. This doesn't mean
|
||||
// they'll immediately be available, but ensures that the client will actually try
|
||||
// once.
|
||||
logger.Errorf("failed creating custom resources: %v", err)
|
||||
go func() {
|
||||
for {
|
||||
if cli.registerCustomResources(c.UseTPR) {
|
||||
return
|
||||
}
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-time.After(30 * time.Second):
|
||||
}
|
||||
if waitForResources {
|
||||
if err := cli.waitForCRDs(ctx); err != nil {
|
||||
cancel()
|
||||
return nil, err
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
if waitForResources {
|
||||
if err := cli.waitForCRDs(ctx); err != nil {
|
||||
cancel()
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue