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

fix(import): failure when multiple versions of the same CRD exist in different obejcts #1042

Merged
merged 3 commits into from
Jun 29, 2023

Conversation

iliapolo
Copy link
Member

When a CRD has multiple objects that represent the same kind but for different versions, cdk8s import will fail with a vague "already exists" error.

For example:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: tenants.capsule.clastix.io
spec:
  group: capsule.clastix.io
  names:
    kind: Tenant
    listKind: TenantList
    plural: tenants
    shortNames:
      - tnt
    singular: tenant
  scope: Cluster
  versions:
    - name: v1beta1
      schema:
        openAPIV3Schema: ...
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: tenants.capsule.clastix.io
spec:
  group: capsule.clastix.io
  names:
    kind: Tenant
    listKind: TenantList
    plural: tenants
    shortNames:
      - tnt
    singular: tenant
  scope: Cluster
  versions:
    - name: v1beta2
      schema:
        openAPIV3Schema: ...

Note that if the two versions are defined within the same object, import will succeed.

For example:

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: tenants.capsule.clastix.io
spec:
  group: capsule.clastix.io
  names:
    kind: Tenant
    listKind: TenantList
    plural: tenants
    shortNames:
      - tnt
    singular: tenant
  scope: Cluster
  versions:
    - name: v1beta1
      schema:
        openAPIV3Schema: ...
    - name: v1beta2
      schema:
        openAPIV3Schema: ...

This is actually a followup to #387.

Signed-off-by: epolon <epolon@amazon.com>
@iliapolo iliapolo added the backport-to-1.x Backport a PR to the 1.x branch label Jun 25, 2023
@iliapolo iliapolo self-assigned this Jun 25, 2023
src/import/base.ts Outdated Show resolved Hide resolved
@mergify mergify bot merged commit 18e6eda into 2.x Jun 29, 2023
@mergify mergify bot deleted the epolon/multi-version-multi-doc-crd branch June 29, 2023 15:03
cdk8s-automation pushed a commit that referenced this pull request Jun 29, 2023
…different obejcts (#1042)

When a CRD has multiple objects that represent the same *kind* but for different versions, `cdk8s import` will fail with a vague "already exists" error.

For example:

```yaml
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: tenants.capsule.clastix.io
spec:
  group: capsule.clastix.io
  names:
    kind: Tenant
    listKind: TenantList
    plural: tenants
    shortNames:
      - tnt
    singular: tenant
  scope: Cluster
  versions:
    - name: v1beta1
      schema:
        openAPIV3Schema: ...
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: tenants.capsule.clastix.io
spec:
  group: capsule.clastix.io
  names:
    kind: Tenant
    listKind: TenantList
    plural: tenants
    shortNames:
      - tnt
    singular: tenant
  scope: Cluster
  versions:
    - name: v1beta2
      schema:
        openAPIV3Schema: ...

```

Note that if the two versions are defined within the same object, import will succeed.

For example:

```yaml
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: tenants.capsule.clastix.io
spec:
  group: capsule.clastix.io
  names:
    kind: Tenant
    listKind: TenantList
    plural: tenants
    shortNames:
      - tnt
    singular: tenant
  scope: Cluster
  versions:
    - name: v1beta1
      schema:
        openAPIV3Schema: ...
    - name: v1beta2
      schema:
        openAPIV3Schema: ...
```

This is actually a followup to #387.

(cherry picked from commit 18e6eda)
Signed-off-by: Eli Polonsky <epolon@amazon.com>
@cdk8s-automation
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
1.x

Questions ?

Please refer to the Backport tool documentation

mergify bot pushed a commit that referenced this pull request Jun 29, 2023
…different obejcts (#1042) (#1055)

# Backport

This will backport the following commits from `2.x` to `1.x`:
 - [fix(import): failure when multiple versions of the same CRD exist in different obejcts (#1042)](#1042)



### Questions ?
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-to-1.x Backport a PR to the 1.x branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants