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

Created set machine type request #485

Merged
merged 4 commits into from
Feb 24, 2020
Merged

Conversation

gscho
Copy link
Contributor

@gscho gscho commented Jan 28, 2020

Adds a set_server_machine_type request. This is useful for changing a server's machine type although the instance must be stopped to do so.

Signed-off-by: gscho [email protected]

@gscho gscho requested review from Temikus and icco January 28, 2020 18:56
@kgaikwad
Copy link
Contributor

kgaikwad commented Feb 3, 2020

In addition to this, would it be possible to add method on server model to change machine_type? This method will be responsible to check status of that server. If stopped then allowed user to do so.

@gscho
Copy link
Contributor Author

gscho commented Feb 3, 2020

@kgaikwad I could do that, sure. If I understand correctly, the method should raise an error if the server is not stopped:

set_machine_type
   raise unless status is stopped
end

That way we're not implicitly stopping the server.

Copy link
Member

@Temikus Temikus left a comment

Choose a reason for hiding this comment

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

Please add a Server model method as mentioned in #485 (comment)
Asking since we're trying to discourage using raw requests.

Otherwise LGTM, thanks for this!

@codecov
Copy link

codecov bot commented Feb 18, 2020

Codecov Report

Merging #485 into master will increase coverage by 2.49%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #485      +/-   ##
==========================================
+ Coverage   86.37%   88.86%   +2.49%     
==========================================
  Files         339      340       +1     
  Lines        6819     5659    -1160     
==========================================
- Hits         5890     5029     -861     
+ Misses        929      630     -299
Impacted Files Coverage Δ
...compute/google/requests/set_server_machine_type.rb 100% <100%> (ø)
lib/fog/compute/google.rb 100% <100%> (ø) ⬆️
lib/fog/compute/google/models/server.rb 78.36% <100%> (+2.24%) ⬆️
lib/fog/google/sql/mock.rb 61.11% <0%> (-25.99%) ⬇️
lib/fog/google/pubsub/mock.rb 62.5% <0%> (-24.46%) ⬇️
lib/fog/google/requests/sql/import_instance.rb 50% <0%> (-23.92%) ⬇️
lib/fog/google/requests/sql/export_instance.rb 43.75% <0%> (-21.93%) ⬇️
lib/fog/google/models/sql/operations.rb 57.89% <0%> (-14.11%) ⬇️
lib/fog/google/requests/pubsub/list_topics.rb 83.33% <0%> (-4.17%) ⬇️
lib/fog/compute/google/mock.rb 50% <0%> (-11.54%) ⬇️
... and 77 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update abb11e9...0e85063. Read the comment docs.

@Temikus
Copy link
Member

Temikus commented Feb 24, 2020

@gscho Thank you for the tests \o/

Looks there's only one caveat here, the returned resource will give you the full identity (resource link), instead of name (which looks to be correct since different zones have different machine types available):

λ bundle exec rake test TESTOPTS="--name=TestServers#test_set_machine_type"
Started with run options --name=TestServers#test_set_machine_type --seed 16020

TestServers
  test_set_machine_type                                           FAIL (114.00s)
        --- expected
        +++ actual
        @@ -1 +1 @@
        -"n1-standard-2"
        +"https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-f/machineTypes/n1-standard-2"
        /Users/temikus/fog-dev/fog-google/test/integration/compute/core_compute/test_servers.rb:28:in `test_set_machine_type'

@gscho
Copy link
Contributor Author

gscho commented Feb 24, 2020

Thank you @Temikus. I was unable to log into concourse with Chrome, Firefox or Safari (via Github SSO) 😞

@Temikus
Copy link
Member

Temikus commented Feb 24, 2020

@gscho
Re: PR - looks great, I'll merge this in! :)

Re: Concourse - I'm afraid this is currently by design. Since fog is an infra library it is theoretically possible to expose secrets and concourse doesn't allow for easy arbitrary secret redaction.

It is possible to use mocks and we did so in the past but experience has shown us that the GCP API changes too quickly to have reliable VCR cassettes.

It is on my (mile-long, I admit) todo list, with the following:

  • Planning to migrate to drone.io soon'ish which should make publishing the pipeline easier
  • Adding more mocks which should allow us to run more of those tests in Travis

@Temikus Temikus merged commit a82c2c5 into fog:master Feb 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants