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: include namespace in renderedYaml filename #1429

Merged
merged 2 commits into from
Feb 26, 2021

Conversation

rawkode
Copy link
Contributor

@rawkode rawkode commented Jan 18, 2021

This fixes a problem when resources have the same name/kind, but live in different namespaces. This caused the first file written to be overwritten by the later resources.

@rawkode rawkode force-pushed the fix/duplicate-resource-names branch from 62e2a06 to a20d23d Compare January 18, 2021 18:56
@rawkode
Copy link
Contributor Author

rawkode commented Jan 18, 2021

@lblackstone I'm not sure if GetNamespace() will work on resources without a namespace. I'm going to run some tests now :)

@rawkode
Copy link
Contributor Author

rawkode commented Jan 18, 2021

The test that failed seems unrelated 👍

@lblackstone
Copy link
Member

/run-acceptance-tests

@github-actions
Copy link

Copy link
Member

@lblackstone lblackstone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

I do have a couple concerns about this change so far:

  1. While changing the name does resolve the bug, it also would rename every generated resource YAML, which might break users' existing workflows. Adding the namespace is a good way to disambiguate, but it would be ideal if we could leave existing stacks alone. I'm not sure off the top of my head how easy that would be to check.
  2. GetNamespace() will return "" for the default namespace, so it would be better to format the string to avoid the extra - in that case. e.g. pod-foo rather than pod--foo.

@rawkode
Copy link
Contributor Author

rawkode commented Jan 19, 2021

@lblackstone With regards to issue 1 - I don't think that's a problem. Anyone generating the YAML will be using kubectl to apply and the filenames will be irrelevant. The directories created won't be modified, which I believe is safe to assume that's as close to coupling a consumer to renderToYaml may get. IMO.

Happy to implement issue 2 if you're happy to proceed on the above hypothesis.

Option 3 could be to add another option to the provider config to tweak the filenames, but I don't think that would be used really?

@lblackstone
Copy link
Member

Anyone generating the YAML will be using kubectl to apply and the filenames will be irrelevant. The directories created won't be modified, which I believe is safe to assume that's as close to coupling a consumer to renderToYaml may get...Happy to implement issue 2 if you're happy to proceed on the above hypothesis.

Yeah, that's probably a reasonable assumption. Let's proceed with this change, and I'll bump the minor version of the next release since it's technically a breaking change.

CHANGELOG.md Outdated Show resolved Hide resolved
@leezen
Copy link
Contributor

leezen commented Feb 25, 2021

@rawkode Just checking in to see if you plan to come back to this. Thanks!

@rawkode
Copy link
Contributor Author

rawkode commented Feb 25, 2021

@rawkode Just checking in to see if you plan to come back to this. Thanks!

The last message from @lblackstone said they where happy to go with it as it is, under our assumptions.

I was just waiting for this to be merged.

@lblackstone
Copy link
Member

Oh, sorry for the confusion. There's still one point of feedback to address, and then we can merge.

GetNamespace() will return "" for the default namespace, so it would be better to format the string to avoid the extra - in that case. e.g. pod-foo rather than pod--foo.

This fixes a problem when resources have the same name/kind, but live in different namespaces. This caused the first file written to be overwritten by the later resources.
@github-actions
Copy link

PR is now waiting for a maintainer to run the acceptance tests. This PR will only perform build and linting.

Note for the maintainer: To run the acceptance tests, please comment /run-acceptance-tests on the PR

@lblackstone
Copy link
Member

/run-acceptance-tests

@github-actions
Copy link

@lblackstone lblackstone merged commit be90a25 into pulumi:master Feb 26, 2021
@lblackstone
Copy link
Member

Thanks for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants