Skip to content

Commit

Permalink
refactor: make the topo spec saner for connectivity things
Browse files Browse the repository at this point in the history
  • Loading branch information
carlmontanari committed Jan 17, 2024
1 parent 52fb117 commit 1c83a1a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 24 deletions.
11 changes: 7 additions & 4 deletions apis/v1alpha1/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ type TopologySpec struct {
// images.
// +optional
ImagePull ImagePull `json:"imagePull"`
// EnableSlurpeeth enables experimental slurpeeth for connectivity between nodes on different
// launchers.
// +optional
EnableSlurpeeth bool `json:"enableSlurpeeth"`
// Connectivity defines the type of connectivity to use between nodes in the topology. The
// default behavior is to use vxlan tunnels, alternatively you can enable a more experimental
// "slurpeeth" connectivity flavor that stuffs traffic into tcp tunnels to avoid any vxlan mtu
// and/or fragmentation challenges.
// +kubebuilder:validation:Enum=vxlan;slurpeeth
// +kubebuilder:default=vxlan
Connectivity string `json:"connectivity"`
}

// TopologyStatus is the status for a Topology resource.
Expand Down
16 changes: 12 additions & 4 deletions assets/crd/clabernetes.containerlab.dev_topologies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ spec:
spec:
description: TopologySpec is the spec for a Topology resource.
properties:
connectivity:
default: vxlan
description: |-
Connectivity defines the type of connectivity to use between nodes in the topology. The
default behavior is to use vxlan tunnels, alternatively you can enable a more experimental
"slurpeeth" connectivity flavor that stuffs traffic into tcp tunnels to avoid any vxlan mtu
and/or fragmentation challenges.
enum:
- vxlan
- slurpeeth
type: string
definition:
description: |-
Definition defines the actual set of nodes (network ones, not k8s ones!) that this Topology
Expand Down Expand Up @@ -310,10 +321,6 @@ spec:
type: array
type: object
type: object
enableSlurpeeth:
description: EnableSlurpeeth enables experimental slurpeeth for connectivity
between nodes on different launchers.
type: boolean
expose:
description: Expose holds configurations relevant to how clabernetes
exposes a topology.
Expand Down Expand Up @@ -407,6 +414,7 @@ spec:
type: string
type: object
required:
- connectivity
- definition
type: object
status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ spec:
spec:
description: TopologySpec is the spec for a Topology resource.
properties:
connectivity:
default: vxlan
description: |-
Connectivity defines the type of connectivity to use between nodes in the topology. The
default behavior is to use vxlan tunnels, alternatively you can enable a more experimental
"slurpeeth" connectivity flavor that stuffs traffic into tcp tunnels to avoid any vxlan mtu
and/or fragmentation challenges.
enum:
- vxlan
- slurpeeth
type: string
definition:
description: |-
Definition defines the actual set of nodes (network ones, not k8s ones!) that this Topology
Expand Down Expand Up @@ -310,10 +321,6 @@ spec:
type: array
type: object
type: object
enableSlurpeeth:
description: EnableSlurpeeth enables experimental slurpeeth for connectivity
between nodes on different launchers.
type: boolean
expose:
description: Expose holds configurations relevant to how clabernetes
exposes a topology.
Expand Down Expand Up @@ -407,6 +414,7 @@ spec:
type: string
type: object
required:
- connectivity
- definition
type: object
status:
Expand Down
9 changes: 2 additions & 7 deletions controllers/topology/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,11 +451,6 @@ func (r *DeploymentReconciler) renderDeploymentContainerEnv(
}
}

connectivityKind := clabernetesconstants.ConnectivityVXLAN
if owningTopology.Spec.EnableSlurpeeth {
connectivityKind = clabernetesconstants.ConnectivitySlurpeeth
}

envs := []k8scorev1.EnvVar{
{
Name: clabernetesconstants.NodeNameEnv,
Expand Down Expand Up @@ -518,7 +513,7 @@ func (r *DeploymentReconciler) renderDeploymentContainerEnv(
},
{
Name: clabernetesconstants.LauncherConnectivityKind,
Value: connectivityKind,
Value: owningTopology.Spec.Connectivity,
},
}

Expand Down Expand Up @@ -989,7 +984,7 @@ func (r *DeploymentReconciler) DetermineNodesNeedingRestart(
continue
}

if owningTopology.Spec.EnableSlurpeeth {
if owningTopology.Spec.Connectivity == clabernetesconstants.ConnectivitySlurpeeth {
determineNodeNeedsRestartSlurpeeth(reconcileData, nodeName)
} else if !reflect.DeepEqual(nodeConfig, reconcileData.PreviousConfigs[nodeName]) {
reconcileData.NodesNeedingReboot.Add(nodeName)
Expand Down
10 changes: 5 additions & 5 deletions generated/openapi/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1c83a1a

Please sign in to comment.