Skip to content

Commit

Permalink
Merge pull request #1095 from caseydavenport/automated-cherry-pick-of…
Browse files Browse the repository at this point in the history
…-#1088-origin-release-v3.7

Automated cherry pick of #1088: Update should set defaults before doing validation
  • Loading branch information
caseydavenport committed Jun 5, 2019
2 parents 6860ff2 + a4484a0 commit 8898b03
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
9 changes: 5 additions & 4 deletions lib/clientv3/ippool.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2017-2018 Tigera, Inc. All rights reserved.
// Copyright (c) 2017-2019 Tigera, Inc. All rights reserved.

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -129,9 +129,6 @@ func (r ipPools) Update(ctx context.Context, res *apiv3.IPPool, opts options.Set
resCopy := *res
res = &resCopy
}
if err := validator.Validate(res); err != nil {
return nil, err
}

// Get the existing settings, so that we can validate the CIDR and block size have not changed.
old, err := r.Get(ctx, res.Name, options.GetOptions{})
Expand All @@ -144,6 +141,10 @@ func (r ipPools) Update(ctx context.Context, res *apiv3.IPPool, opts options.Set
return nil, err
}

if err := validator.Validate(res); err != nil {
return nil, err
}

// Enable IPIP globally if required. Do this before the Update so if it fails the user
// can retry the same command.
err = r.maybeEnableIPIP(ctx, res)
Expand Down
27 changes: 26 additions & 1 deletion lib/clientv3/ippool_e2e_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2017-2018 Tigera, Inc. All rights reserved.
// Copyright (c) 2017-2018,2019 Tigera, Inc. All rights reserved.

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -493,6 +493,14 @@ var _ = testutils.E2eDatastoreDescribe("IPPool tests", testutils.DatastoreAll, f
})

Describe("Verify handling of VXLAN mode", func() {

var missingVxlanPool = apiv3.IPPool{
ObjectMeta: metav1.ObjectMeta{Name: "ippool1"},
Spec: apiv3.IPPoolSpec{
CIDR: "192.168.0.0/16",
},
}

var err error
var c clientv3.Interface

Expand All @@ -513,6 +521,23 @@ var _ = testutils.E2eDatastoreDescribe("IPPool tests", testutils.DatastoreAll, f
return cfg.Spec.VXLANEnabled, nil
}

It("should create/update an IPPool when VXLAN is missing", func() {
// create an ipppol with missing vxlan
ipPoolV1 := missingVxlanPool.DeepCopy()
ipPoolV2, err := c.IPPools().Create(ctx, ipPoolV1, options.SetOptions{})
Expect(err).NotTo(HaveOccurred())

// update an ipppol with missing vxlan
ipPoolV2.Spec.VXLANMode = ""
_, err = c.IPPools().Update(ctx, ipPoolV2, options.SetOptions{})
Expect(err).NotTo(HaveOccurred())

// delete the ipppol
_, err = c.IPPools().Delete(ctx, ipPoolV2.Name, options.DeleteOptions{})
Expect(err).NotTo(HaveOccurred())

})

It("should enable VXLAN globally on an IPPool Create (VXLANModeAlways) if the global setting is not configured", func() {
By("Getting the current felix configuration - checking does not exist")
_, err = getGlobalSetting()
Expand Down

0 comments on commit 8898b03

Please sign in to comment.