Skip to content

Commit

Permalink
Add cce runtime option (#518)
Browse files Browse the repository at this point in the history
Add cce runtime option

Tests passed
=== RUN   TestNodes
--- PASS: TestNodes (743.95s)
=== RUN   TestNodes/TestNodeLifecycle
    --- PASS: TestNodes/TestNodeLifecycle (257.69s)
PASS

Reviewed-by: Anton Sidelnikov
Reviewed-by: Artem Lifshits
  • Loading branch information
vladimirvshivkov authored Apr 19, 2023
1 parent 7597df6 commit fe9f11e
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 20 deletions.
1 change: 1 addition & 0 deletions acceptance/openstack/cce/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func CreateCluster(t *testing.T, vpcID, subnetID string) string {
VpcId: vpcID,
SubnetId: subnetID,
},
Version: "v1.25",
ContainerNetwork: clusters.ContainerNetworkSpec{
Mode: "overlay_l2",
},
Expand Down
7 changes: 5 additions & 2 deletions acceptance/openstack/cce/v3/nodes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (s *testNodes) TestNodeLifecycle() {
client, err := clients.NewCceV3Client()
th.AssertNoErr(t, err)

privateIP := "192.168.1.12" // suppose used subnet is 192.168.0.0/16
privateIP := "192.168.0.12" // suppose used subnet is 192.168.0.0/16

kp := cce.CreateKeypair(t)
defer cce.DeleteKeypair(t, kp)
Expand All @@ -71,7 +71,7 @@ func (s *testNodes) TestNodeLifecycle() {
Spec: nodes.Spec{
Flavor: "s2.xlarge.2",
Az: "eu-de-01",
Os: "EulerOS 2.5",
Os: "EulerOS 2.9",
Login: nodes.LoginSpec{
SshKey: kp,
},
Expand All @@ -96,6 +96,9 @@ func (s *testNodes) TestNodeLifecycle() {
FixedIPs: []string{privateIP},
},
},
Runtime: nodes.RuntimeSpec{
Name: "containerd",
},
ExtendParam: nodes.ExtendParam{
MaxPods: 16,
DockerBaseSize: 20,
Expand Down
8 changes: 8 additions & 0 deletions openstack/cce/v3/nodes/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ type Spec struct {
K8sTags map[string]string `json:"k8sTags,omitempty"`
// taints to created nodes to configure anti-affinity
Taints []TaintSpec `json:"taints,omitempty"`
// Container runtime. The default value is docker.
Runtime RuntimeSpec `json:"runtime,omitempty"`
}

type RuntimeSpec struct {
// Container runtime. The default value is docker.
// Enumeration values: docker, containerd
Name string `json:"name,omitempty"`
}

// NodeNicSpec spec of the node
Expand Down
12 changes: 9 additions & 3 deletions openstack/cce/v3/nodes/testing/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ const Output = `{
"volumetype": "SATA",
"size": 100
}
]
],
"runtime": {
"name": "containerd"
}
}
}`

Expand All @@ -54,13 +57,16 @@ var Expected = &nodes.Nodes{
Size: 100,
},
},
Runtime: nodes.RuntimeSpec{
Name: "containerd",
},
},
}

const JobOutput = `{
"kind": "Job",
"metadata": {
"uid": "73ce052c-8b1b-11e8-8f9d-0255ac10193f"
"uid": "73ce052c-8b1b-11e8-8f9d-0255ac10193f"
},
"spec": {
"type": "ScaleupCluster",
Expand All @@ -80,7 +86,7 @@ const JobOutput = `{
{
"kind": "Job",
"metadata": {
"uid": "73ce03fd-8b1b-11e8-8f9d-0255ac10193f"
"uid": "73ce03fd-8b1b-11e8-8f9d-0255ac10193f"
},
"spec": {
"type": "GetPSMCert",
Expand Down
17 changes: 14 additions & 3 deletions openstack/cce/v3/nodes/testing/requests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ func TestListNode(t *testing.T) {
"size": 100
}
],
"runtime": {
"name": "containerd"
},
"publicIP": {
"eip": {
"bandwidth": {}
Expand All @@ -75,7 +78,7 @@ func TestListNode(t *testing.T) {
t.Errorf("Failed to extract nodes: %v", err)
}

expected := []nodes.Nodes{
var expected = []nodes.Nodes{
{
Kind: "Host",
Apiversion: "v3",
Expand All @@ -91,11 +94,13 @@ func TestListNode(t *testing.T) {
Size: 100,
}},
Flavor: "s1.medium",
Runtime: nodes.RuntimeSpec{
Name: "containerd",
},
},
Status: nodes.Status{Phase: "Active", ServerID: "41748e56-33d4-46a1-aa57-2c8c29907995", PrivateIP: "192.168.0.3"},
},
}

th.AssertDeepEquals(t, expected, actual)
}

Expand Down Expand Up @@ -165,7 +170,10 @@ func TestCreateV3Node(t *testing.T) {
"rootVolume": {
"size": 40,
"volumetype": "SATA"
}
},
"runtime": {
"name": "containerd"
}
}
}
`)
Expand Down Expand Up @@ -193,6 +201,9 @@ func TestCreateV3Node(t *testing.T) {
},
},
Count: 1,
Runtime: nodes.RuntimeSpec{
Name: "containerd",
},
},
}
actual, err := nodes.Create(fake.ServiceClient(), "cec124c2-58f1-11e8-ad73-0255ac101926", options).Extract()
Expand Down
22 changes: 10 additions & 12 deletions openstack/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func DeleteNotPassParams(params *map[string]interface{}, notPassParams []string)
}
}

// merges two interfaces. In cases where a value is defined for both 'overridingInterface' and
// MergeInterfaces merges two interfaces. In cases where a value is defined for both 'overridingInterface' and
// 'inferiorInterface' the value in 'overridingInterface' will take precedence.
func MergeInterfaces(overridingInterface, inferiorInterface interface{}) interface{} {
switch overriding := overridingInterface.(type) {
Expand All @@ -35,9 +35,7 @@ func MergeInterfaces(overridingInterface, inferiorInterface interface{}) interfa
if !ok {
return overriding
}
for i := range list {
overriding = append(overriding, list[i])
}
overriding = append(overriding, list)
return overriding
case nil:
// mergeClouds(nil, map[string]interface{...}) -> map[string]interface{...}
Expand All @@ -63,14 +61,14 @@ func PrependString(item string, slice []string) []string {
return result
}

func In(item interface{}, slice interface{}) bool {
for _, it := range slice.([]interface{}) {
if reflect.DeepEqual(item, it) {
return true
}
}
return false
}
// func In(item interface{}, slice interface{}) bool {
// for _, it := range slice.([]interface{}) {
// if reflect.DeepEqual(item, it) {
// return true
// }
// }
// return false
// }

// GetRegion returns the region that was specified in the auth options. If a
// region was not set it returns value from env OS_REGION_NAME
Expand Down

0 comments on commit fe9f11e

Please sign in to comment.