Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic Client doesn't discover newly created resources after operator has run #272

Closed
fanminshi opened this issue May 22, 2018 · 0 comments · Fixed by #280
Closed

Dynamic Client doesn't discover newly created resources after operator has run #272

fanminshi opened this issue May 22, 2018 · 0 comments · Fixed by #280
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@fanminshi
Copy link
Contributor

fanminshi commented May 22, 2018

Currently The SDK's query, action, and Watch APIs are not able to discover a new resource
type after the operator has initiated.

For example:

We have a setup such that the operator gets the AppService resource every 5 seconds:

a := &v1alpha1.AppService{
	TypeMeta: metav1.TypeMeta{
		Kind:       "AppService",
		APIVersion: "example.com/v1alpha1",
	},
	ObjectMeta: metav1.ObjectMeta{
		Name:      "bla",
		Namespace: "default",
	},
}
for {
	err := query.Get(a)
	if err != nil {
		logrus.Error(err)
	}
	time.Sleep(5 * time.Second)
}

Initially, the CRD of AppService is not registered.

$ kubectl get CRD
No resources found.

The above code prints the error:

ERRO[0000] failed to get resource client for (apiVersion:example.com/v1alpha1, kind:AppService, ns:default): failed to get resource type: failed to get the resource REST mapping for GroupVersionKind(example.com/v1alpha1, Kind=AppService): no matches for example.com/, Kind=AppService

Let's create the CRD:

$ kubectl get crd
NAME                      AGE
appservices.example.com   7s

We expect the getter from main loop to eventually discover the AppService resource so that
the getter gets the correct resource. However, that does not happen, and we get the same error as before:

ERRO[0035] failed to get resource client for (apiVersion:example.com/v1alpha1, kind:AppService, ns:default): failed to get resource type: failed to get the resource REST mapping for GroupVersionKind(example.com/v1alpha1, Kind=AppService): no matches for example.com/, Kind=AppService
@fanminshi fanminshi added the kind/bug Categorizes issue or PR as related to a bug. label May 22, 2018
shawn-hurley pushed a commit to shawn-hurley/operator-sdk that referenced this issue May 23, 2018
This sets up a go routine to reset the restMapper at a 1 minute
interval so that new resources can be found in the cluster.

fixes operator-framework#272
shawn-hurley pushed a commit to shawn-hurley/operator-sdk that referenced this issue May 23, 2018
This sets up a go routine to reset the restMapper at a 1 minute
interval so that new resources can be found in the cluster.

fixes operator-framework#272
shawn-hurley pushed a commit to shawn-hurley/operator-sdk that referenced this issue May 24, 2018
This sets up a go routine to reset the restMapper at a 1 minute
interval so that new resources can be found in the cluster.
adds fix to CHANGELOG.md

fixes operator-framework#272
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant