terrajet icon indicating copy to clipboard operation
terrajet copied to clipboard

Problem to create a resource that is named `Namespace`

Open remyleone opened this issue 2 years ago • 2 comments

What happened?

When I try to apply the following resource:

apiVersion: registry.scaleway.jet.crossplane.io/v1alpha1
kind: Namespace
metadata:
  name: main
  namespace: default
spec:
  forProvider:
    name: crossplane-namespace
  providerConfigRef:
    name: default

That got the following configuration:

package registry

import "github.com/crossplane/terrajet/pkg/config"

const shortGroup = "registry"

// Configure configures the registry resources.
func Configure(p *config.Provider) {
	p.AddResourceConfigurator("scaleway_registry_namespace", func(r *config.Resource) {
		// Identifier for this resource is assigned by the provider. In other
		// words it is not simply the name of the resource.
		r.ExternalName = config.IdentifierFromProvider
		r.ShortGroup = shortGroup
		r.Kind = "Namespace"
	})
}

I get the following errors in loop:

2022-02-09T17:45:58.621+0100	DEBUG	provider-jet-scaleway	Reconciling	{"controller": "managed/registry.scaleway.jet.crossplane.io/v1alpha1, kind=namespace", "request": "/main"}
2022-02-09T17:45:58.924+0100	DEBUG	provider-jet-scaleway	refresh ended	{"workspace": "/var/folders/58/dpfvy5xj6q5b44ly5zhfjfnh0000gn/T/9a968537-079d-40b2-852b-e36207171ee9", "out": "{\"@level\":\"info\",\"@message\":\"Terraform 1.1.5\",\"@module\":\"terraform.ui\",\"@timestamp\":\"2022-02-09T17:45:58.655451+01:00\",\"terraform\":\"1.1.5\",\"type\":\"version\",\"ui\":\"1.0\"}\n{\"@level\":\"info\",\"@message\":\"Plan: 0 to add, 0 to change, 0 to destroy.\",\"@module\":\"terraform.ui\",\"@timestamp\":\"2022-02-09T17:45:58.900336+01:00\",\"changes\":{\"add\":0,\"change\":0,\"remove\":0,\"operation\":\"plan\"},\"type\":\"change_summary\"}\n{\"@level\":\"info\",\"@message\":\"Apply complete! Resources: 0 added, 0 changed, 0 destroyed.\",\"@module\":\"terraform.ui\",\"@timestamp\":\"2022-02-09T17:45:58.921594+01:00\",\"changes\":{\"add\":0,\"change\":0,\"remove\":0,\"operation\":\"apply\"},\"type\":\"change_summary\"}\n{\"@level\":\"info\",\"@message\":\"Outputs: 0\",\"@module\":\"terraform.ui\",\"@timestamp\":\"2022-02-09T17:45:58.921645+01:00\",\"outputs\":{},\"type\":\"outputs\"}\n"}
2022-02-09T17:45:58.928+0100	DEBUG	provider-jet-scaleway	Cannot add finalizer	{"controller": "managed/registry.scaleway.jet.crossplane.io/v1alpha1, kind=namespace", "request": "/main", "uid": "9a968537-079d-40b2-852b-e36207171ee9", "version": "790", "external-name": "", "error": "cannot update object: the server could not find the requested resource (put namespaces.registry.scaleway.jet.crossplane.io main)"}
2022-02-09T17:45:58.931+0100	ERROR	controller-runtime.manager.controller.managed/registry.scaleway.jet.crossplane.io/v1alpha1, kind=namespace	Reconciler error	{"reconciler group": "registry.scaleway.jet.crossplane.io", "reconciler kind": "Namespace", "name": "main", "namespace": "", "error": "cannot update managed resource status: the server could not find the requested resource (put namespaces.registry.scaleway.jet.crossplane.io main)"}
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
	/Users/sieben/workspace/crossplane-scaleway-provider/.work/pkg/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:253
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2
	/Users/sieben/workspace/crossplane-scaleway-provider/.work/pkg/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:214

How can we reproduce it?

Try to create the mentioned resource using this provider: https://github.com/remyleone/crossplane-scaleway-provider

remyleone avatar Feb 14 '22 14:02 remyleone

Hi @remyleone, Thanks for reporting. This is a known upstream issue for which we have proposed a fix. Meanwhile, the workaround is to choose a different Kind name than Namespace for the managed resource.

ulucinar avatar Mar 11 '22 08:03 ulucinar

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 13 '22 00:08 stale[bot]