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 VPC parser #389

Merged
merged 6 commits into from
Oct 18, 2017
Merged

Fix VPC parser #389

merged 6 commits into from
Oct 18, 2017

Conversation

ddiachkov
Copy link
Contributor

This PR fixes problems with VPC parser + adds cidr_block_association_set attribute to model.
#379 was not sufficient – VPC list still contains duplicates with invalid status.

NB: cidr_block_association_set and ipv_6_cidr_block_association_set are array of hashes (currently ipv_6_cidr_block_association_set is a Hash)

Copy link
Member

@geemus geemus left a comment

Choose a reason for hiding this comment

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

Overall looking good, just added some minor feedback. Thanks!


attribute :cidr_block_association_set, :aliases => 'cidrBlockAssociationSet'

attribute :ipv_6_cidr_block_association_set, :aliases => 'ipv6CidrBlockAssociationSet'
Copy link
Member

Choose a reason for hiding this comment

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

I guess it was already there, but it seems surprising to me that this is ipv_6_cidr_block_association_set instead of ipv6_cidr_block_association_set. Does that make sense? I just happened to notice here (and have the same question about the new attribute below). What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you are right. We could just add alias for backward compatibility (ipv_6_cidr_block_association_set is already released...)

Copy link
Member

Choose a reason for hiding this comment

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

I hadn't even thought about that, but that sounds good. That way we can have more consistent names, but avoid breaking anybody. Sound good?

@current_cidr_block[name] = value

when 'vpcSet.item.cidrBlockAssociationSet.item.cidrBlockState'
@current_cidr_block['state'] = value.squish
Copy link
Member

Choose a reason for hiding this comment

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

In the old version state was capitalized as State, not sure it makes that much difference, but probably better safe than sorry. Could you change it?

Copy link
Contributor Author

@ddiachkov ddiachkov Sep 14, 2017

Choose a reason for hiding this comment

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

I don't like the inconsistency:

{
   "cidrBlock" => "...",
   "associationId" => "...",
   "State" => "associated"
}

Can we sacrifice backward compatibility in that case (knowing that ipv_6_cidr_block_association_set support just released)?

Copy link
Member

Choose a reason for hiding this comment

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

I don't feel super strongly about it, so I'm alright leaving it as you suggest. I just wanted to at least discuss it, which we now have. Thanks!

@current_ipv6_block[name] = value

when 'vpcSet.item.ipv6CidrBlockAssociationSet.item.ipv6CidrBlockState'
@current_ipv6_block['state'] = value.squish
Copy link
Member

Choose a reason for hiding this comment

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

Same thing here, if we could keep it as State for safety that would be great.

@geemus
Copy link
Member

geemus commented Sep 12, 2017

@lanej This looks good to me other than my feedback, but I would appreciate an extra set of eyes if you have a chance. Thanks!

@lanej
Copy link
Member

lanej commented Sep 25, 2017

Seeing some failure when doing live testing

irb(main):003:0> aws.describe_vpcs
#<NoMethodError: undefined method `squish' for "associated\n                    ":String>
#<NoMethodError: undefined method `squish' for "associated\n                    \n                ":String>
#<NoMethodError: undefined method `squish' for #<String:0x007fdf881e4898>>
#<NoMethodError: undefined method `squish' for "false\n        ":String>
#<NoMethodError: undefined method `squish' for "true\n        \n    ":String>
#<NoMethodError: undefined method `squish' for "true\n        \n    \n":String>

String#squish is an rails-ism that we do not have access to.

@geemus
Copy link
Member

geemus commented Sep 25, 2017

I'm fine with this going in and adding the aliases later too, if that is easier.

@lanej
Copy link
Member

lanej commented Sep 25, 2017

A squish reference was mistakenly introduced in 9e97b41.

@ddiachkov please rebase this PR and resolve conflicts, when you're ready.

@ddiachkov ddiachkov force-pushed the fix_vpc_parser branch 4 times, most recently from f8aa51b to 3a44e60 Compare October 1, 2017 07:58
@ddiachkov
Copy link
Contributor Author

@lanej done

@lanej
Copy link
Member

lanej commented Oct 5, 2017

Live tests result:

