Skip to content

Commit bb91e6e

Browse files
committed
modified after review
1 parent 7686d5f commit bb91e6e

File tree

10 files changed

+348
-22
lines changed

10 files changed

+348
-22
lines changed

deploy/deploy.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,6 @@ func init() {
11411141
}
11421142

11431143
type CdnosSpec struct {
1144-
ManifestDir string `yaml:"manifests"`
11451144
Operator string `yaml:"operator" kne:"yaml"`
11461145
OperatorData []byte
11471146
kClient kubernetes.Interface
@@ -1166,10 +1165,6 @@ func (c *CdnosSpec) Deploy(ctx context.Context) error {
11661165
}
11671166
c.Operator = f.Name()
11681167
}
1169-
if c.Operator == "" && c.ManifestDir != "" {
1170-
log.Errorf("Deploying Cdnos controller using the directory 'manifests' field (%v) is deprecated, instead provide the filepath of the operator file directly using the 'operator' field going forward", c.ManifestDir)
1171-
c.Operator = filepath.Join(c.ManifestDir, "manifest.yaml")
1172-
}
11731168
log.Infof("Deploying Cdnos controller from: %s", c.Operator)
11741169
if err := run.LogCommand("kubectl", "apply", "-f", c.Operator); err != nil {
11751170
return fmt.Errorf("failed to deploy cdnos operator: %w", err)

deploy/deploy_test.go

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,6 +1843,173 @@ func TestLemmingSpec(t *testing.T) {
18431843
}
18441844
}
18451845

1846+
func TestCdnosSpec(t *testing.T) {
1847+
canceledCtx, cancel := context.WithCancel(context.Background())
1848+
cancel()
1849+
deploymentName := "foo"
1850+
deploymentNS := "cdnos-operator"
1851+
var replicas int32 = 2
1852+
d := &appsv1.Deployment{
1853+
ObjectMeta: metav1.ObjectMeta{
1854+
Name: deploymentName,
1855+
Namespace: deploymentNS,
1856+
},
1857+
}
1858+
tests := []struct {
1859+
desc string
1860+
cdnos *CdnosSpec
1861+
resp []fexec.Response
1862+
dErr string
1863+
hErr string
1864+
ctx context.Context
1865+
mockKClient func(*fake.Clientset)
1866+
}{{
1867+
desc: "1 replica",
1868+
cdnos: &CdnosSpec{},
1869+
resp: []fexec.Response{
1870+
{Cmd: "kubectl", Args: []string{"apply", "-f", ""}},
1871+
},
1872+
1873+
mockKClient: func(k *fake.Clientset) {
1874+
reaction := func(action ktest.Action) (handled bool, ret watch.Interface, err error) {
1875+
f := newFakeWatch([]watch.Event{{
1876+
Type: watch.Added,
1877+
Object: &appsv1.Deployment{
1878+
ObjectMeta: metav1.ObjectMeta{
1879+
Name: deploymentName,
1880+
Namespace: deploymentNS,
1881+
},
1882+
Status: appsv1.DeploymentStatus{
1883+
AvailableReplicas: 0,
1884+
ReadyReplicas: 0,
1885+
Replicas: 0,
1886+
UnavailableReplicas: 1,
1887+
UpdatedReplicas: 0,
1888+
},
1889+
},
1890+
}, {
1891+
Type: watch.Modified,
1892+
Object: &appsv1.Deployment{
1893+
ObjectMeta: metav1.ObjectMeta{
1894+
Name: deploymentName,
1895+
Namespace: deploymentNS,
1896+
},
1897+
Status: appsv1.DeploymentStatus{
1898+
AvailableReplicas: 1,
1899+
ReadyReplicas: 1,
1900+
Replicas: 1,
1901+
UnavailableReplicas: 0,
1902+
UpdatedReplicas: 1,
1903+
},
1904+
},
1905+
}})
1906+
return true, f, nil
1907+
}
1908+
k.PrependWatchReactor("deployments", reaction)
1909+
},
1910+
}, {
1911+
desc: "2 replicas - data over file",
1912+
cdnos: &CdnosSpec{
1913+
OperatorData: []byte("some fake data"),
1914+
},
1915+
resp: []fexec.Response{
1916+
{Cmd: "kubectl", Args: []string{"apply", "-f", ".*.yaml"}},
1917+
},
1918+
mockKClient: func(k *fake.Clientset) {
1919+
reaction := func(action ktest.Action) (handled bool, ret watch.Interface, err error) {
1920+
f := newFakeWatch([]watch.Event{{
1921+
Type: watch.Added,
1922+
Object: &appsv1.Deployment{
1923+
ObjectMeta: metav1.ObjectMeta{
1924+
Name: deploymentName,
1925+
Namespace: deploymentNS,
1926+
},
1927+
Spec: appsv1.DeploymentSpec{
1928+
Replicas: &replicas,
1929+
},
1930+
Status: appsv1.DeploymentStatus{
1931+
AvailableReplicas: 0,
1932+
ReadyReplicas: 0,
1933+
Replicas: 0,
1934+
UnavailableReplicas: replicas,
1935+
UpdatedReplicas: 0,
1936+
},
1937+
},
1938+
}, {
1939+
Type: watch.Modified,
1940+
Object: &appsv1.Deployment{
1941+
ObjectMeta: metav1.ObjectMeta{
1942+
Name: deploymentName,
1943+
Namespace: deploymentNS,
1944+
},
1945+
Spec: appsv1.DeploymentSpec{
1946+
Replicas: &replicas,
1947+
},
1948+
Status: appsv1.DeploymentStatus{
1949+
AvailableReplicas: replicas,
1950+
ReadyReplicas: replicas,
1951+
Replicas: replicas,
1952+
UnavailableReplicas: 0,
1953+
UpdatedReplicas: replicas,
1954+
},
1955+
},
1956+
}})
1957+
return true, f, nil
1958+
}
1959+
k.PrependWatchReactor("deployments", reaction)
1960+
},
1961+
}, {
1962+
desc: "operator deploy error",
1963+
cdnos: &CdnosSpec{},
1964+
resp: []fexec.Response{
1965+
{Cmd: "kubectl", Args: []string{"apply", "-f", ""}, Err: "failed to apply operator"},
1966+
},
1967+
1968+
dErr: "failed to apply operator",
1969+
}, {
1970+
desc: "context canceled",
1971+
cdnos: &CdnosSpec{},
1972+
resp: []fexec.Response{
1973+
{Cmd: "kubectl", Args: []string{"apply", "-f", ""}},
1974+
},
1975+
1976+
ctx: canceledCtx,
1977+
hErr: "context canceled",
1978+
}}
1979+
for _, tt := range tests {
1980+
t.Run(tt.desc, func(t *testing.T) {
1981+
if verbose {
1982+
fexec.LogCommand = func(s string) {
1983+
t.Logf("%s: %s", tt.desc, s)
1984+
}
1985+
}
1986+
cmds := fexec.Commands(tt.resp)
1987+
kexec.Command = cmds.Command
1988+
defer checkCmds(t, cmds)
1989+
1990+
ki := fake.NewSimpleClientset(d)
1991+
if tt.mockKClient != nil {
1992+
tt.mockKClient(ki)
1993+
}
1994+
tt.cdnos.SetKClient(ki)
1995+
err := tt.cdnos.Deploy(context.Background())
1996+
if s := errdiff.Substring(err, tt.dErr); s != "" {
1997+
t.Fatalf("unexpected error: %s", s)
1998+
}
1999+
if err != nil {
2000+
return
2001+
}
2002+
if tt.ctx == nil {
2003+
tt.ctx = context.Background()
2004+
}
2005+
err = tt.cdnos.Healthy(tt.ctx)
2006+
if s := errdiff.Substring(err, tt.hErr); s != "" {
2007+
t.Fatalf("unexpected error: %s", s)
2008+
}
2009+
})
2010+
}
2011+
}
2012+
18462013
func checkCmds(t *testing.T, cmds *fexec.Command) {
18472014
t.Helper()
18482015
if err := cmds.Done(); err != nil {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# external-multinode.yaml cluster config file sets up ingress, cni, and controllers in an existing k8 cluster.
2+
# This spec instructs Metallb to use a docker network named multinode.
3+
# The "external" cluster lifecycle is not managed by the KNE deployment.
4+
cluster:
5+
kind: External
6+
spec:
7+
network: multinode
8+
ingress:
9+
kind: MetalLB
10+
spec:
11+
manifest: ../../manifests/metallb/manifest.yaml
12+
ip_count: 200
13+
cni:
14+
kind: Meshnet
15+
spec:
16+
manifest: ../../manifests/meshnet/grpc/manifest.yaml
17+
controllers:
18+
- kind: IxiaTG
19+
spec:
20+
operator: ../../manifests/keysight/ixiatg-operator.yaml
21+
configMap: ../../manifests/keysight/ixiatg-configmap.yaml
22+
- kind: SRLinux
23+
spec:
24+
operator: ../../manifests/controllers/srlinux/manifest.yaml
25+
- kind: CEOSLab
26+
spec:
27+
operator: ../../manifests/controllers/ceoslab/manifest.yaml
28+
- kind: Lemming
29+
spec:
30+
operator: ../../manifests/controllers/lemming/manifest.yaml
31+
- kind: Cdnos
32+
spec:
33+
operator: ../../manifests/controllers/cdnos/manifest.yaml

deploy/kne/external-multinode.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,3 @@ controllers:
2828
- kind: Lemming
2929
spec:
3030
operator: ../../manifests/controllers/lemming/manifest.yaml
31-
- kind: Cdnos
32-
spec:
33-
operator: ../../manifests/controllers/cdnos/manifest.yaml

deploy/kne/kind-bridge-cdnos.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# kind-bridge.yaml cluster config file sets up a kind cluster where default PTP CNI plugin
2+
# is swapped with the Bridge CNI plugin.
3+
# Bridge CNI plugin is required by some Network OSes to operate.
4+
cluster:
5+
kind: Kind
6+
spec:
7+
name: kne
8+
recycle: True
9+
version: v0.17.0
10+
image: kindest/node:v1.26.0
11+
config: ../../manifests/kind/config.yaml
12+
additionalManifests:
13+
- ../../manifests/kind/bridge.yaml
14+
ingress:
15+
kind: MetalLB
16+
spec:
17+
manifest: ../../manifests/metallb/manifest.yaml
18+
ip_count: 100
19+
cni:
20+
kind: Meshnet
21+
spec:
22+
manifest: ../../manifests/meshnet/grpc/manifest.yaml
23+
controllers:
24+
- kind: IxiaTG
25+
spec:
26+
operator: ../../manifests/keysight/ixiatg-operator.yaml
27+
configMap: ../../manifests/keysight/ixiatg-configmap.yaml
28+
- kind: SRLinux
29+
spec:
30+
operator: ../../manifests/controllers/srlinux/manifest.yaml
31+
- kind: CEOSLab
32+
spec:
33+
operator: ../../manifests/controllers/ceoslab/manifest.yaml
34+
- kind: Lemming
35+
spec:
36+
operator: ../../manifests/controllers/lemming/manifest.yaml
37+
- kind: Cdnos
38+
spec:
39+
operator: ../../manifests/controllers/cdnos/manifest.yaml

deploy/kne/kind-bridge.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,3 @@ controllers:
3434
- kind: Lemming
3535
spec:
3636
operator: ../../manifests/controllers/lemming/manifest.yaml
37-
- kind: Cdnos
38-
spec:
39-
operator: ../../manifests/controllers/cdnos/manifest.yaml

docs/create_topology.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,9 @@ Field | Type | Description
117117

118118
Field | Type | Description
119119
------ | --------- | ----------------------------------------------------
120-
`kind` | string | Name of the controller type. The current options currently are `Cdnos`, `IxiaTG`, `SRLinux`, `CEOSLab`, and `Lemming`.
120+
`kind` | string | Name of the controller type. The current options currently are `IxiaTG`, `SRLinux`, `CEOSLab`, and `Lemming`.
121121
`spec` | yaml.Node | Fields that set the options for the controller type.
122122

123-
##### Cdnos
124-
125-
Field | Type | Description
126-
--------------- | ---------- | -----------
127-
`operator` | string | Path of the yaml file to create a Cdnos operator in the cluster. The validated operator for use with KNE can be found [here](https://github.com/openconfig/kne/tree/main/manifests/controllers/cdnos/manifest.yaml).
128-
~~`manifests`~~ | ~~string~~ | ~~Path of the directory holding the manifests to create a CEOSLab operator in the cluster. The directory is expected to contain a file with the name `manifest.yaml`.~~
129-
130123
##### IxiaTG
131124

132125
Field | Type | Description

examples/drivenets/srlinux.cfg

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)