Skip to content

Commit 112a67f

Browse files
authored
Remove/Add ClearContainer/COW Container type support (#391)
* Remove/Add ClearContainer/COW Container type
1 parent fccf269 commit 112a67f

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

cns/NetworkContainerContract.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ const (
2323
const (
2424
AzureContainerInstance = "AzureContainerInstance"
2525
WebApps = "WebApps"
26-
ClearContainer = "ClearContainer"
2726
Docker = "Docker"
2827
Basic = "Basic"
2928
JobObject = "JobObject"
29+
COW = "COW" // Container on Windows
3030
)
3131

3232
// Orchestrator Types
@@ -171,7 +171,7 @@ type AttachContainerToNetworkResponse struct {
171171
Response Response
172172
}
173173

174-
// DetachNetworkContainerToNetworkResponse specifies response of detaching network container from network.
174+
// DetachContainerFromNetworkResponse specifies response of detaching network container from network.
175175
type DetachContainerFromNetworkResponse struct {
176176
Response Response
177177
}

cns/restserver/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const (
2626
UnexpectedError = 99
2727
)
2828

29+
// ReturnCodeToString - Converts an error code to appropriate string.
2930
func ReturnCodeToString(returnCode int) (s string) {
3031
switch returnCode {
3132
case Success:

cns/restserver/restserver.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ func (service *HTTPRestService) Stop() {
191191
log.Printf("[Azure CNS] Service stopped.")
192192
}
193193

194-
// Get dnc/service partition key
194+
// GetPartitionKey - Get dnc/service partition key
195195
func (service *HTTPRestService) GetPartitionKey() (dncPartitionKey string) {
196196
service.lock.Lock()
197197
dncPartitionKey = service.dncPartitionKey
@@ -1025,13 +1025,13 @@ func (service *HTTPRestService) saveNetworkContainerGoalState(req cns.CreateNetw
10251025
switch req.NetworkContainerType {
10261026
case cns.AzureContainerInstance:
10271027
fallthrough
1028-
case cns.ClearContainer:
1029-
fallthrough
10301028
case cns.Docker:
10311029
fallthrough
10321030
case cns.Basic:
10331031
fallthrough
10341032
case cns.JobObject:
1033+
fallthrough
1034+
case cns.COW:
10351035
switch service.state.OrchestratorType {
10361036
case cns.Kubernetes:
10371037
fallthrough

cns/restserver/restserver_test.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ func TestCreateNetworkContainer(t *testing.T) {
580580

581581
// Test create network container of type JobObject
582582
fmt.Println("TestCreateNetworkContainer: JobObject")
583-
err := creatOrUpdateNetworkContainerWithName(t, "testJobObject", "11.0.0.5", "JobObject")
583+
err := creatOrUpdateNetworkContainerWithName(t, "testJobObject", "10.1.0.5", "JobObject")
584584
if err != nil {
585585
t.Errorf("Failed to save the goal state for network container of type JobObject "+
586586
" due to error: %+v", err)
@@ -596,13 +596,13 @@ func TestCreateNetworkContainer(t *testing.T) {
596596

597597
// Test create network container of type WebApps
598598
fmt.Println("TestCreateNetworkContainer: WebApps")
599-
err = creatOrUpdateNetworkContainerWithName(t, "ethWebApp", "11.0.0.5", "WebApps")
599+
err = creatOrUpdateNetworkContainerWithName(t, "ethWebApp", "192.0.0.5", "WebApps")
600600
if err != nil {
601601
t.Errorf("creatOrUpdateWebAppContainerWithName failed Err:%+v", err)
602602
t.Fatal(err)
603603
}
604604

605-
err = creatOrUpdateNetworkContainerWithName(t, "ethWebApp", "11.0.0.6", "WebApps")
605+
err = creatOrUpdateNetworkContainerWithName(t, "ethWebApp", "192.0.0.6", "WebApps")
606606
if err != nil {
607607
t.Errorf("Updating interface failed Err:%+v", err)
608608
t.Fatal(err)
@@ -616,6 +616,21 @@ func TestCreateNetworkContainer(t *testing.T) {
616616
t.Fatal(err)
617617
}
618618

619+
// Test create network container of type COW
620+
err = creatOrUpdateNetworkContainerWithName(t, "testCOWContainer", "10.0.0.5", "COW")
621+
if err != nil {
622+
t.Errorf("Failed to save the goal state for network container of type COW"+
623+
" due to error: %+v", err)
624+
t.Fatal(err)
625+
}
626+
627+
fmt.Println("Deleting the saved goal state for network container of type COW")
628+
err = deleteNetworkAdapterWithName(t, "testCOWContainer")
629+
if err != nil {
630+
t.Errorf("Failed to delete the saved goal state due to error: %+v", err)
631+
t.Fatal(err)
632+
}
633+
619634
}
620635

621636
func TestGetNetworkContainerByOrchestratorContext(t *testing.T) {

0 commit comments

Comments
 (0)