» FOG_MOCK=false be shindo tests/requests/compute/vpc_tests.rb
[fog][WARNING] Setting default fog timeout to 2000 seconds

  Fog::Compute[:aws] | vpc requests (aws)
    success
      #create_vpc + has proper format
      #create_vpc + has proper format
      #describe_vpcs - has proper format
        {"vpcSet"=>[{"tagSet"=>{}, "ipv6CidrBlockAssociationSet"=>{}, "vpcId"=>"vpc-9ee916e6", "state"=>"associated", "cidrBlock"=>"10.255.254.0/28"}, {"tagSet"=>{}, "ipv6CidrBlockAssociationSet"=>{}, "dhcpOptionsId"=>"dopt-d04fd7b4", "instanceTenancy"=>"default", "isDefault"=>false}, {"tagSet"=>{}, "ipv6CidrBlockAssociationSet"=>{}, "vpcId"=>"vpc-44ed123c", "state"=>"associated", "cidrBlock"=>"10.255.254.0/28"}, {"tagSet"=>{}, "ipv6CidrBlockAssociationSet"=>{}, "dhcpOptionsId"=>"dopt-d04fd7b4", "instanceTenancy"=>"default", "isDefault"=>false}], "requestId"=>"9a9e14cd-ccd0-4a07-bcd5-674e5a34de41"} does not match {"vpcSet"=>[{"vpcId"=>String, "state"=>String, "cidrBlock"=>String, "dhcpOptionsId"=>String, "tagSet"=>Hash, "instanceTenancy"=>Fog::Nullable::String}], "requestId"=>String}

Beyond that, I think this is ready to go.

@lanej
Copy link
Member

lanej commented Oct 5, 2017

@geemus I am still getting nil VPC ids with this change :(.

@ddiachkov
Copy link
Contributor Author

@lanej thats not right... Which field contains nil?

@lanej
Copy link
Member

lanej commented Oct 5, 2017

<Fog::Compute::AWS::VPC
        id=nil,
        state=nil,
        cidr_block=nil,
        dhcp_options_id="dopt-d04fd7b4",
        tags={},
        tenancy="default",
        is_default=false,
        ipv_6_cidr_block_association_set={},
        amazon_provided_ipv_6_cidr_block=false
      >

@ddiachkov seems the id is still nil, as reported in #387

@ddiachkov
Copy link
Contributor Author

Let me check it on a real AWS

@ddiachkov
Copy link
Contributor Author

Hey @lanej, are you sure you use this branch?

  [{"tagSet"=>{},
    "cidrBlockAssociationSet"=>
     [{"cidrBlock"=>"10.255.254.0/28",
       "associationId"=>"vpc-cidr-assoc-687a8b02",
       "state"=>"associated"}],
    "ipv6CidrBlockAssociationSet"=>[],
    "vpcId"=>"vpc-cab34db2",
    "state"=>"available",
    "cidrBlock"=>"10.255.254.0/28",
    "dhcpOptionsId"=>"dopt-2873c74c",
    "instanceTenancy"=>"default",
    "isDefault"=>false},
   {"tagSet"=>{},
    "cidrBlockAssociationSet"=>
     [{"cidrBlock"=>"172.31.0.0/16",
       "associationId"=>"vpc-cidr-assoc-473c8e2e",
       "state"=>"associated"}],
    "ipv6CidrBlockAssociationSet"=>[],
    "vpcId"=>"vpc-3e9d1659",
    "state"=>"available",
    "cidrBlock"=>"172.31.0.0/16",
    "dhcpOptionsId"=>"dopt-2873c74c",
    "instanceTenancy"=>"default",
    "isDefault"=>true},
   {"tagSet"=>{},
    "cidrBlockAssociationSet"=>
     [{"cidrBlock"=>"10.255.254.0/28",
       "associationId"=>"vpc-cidr-assoc-c17988ab",
       "state"=>"associated"}],
    "ipv6CidrBlockAssociationSet"=>[],
    "vpcId"=>"vpc-5cb04e24",
    "state"=>"available",
    "cidrBlock"=>"10.255.254.0/28",
    "dhcpOptionsId"=>"dopt-2873c74c",
    "instanceTenancy"=>"default",
    "isDefault"=>false}],
 "requestId"=>"920616e6-36fd-4779-9c41-21f0518aa52c"}

Thats what I get on a real AWS. Notice that ipv_6_cidr_block_association_set is an Array, not Hash.

@ddiachkov
Copy link
Contributor Author

I've added additional format tests.

@lanej
Copy link
Member

lanej commented Oct 6, 2017

Thanks @ddiachkov.

Hey @geemus, how would you feel about moving the Gemfile.edge tests to allowed failures in Travis CI? This branch is failing due to an unrelated change on fog-core, I think fog/fog-core#218

@geemus
Copy link
Member

geemus commented Oct 17, 2017

@lanej feel free to do that if you think it makes sense (though presumably we'll want to also fix that before release?).

@lanej
Copy link
Member

lanej commented Oct 17, 2017

@ddiachkov sorry for the delay. If you rebase off master, we can get this out.

@ddiachkov
Copy link
Contributor Author

No worries. I've rebased the code – looks like tests are passed.

@lanej
Copy link
Member

lanej commented Oct 17, 2017

@geemus has your feedback been addressed?

@geemus
Copy link
Member

geemus commented Oct 18, 2017

@lanej I think so, thanks for double checking!

@geemus geemus merged commit 298a99d into fog:master Oct 18, 2017
@geemus
Copy link
Member

geemus commented Oct 18, 2017

@ddiachkov thanks!

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.

3 participants