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

Adding support to get Yaml for k8s object #45

Merged
merged 4 commits into from
Mar 2, 2020

Conversation

AshishKhatkar
Copy link
Member

@AshishKhatkar AshishKhatkar commented Feb 27, 2020

Changes done :

  • Moved logic to compute necessary object to get hash of k8s object to utils.
  • Added support to generate yaml of any k8s object.
  • The above changes will be used to get diff of k8s object in operator whenever hash of object changes to have better visibility around the changes that triggers restart of k8 clusters.
  • Added test for the newly created util file.
  • Testing done : make test

@poros
Copy link

poros commented Feb 28, 2020

I don't want to nitpick, but I think that the hashing logic belongs to the hashing module, not the utils. If the problem is calling the hashing function in one of the yaml getters, I suggest you move them to the hashing module, too. They are going to be called in the contest of computing hashes anyway.

@poros
Copy link

poros commented Feb 28, 2020

Could you also please rope in the CI on-point? This is a library they maintain, so I think it would be good if someone from CI reviews it too

@poros
Copy link

poros commented Feb 28, 2020

What about adding the logic to show the diff of two objects here as well? I am sure that other operators would benefit from that too. Or do you think that it would be too Flink specific?

@AshishKhatkar
Copy link
Member Author

AshishKhatkar commented Feb 28, 2020

@poros

  • Regarding the logic of hashing function. The job of hashing module according to me is to generate the hash of the object. IMO how it gets that relevant object can be put into utils so that other modules if they want to use can use the same logic.
  • Yeah I will add someone from CI
  • Good suggestion, we can actually put that logic here as it is not specific to Flink object.

@Bronek Bronek requested review from mattmb and Baisang February 28, 2020 11:44
@Bronek
Copy link
Contributor

Bronek commented Feb 28, 2020

Could you also please rope in the CI on-point? This is a library they maintain, so I think it would be good if someone from CI reviews it too

I invited to review our CI colleagues who were involved in a related discussion to reconsider hashing k8s objects in operators

@AshishKhatkar AshishKhatkar requested review from chlgit, mattmb and Baisang and removed request for mattmb and Baisang February 28, 2020 11:45
@Bronek
Copy link
Contributor

Bronek commented Feb 28, 2020

I don't want to nitpick, but I think that the hashing logic belongs to the hashing module, not the utils. If the problem is calling the hashing function in one of the yaml getters, I suggest you move them to the hashing module, too. They are going to be called in the contest of computing hashes anyway.

I strongly support this. The reason being that the function GetHashObjectOfKubernetes takes some very specific parts of an object which matter for hashing only, while function GetYamlOfHashObjectOfK8sObject has a dependency on this particular behaviour. I think we probably do not need GetYamlOfObject, so that leaves nothing to utils module.

Copy link

@JoeMalt JoeMalt left a comment

Choose a reason for hiding this comment

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

2 nitpicks, one of which Antonio already picked up on. Otherwise looks good to me

@AshishKhatkar
Copy link
Member Author

AshishKhatkar commented Feb 28, 2020

Updated the review

  • Separate out logic of hashing into hashing/helper.go
  • Add logic to generate yaml diff of objects in utils/yamlhelper.go
  • If needed I can separate out the above 2 changes in 2 code reviews. Let me know if that is required.

Copy link
Contributor

@Bronek Bronek left a comment

Choose a reason for hiding this comment

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

This is rather nice - thank you for taking my feedback!

@AshishKhatkar AshishKhatkar requested a review from Bronek March 2, 2020 11:44
Copy link
Contributor

@Bronek Bronek left a comment

Choose a reason for hiding this comment

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

Just nitpicking on a comment!

@AshishKhatkar AshishKhatkar requested a review from Bronek March 2, 2020 12:12
@AshishKhatkar AshishKhatkar merged commit a689c52 into master Mar 2, 2020
mks-m pushed a commit that referenced this pull request Apr 23, 2020
* Adding support to get Yaml for k8s object

* Added logic to compute yaml diff, refactored hashing helper

* Nit changes for review

* Updating link for unified context
mks-m pushed a commit that referenced this pull request May 3, 2020
* Adding support to get Yaml for k8s object

* Added logic to compute yaml diff, refactored hashing helper

* Nit changes for review

* Updating link for unified context
mks-m pushed a commit that referenced this pull request May 4, 2020
* Adding support to get Yaml for k8s object

* Added logic to compute yaml diff, refactored hashing helper

* Nit changes for review

* Updating link for unified context
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.

4 participants