Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
e1daee5b
Commit
e1daee5b
authored
Dec 06, 2016
by
bprashanth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete regional static-ip instead of global for type=lb
parent
94051999
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
21 deletions
+54
-21
BUILD
test/e2e/BUILD
+0
-1
BUILD
test/e2e/framework/BUILD
+2
-0
google_compute.go
test/e2e/framework/google_compute.go
+9
-10
util.go
test/e2e/framework/util.go
+40
-7
service.go
test/e2e/service.go
+3
-3
No files found.
test/e2e/BUILD
View file @
e1daee5b
...
@@ -57,7 +57,6 @@ go_library(
...
@@ -57,7 +57,6 @@ go_library(
"generated_clientset.go",
"generated_clientset.go",
"gke_local_ssd.go",
"gke_local_ssd.go",
"gke_node_pools.go",
"gke_node_pools.go",
"google_compute.go",
"ha_master.go",
"ha_master.go",
"horizontal_pod_autoscaling.go",
"horizontal_pod_autoscaling.go",
"ingress.go",
"ingress.go",
...
...
test/e2e/framework/BUILD
View file @
e1daee5b
...
@@ -17,6 +17,7 @@ go_library(
...
@@ -17,6 +17,7 @@ go_library(
"exec_util.go",
"exec_util.go",
"federation_util.go",
"federation_util.go",
"framework.go",
"framework.go",
"google_compute.go",
"kubelet_stats.go",
"kubelet_stats.go",
"log_size_monitoring.go",
"log_size_monitoring.go",
"metrics_util.go",
"metrics_util.go",
...
@@ -99,6 +100,7 @@ go_library(
...
@@ -99,6 +100,7 @@ go_library(
"//vendor:github.com/spf13/viper",
"//vendor:github.com/spf13/viper",
"//vendor:golang.org/x/crypto/ssh",
"//vendor:golang.org/x/crypto/ssh",
"//vendor:golang.org/x/net/websocket",
"//vendor:golang.org/x/net/websocket",
"//vendor:google.golang.org/api/googleapi",
"//vendor:gopkg.in/yaml.v2",
"//vendor:gopkg.in/yaml.v2",
"//vendor:k8s.io/client-go/kubernetes",
"//vendor:k8s.io/client-go/kubernetes",
"//vendor:k8s.io/client-go/pkg/util/sets",
"//vendor:k8s.io/client-go/pkg/util/sets",
...
...
test/e2e/google_compute.go
→
test/e2e/
framework/
google_compute.go
View file @
e1daee5b
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
e2e
package
framework
import
(
import
(
"fmt"
"fmt"
...
@@ -26,13 +26,12 @@ import (
...
@@ -26,13 +26,12 @@ import (
"github.com/golang/glog"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce"
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce"
"k8s.io/kubernetes/test/e2e/framework"
)
)
// TODO: These should really just use the GCE API client library or at least use
// TODO: These should really just use the GCE API client library or at least use
// better formatted output from the --format flag.
// better formatted output from the --format flag.
func
c
reateGCEStaticIP
(
name
string
)
(
string
,
error
)
{
func
C
reateGCEStaticIP
(
name
string
)
(
string
,
error
)
{
// gcloud compute --project "abshah-kubernetes-001" addresses create "test-static-ip" --region "us-central1"
// gcloud compute --project "abshah-kubernetes-001" addresses create "test-static-ip" --region "us-central1"
// abshah@abhidesk:~/go/src/code.google.com/p/google-api-go-client/compute/v1$ gcloud compute --project "abshah-kubernetes-001" addresses create "test-static-ip" --region "us-central1"
// abshah@abhidesk:~/go/src/code.google.com/p/google-api-go-client/compute/v1$ gcloud compute --project "abshah-kubernetes-001" addresses create "test-static-ip" --region "us-central1"
// Created [https://www.googleapis.com/compute/v1/projects/abshah-kubernetes-001/regions/us-central1/addresses/test-static-ip].
// Created [https://www.googleapis.com/compute/v1/projects/abshah-kubernetes-001/regions/us-central1/addresses/test-static-ip].
...
@@ -41,14 +40,14 @@ func createGCEStaticIP(name string) (string, error) {
...
@@ -41,14 +40,14 @@ func createGCEStaticIP(name string) (string, error) {
var
outputBytes
[]
byte
var
outputBytes
[]
byte
var
err
error
var
err
error
region
,
err
:=
gce
.
GetGCERegion
(
framework
.
TestContext
.
CloudConfig
.
Zone
)
region
,
err
:=
gce
.
GetGCERegion
(
TestContext
.
CloudConfig
.
Zone
)
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"failed to convert zone to region: %v"
,
err
)
return
""
,
fmt
.
Errorf
(
"failed to convert zone to region: %v"
,
err
)
}
}
glog
.
Infof
(
"Creating static IP with name %q in project %q in region %q"
,
name
,
framework
.
TestContext
.
CloudConfig
.
ProjectID
,
region
)
glog
.
Infof
(
"Creating static IP with name %q in project %q in region %q"
,
name
,
TestContext
.
CloudConfig
.
ProjectID
,
region
)
for
attempts
:=
0
;
attempts
<
4
;
attempts
++
{
for
attempts
:=
0
;
attempts
<
4
;
attempts
++
{
outputBytes
,
err
=
exec
.
Command
(
"gcloud"
,
"compute"
,
"addresses"
,
"create"
,
outputBytes
,
err
=
exec
.
Command
(
"gcloud"
,
"compute"
,
"addresses"
,
"create"
,
name
,
"--project"
,
framework
.
TestContext
.
CloudConfig
.
ProjectID
,
name
,
"--project"
,
TestContext
.
CloudConfig
.
ProjectID
,
"--region"
,
region
,
"-q"
)
.
CombinedOutput
()
"--region"
,
region
,
"-q"
)
.
CombinedOutput
()
if
err
==
nil
{
if
err
==
nil
{
break
break
...
@@ -75,20 +74,20 @@ func createGCEStaticIP(name string) (string, error) {
...
@@ -75,20 +74,20 @@ func createGCEStaticIP(name string) (string, error) {
}
}
}
}
func
d
eleteGCEStaticIP
(
name
string
)
error
{
func
D
eleteGCEStaticIP
(
name
string
)
error
{
// gcloud compute --project "abshah-kubernetes-001" addresses create "test-static-ip" --region "us-central1"
// gcloud compute --project "abshah-kubernetes-001" addresses create "test-static-ip" --region "us-central1"
// abshah@abhidesk:~/go/src/code.google.com/p/google-api-go-client/compute/v1$ gcloud compute --project "abshah-kubernetes-001" addresses create "test-static-ip" --region "us-central1"
// abshah@abhidesk:~/go/src/code.google.com/p/google-api-go-client/compute/v1$ gcloud compute --project "abshah-kubernetes-001" addresses create "test-static-ip" --region "us-central1"
// Created [https://www.googleapis.com/compute/v1/projects/abshah-kubernetes-001/regions/us-central1/addresses/test-static-ip].
// Created [https://www.googleapis.com/compute/v1/projects/abshah-kubernetes-001/regions/us-central1/addresses/test-static-ip].
// NAME REGION ADDRESS STATUS
// NAME REGION ADDRESS STATUS
// test-static-ip us-central1 104.197.143.7 RESERVED
// test-static-ip us-central1 104.197.143.7 RESERVED
region
,
err
:=
gce
.
GetGCERegion
(
framework
.
TestContext
.
CloudConfig
.
Zone
)
region
,
err
:=
gce
.
GetGCERegion
(
TestContext
.
CloudConfig
.
Zone
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to convert zone to region: %v"
,
err
)
return
fmt
.
Errorf
(
"failed to convert zone to region: %v"
,
err
)
}
}
glog
.
Infof
(
"Deleting static IP with name %q in project %q in region %q"
,
name
,
framework
.
TestContext
.
CloudConfig
.
ProjectID
,
region
)
glog
.
Infof
(
"Deleting static IP with name %q in project %q in region %q"
,
name
,
TestContext
.
CloudConfig
.
ProjectID
,
region
)
outputBytes
,
err
:=
exec
.
Command
(
"gcloud"
,
"compute"
,
"addresses"
,
"delete"
,
outputBytes
,
err
:=
exec
.
Command
(
"gcloud"
,
"compute"
,
"addresses"
,
"delete"
,
name
,
"--project"
,
framework
.
TestContext
.
CloudConfig
.
ProjectID
,
name
,
"--project"
,
TestContext
.
CloudConfig
.
ProjectID
,
"--region"
,
region
,
"-q"
)
.
CombinedOutput
()
"--region"
,
region
,
"-q"
)
.
CombinedOutput
()
if
err
!=
nil
{
if
err
!=
nil
{
// Ditch the error, since the stderr in the output is what actually contains
// Ditch the error, since the stderr in the output is what actually contains
...
...
test/e2e/framework/util.go
View file @
e1daee5b
...
@@ -41,6 +41,7 @@ import (
...
@@ -41,6 +41,7 @@ import (
"time"
"time"
"github.com/golang/glog"
"github.com/golang/glog"
"google.golang.org/api/googleapi"
"k8s.io/kubernetes/federation/client/clientset_generated/federation_release_1_5"
"k8s.io/kubernetes/federation/client/clientset_generated/federation_release_1_5"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
apierrs
"k8s.io/kubernetes/pkg/api/errors"
apierrs
"k8s.io/kubernetes/pkg/api/errors"
...
@@ -4945,17 +4946,49 @@ func (p *E2ETestNodePreparer) CleanupNodes() error {
...
@@ -4945,17 +4946,49 @@ func (p *E2ETestNodePreparer) CleanupNodes() error {
return
encounteredError
return
encounteredError
}
}
func
CleanupGCEResources
(
loadBalancerName
string
)
(
err
error
)
{
// CleanupGCEResources cleans up GCE Service Type=LoadBalancer resources with
// the given name. The name is usually the UUID of the Service prefixed with an
// alpha-numeric character ('a') to work around cloudprovider rules.
func
CleanupGCEResources
(
loadBalancerName
string
)
(
retErr
error
)
{
gceCloud
,
ok
:=
TestContext
.
CloudConfig
.
Provider
.
(
*
gcecloud
.
GCECloud
)
gceCloud
,
ok
:=
TestContext
.
CloudConfig
.
Provider
.
(
*
gcecloud
.
GCECloud
)
if
!
ok
{
if
!
ok
{
return
fmt
.
Errorf
(
"failed to convert CloudConfig.Provider to GCECloud: %#v"
,
TestContext
.
CloudConfig
.
Provider
)
return
fmt
.
Errorf
(
"failed to convert CloudConfig.Provider to GCECloud: %#v"
,
TestContext
.
CloudConfig
.
Provider
)
}
}
gceCloud
.
DeleteFirewall
(
loadBalancerName
)
if
err
:=
gceCloud
.
DeleteFirewall
(
loadBalancerName
);
err
!=
nil
&&
gceCloud
.
DeleteForwardingRule
(
loadBalancerName
)
!
IsGoogleAPIHTTPErrorCode
(
err
,
http
.
StatusNotFound
)
{
gceCloud
.
DeleteGlobalStaticIP
(
loadBalancerName
)
retErr
=
err
hc
,
_
:=
gceCloud
.
GetHttpHealthCheck
(
loadBalancerName
)
}
gceCloud
.
DeleteTargetPool
(
loadBalancerName
,
hc
)
if
err
:=
gceCloud
.
DeleteForwardingRule
(
loadBalancerName
);
err
!=
nil
&&
return
nil
!
IsGoogleAPIHTTPErrorCode
(
err
,
http
.
StatusNotFound
)
{
retErr
=
fmt
.
Errorf
(
"%v
\n
%v"
,
retErr
,
err
)
}
if
err
:=
gceCloud
.
DeleteGlobalStaticIP
(
loadBalancerName
);
err
!=
nil
&&
!
IsGoogleAPIHTTPErrorCode
(
err
,
http
.
StatusNotFound
)
{
retErr
=
fmt
.
Errorf
(
"%v
\n
%v"
,
retErr
,
err
)
}
// This function shells out to gcloud, so we can't compare for NotFound errors.
// TODO: Invoke cloudprovider method directly instead.
if
err
:=
DeleteGCEStaticIP
(
loadBalancerName
);
err
!=
nil
{
Logf
(
"%v"
,
err
)
}
hc
,
getErr
:=
gceCloud
.
GetHttpHealthCheck
(
loadBalancerName
)
if
getErr
!=
nil
&&
!
IsGoogleAPIHTTPErrorCode
(
getErr
,
http
.
StatusNotFound
)
{
retErr
=
fmt
.
Errorf
(
"%v
\n
%v"
,
retErr
,
getErr
)
return
}
if
err
:=
gceCloud
.
DeleteTargetPool
(
loadBalancerName
,
hc
);
err
!=
nil
&&
!
IsGoogleAPIHTTPErrorCode
(
err
,
http
.
StatusNotFound
)
{
retErr
=
fmt
.
Errorf
(
"%v
\n
%v"
,
retErr
,
err
)
}
return
}
// IsHTTPErrorCode returns true if the error is a google api
// error matching the corresponding HTTP error code.
func
IsGoogleAPIHTTPErrorCode
(
err
error
,
code
int
)
bool
{
apiErr
,
ok
:=
err
.
(
*
googleapi
.
Error
)
return
ok
&&
apiErr
.
Code
==
code
}
}
// getMaster populates the externalIP, internalIP and hostname fields of the master.
// getMaster populates the externalIP, internalIP and hostname fields of the master.
...
...
test/e2e/service.go
View file @
e1daee5b
...
@@ -580,12 +580,12 @@ var _ = framework.KubeDescribe("Services", func() {
...
@@ -580,12 +580,12 @@ var _ = framework.KubeDescribe("Services", func() {
if
framework
.
ProviderIs
(
"gce"
,
"gke"
)
{
if
framework
.
ProviderIs
(
"gce"
,
"gke"
)
{
By
(
"creating a static load balancer IP"
)
By
(
"creating a static load balancer IP"
)
staticIPName
=
fmt
.
Sprintf
(
"e2e-external-lb-test-%s"
,
framework
.
RunId
)
staticIPName
=
fmt
.
Sprintf
(
"e2e-external-lb-test-%s"
,
framework
.
RunId
)
requestedIP
,
err
=
c
reateGCEStaticIP
(
staticIPName
)
requestedIP
,
err
=
framework
.
C
reateGCEStaticIP
(
staticIPName
)
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
Expect
(
err
)
.
NotTo
(
HaveOccurred
())
defer
func
()
{
defer
func
()
{
if
staticIPName
!=
""
{
if
staticIPName
!=
""
{
// Release GCE static IP - this is not kube-managed and will not be automatically released.
// Release GCE static IP - this is not kube-managed and will not be automatically released.
if
err
:=
d
eleteGCEStaticIP
(
staticIPName
);
err
!=
nil
{
if
err
:=
framework
.
D
eleteGCEStaticIP
(
staticIPName
);
err
!=
nil
{
framework
.
Logf
(
"failed to release static IP %s: %v"
,
staticIPName
,
err
)
framework
.
Logf
(
"failed to release static IP %s: %v"
,
staticIPName
,
err
)
}
}
}
}
...
@@ -632,7 +632,7 @@ var _ = framework.KubeDescribe("Services", func() {
...
@@ -632,7 +632,7 @@ var _ = framework.KubeDescribe("Services", func() {
if
staticIPName
!=
""
{
if
staticIPName
!=
""
{
// Deleting it after it is attached "demotes" it to an
// Deleting it after it is attached "demotes" it to an
// ephemeral IP, which can be auto-released.
// ephemeral IP, which can be auto-released.
if
err
:=
d
eleteGCEStaticIP
(
staticIPName
);
err
!=
nil
{
if
err
:=
framework
.
D
eleteGCEStaticIP
(
staticIPName
);
err
!=
nil
{
framework
.
Failf
(
"failed to release static IP %s: %v"
,
staticIPName
,
err
)
framework
.
Failf
(
"failed to release static IP %s: %v"
,
staticIPName
,
err
)
}
}
staticIPName
=
""
staticIPName
=
""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment