mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-28 02:18:15 +00:00
fix crd sync issue (#2634)
This commit is contained in:
parent
ea3529f2d0
commit
4c28540f83
1 changed files with 12 additions and 2 deletions
|
@ -77,16 +77,16 @@ func (c *crdSync) Run(workers int, stopCh <-chan struct{}) {
|
|||
if err != nil {
|
||||
log.Log.Error(err, "Could not set custom OpenAPI document")
|
||||
}
|
||||
|
||||
// Sync CRD before kyverno starts
|
||||
c.sync()
|
||||
|
||||
for i := 0; i < workers; i++ {
|
||||
go wait.Until(c.sync, 15*time.Minute, stopCh)
|
||||
go wait.Until(c.sync, 15*time.Second, stopCh)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *crdSync) sync() {
|
||||
c.client.DiscoveryClient.DiscoveryCache().Invalidate()
|
||||
crds, err := c.client.GetDynamicInterface().Resource(runtimeSchema.GroupVersionResource{
|
||||
Group: "apiextensions.k8s.io",
|
||||
Version: "v1",
|
||||
|
@ -106,6 +106,16 @@ func (c *crdSync) sync() {
|
|||
if err := c.updateInClusterKindToAPIVersions(); err != nil {
|
||||
log.Log.Error(err, "sync failed, unable to update in-cluster api versions")
|
||||
}
|
||||
|
||||
newDoc, err := c.client.DiscoveryClient.DiscoveryCache().OpenAPISchema()
|
||||
if err != nil {
|
||||
log.Log.Error(err, "cannot get OpenAPI schema")
|
||||
}
|
||||
|
||||
err = c.controller.useOpenAPIDocument(newDoc)
|
||||
if err != nil {
|
||||
log.Log.Error(err, "Could not set custom OpenAPI document")
|
||||
}
|
||||
}
|
||||
|
||||
func (c *crdSync) updateInClusterKindToAPIVersions() error {
|
||||
|
|
Loading…
Add table
Reference in a new issue