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(pipelineTemplateSave): Take tags from template files #355

Merged
merged 2 commits into from
Apr 24, 2023
Merged

fix(pipelineTemplateSave): Take tags from template files #355

merged 2 commits into from
Apr 24, 2023

Conversation

kbatalin
Copy link
Contributor

Spin ignores tags from pipeline template files, and it causes errors during saving.

Example of the problem:

  1. Create a template with a tag "stable" inside
  2. Save it via spin pt save. Don't pass the tag to the command, because it already exists in the code
  3. Front50 parses the template and finds the tag inside: code
  4. Front50 saves the template with the tag
  5. Edit the code of the template and save it again
  6. Spin tries to find a template in Front50 without tags (because we don't pass the tag via arguments)
  7. Spin can't find the template and invokes "create" method instead of "update"
  8. Front50 throws an DuplicateEntityException because a template with the id already exists. Validation code: code

Front50 takes a tag from query parameters as a priority. And only if the tag is not in the query parameters, it tries to take it from the template source code. code

I reproduced a similar logic in Spin

@Chinikins
Copy link
Contributor

did you run go fmt on your PR perchance? the lint check is failing, though the error i'm seeing looks like it's more with the job itself than an actual lint error, but figured I would ask anyway

@kbatalin
Copy link
Contributor Author

kbatalin commented Mar 30, 2023

@Chinikins
Yes, I ran it for files that I changed. I can run it for the whole project and push changes if you are okay with it

@karlskewes
Copy link
Contributor

Looks like we need to review & merge #358 first, rebase this and then the lint job should run properly.

@karlskewes
Copy link
Contributor

And great work on figuring out the logic and replicating here @kbatalin !

@dbyron-sf
Copy link
Contributor

@Mergifyio update

@mergify
Copy link
Contributor

mergify bot commented Mar 31, 2023

update

❌ Base branch update has failed

refusing to allow a GitHub App to create or update workflow .github/workflows/build.yml without workflows permission
err-code: E8C10

@kbatalin
Copy link
Contributor Author

kbatalin commented Apr 3, 2023

Hi,
@Chinikins @karlskewes @dbyron-sf

Thanks for the CI fix!
Tests passed

Could you have a look on the PR?

@kbatalin
Copy link
Contributor Author

Hi @Chinikins @karlskewes @dbyron-sf

Could you have a look on the PR?

@dbyron-sf
Copy link
Contributor

@Mergifyio update

@mergify
Copy link
Contributor

mergify bot commented Apr 12, 2023

update

❌ Base branch update has failed

refusing to allow a GitHub App to create or update workflow .github/workflows/build.yml without workflows permission
err-code: 346FE

@dbyron-sf
Copy link
Contributor

Can you rebase please @kbatalin ?

kbatalin and others added 2 commits April 12, 2023 18:36
Spin ignores tags from pipeline template files, and it causes errors during saving.
Example of the problem:
1. Create a template with a tag "stable" inside
2. Save it via `spin pt save`. Don't pass the tag to the command, because it already exists in the code
3. Front50 parses the template and finds the tag inside: https://github.com/spinnaker/front50/blob/master/front50-web/src/main/java/com/netflix/spinnaker/front50/controllers/V2PipelineTemplateController.java#L94
4. Front50 saves the template with the tag
5. Edit the code of the template and save it again
6. Spin tries to find a template in Front50 without tags (because we don't pass the tag via arguments)
7. Spin can't find the template and invokes "create" method instead of "update"
8. Front50 throws an DuplicateEntityException because a template with the id already exists. Validation code: https://github.com/spinnaker/front50/blob/master/front50-web/src/main/java/com/netflix/spinnaker/front50/controllers/V2PipelineTemplateController.java#L115

Front50 takes a tag from query parameters as a priority. And only if the tag is not in the query parameters, it tries to take it from the template source code. https://github.com/spinnaker/front50/blob/master/front50-web/src/main/java/com/netflix/spinnaker/front50/controllers/V2PipelineTemplateController.java#L93
I reproduced a similar logic in Spin
@kbatalin
Copy link
Contributor Author

@dbyron-sf
Yes, sure. Rebased

@kbatalin
Copy link
Contributor Author

Hi @dbyron-sf ,
CI passed

@dbyron-sf
Copy link
Contributor

Yup, hoping @Chinikins or @karlskewes can have a look.

@kbatalin
Copy link
Contributor Author

Hi @Chinikins ,
Could you please have a look?

Copy link
Contributor

@karlskewes karlskewes left a comment

Choose a reason for hiding this comment

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

LGTM, thanks very much.

@kbatalin
Copy link
Contributor Author

kbatalin commented Apr 24, 2023

@karlskewes
Thanks for the approve! Can we merge the PR now?

@dbyron-sf dbyron-sf added the ready to merge Approved and Reviewed and ready for merge label Apr 24, 2023
@mergify mergify bot added the auto merged label Apr 24, 2023
@mergify mergify bot merged commit 9d43143 into spinnaker:master Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto merged ready to merge Approved and Reviewed and ready for merge target-release/1.30
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants