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

Floodgate makes changes to our existing resources but it never creates our new resources #124

Open
mertsaygi opened this issue Oct 5, 2020 · 7 comments · May be fixed by #126
Open

Floodgate makes changes to our existing resources but it never creates our new resources #124

mertsaygi opened this issue Oct 5, 2020 · 7 comments · May be fixed by #126

Comments

@mertsaygi
Copy link
Contributor

mertsaygi commented Oct 5, 2020

Describe the bug
When we synth our resources, Floodgate makes changes to our existing resources but it never creates our new resources. When we investigate, we should make change on spinnaker resource directory as like that:

if api != nil { if err := a.LoadRemoteState(api); err != nil { err := a.SaveLocalState(api) return err } }

If loadRemoteState has an error (does not exist error) local state should be saved on remote. This is quick solution. If you want to resolve this issue on me. I can do clean solution.

@boscard
Copy link
Contributor

boscard commented Oct 5, 2020

Hi @mertsaygi ,
Thx for creating this issue. Can you provide some examples? We are trying to test this in our CI process and it seems to work properly. Here you can check how we are testing this https://github.com/codilime/floodgate/blob/master/.circleci/config.yml#L249
Can you check and let us now if this works for you?

@mertsaygi
Copy link
Contributor Author

For example, if you create a new pipeline or application via floodgate. Floodgate does not create it on Spinnaker if your resource does not exists before. I fixed it too simplified solution. I can fix my possible issues after your review.
This is my PR:
#126

@boscard
Copy link
Contributor

boscard commented Oct 5, 2020

@mertsaygi I have tested this using floodgate from master branch on clean Spinnaker installation and it works. Of course there is need to refresh UI after application is created, but spic_cli shows them.
Also tests generated using your change shows an issue with check metod:
https://app.circleci.com/pipelines/github/codilime/floodgate/784/workflows/4f9815e0-20aa-42d8-88fb-425479fbd1dd/jobs/3486

#!/bin/bash -eo pipefail
echo "Print version using version flag"
/floodgate/bin/floodgate --version
echo "Print version using version command"
/floodgate/bin/floodgate version
echo "Comare changes - clean Spinnaker"
/floodgate/bin/floodgate -q --config ~/floodgate.yaml compare && exit 1 || echo "Found changes"
echo "Apply local resources"
/floodgate/bin/floodgate -q --config ~/floodgate.yaml sync
echo "Compare changes - synced resources"
/floodgate/bin/floodgate -q --config ~/floodgate.yaml compare

Print version using version flag
version 0.3.0-pull/126
Print version using version command
Version:		0.3.0-pull/126
Gate API version:	1.21.x
Go version:		1.14.4
Git commit:		9099505e23301e5e55cdf1dfe00f645ea0d0f806
Built:			2020-10-05_20:25:28
Comare changes - clean Spinnaker
FATA[0007] unexpected end of JSON input                 
Found changes
Apply local resources
Compare changes - synced resources

CircleCI received exit code 0

There is a bug in our CI setup - pipeline should fail in this case.

@mertsaygi
Copy link
Contributor Author

mertsaygi commented Oct 12, 2020

Ok think about that you have an application or pipeline but your resource does not exist on Spinnaker.
image
Current production code like that except print message and commented out code block. When we try to use Floodgate like that, we cannot create resources that does not exist on Spinnaker. We got this error message:

image

If i uncomment SaveLocalState line i can create resources on Spinnaker successfully and i got unexpected end of JSON input error message. I will try to fix that.
By the way our Spinnaker version is 1.19.13

@mertsaygi
Copy link
Contributor Author

However LoadRemoteState just gets resource's current state from Spinnaker. We need to create it on Spinnaker so we need the usage of SaveLocalState

@boscard
Copy link
Contributor

boscard commented Oct 12, 2020

@kacpersaw Can you look at it?

@mertsaygi
Copy link
Contributor Author

Also, in this case the resource returns with "unexpected end of JSON input" error even it creates resource on the remote. The root cause is IsChanged method in resource class. If remote state is null, json.Unmarshal process in unmarshalStates method returns with error. I tried it runs if only remote state exists.

image

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 a pull request may close this issue.

2 participants