Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ require (
github.com/google/renameio v0.1.0
github.com/imdario/mergo v0.3.12
github.com/opencontainers/go-digest v1.0.0
github.com/openshift/api v0.0.0-20211108165917-be1be0e89115
github.com/openshift/api v0.0.0-20211203182845-d5252bac4715
github.com/openshift/client-go v0.0.0-20210916133943-9acee1a0fb83
github.com/openshift/library-go v0.0.0-20210930103404-8911cacccb05
github.com/openshift/runtime-utils v0.0.0-20210722191527-8b8348d80d1d
Expand Down Expand Up @@ -62,7 +62,7 @@ replace (
github.com/godbus/dbus => github.com/godbus/dbus v0.0.0-20190623212516-8a1682060722
github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.4.1
github.com/opencontainers/runtime-spec => github.com/opencontainers/runtime-spec v0.1.2-0.20190408193819-a1b50f621a48
github.com/openshift/api => github.com/openshift/api v0.0.0-20211108165917-be1be0e89115
github.com/openshift/api => github.com/openshift/api v0.0.0-20211203182845-d5252bac4715
github.com/openshift/cluster-api => github.com/openshift/cluster-api v0.0.0-20191129101638-b09907ac6668
github.com/securego/gosec => github.com/securego/gosec v0.0.0-20190709033609-4b59c948083c
k8s.io/api => k8s.io/api v0.22.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1037,8 +1037,8 @@ github.com/opencontainers/selinux v1.6.0/go.mod h1:VVGKuOLlE7v4PJyT6h7mNWvq1rzqi
github.com/opencontainers/selinux v1.8.0/go.mod h1:RScLhm78qiWa2gbVCcGkC7tCGdgk3ogry1nUQF8Evvo=
github.com/opencontainers/selinux v1.8.2 h1:c4ca10UMgRcvZ6h0K4HtS15UaVSBEaE+iln2LVpAuGc=
github.com/opencontainers/selinux v1.8.2/go.mod h1:MUIHuUEvKB1wtJjQdOyYRgOnLD2xAPP8dBsCoU0KuF8=
github.com/openshift/api v0.0.0-20211108165917-be1be0e89115 h1:U4FFPL8c/DP5dd2qrEbao8Qi12UboAtZNVTQHmXO91I=
github.com/openshift/api v0.0.0-20211108165917-be1be0e89115/go.mod h1:RsQCVJu4qhUawxxDP7pGlwU3IA4F01wYm3qKEu29Su8=
github.com/openshift/api v0.0.0-20211203182845-d5252bac4715 h1:nEL2qXQofFW4H5QlBs4scQ/m7WRxTS/AHijOWhDs0xk=
github.com/openshift/api v0.0.0-20211203182845-d5252bac4715/go.mod h1:RsQCVJu4qhUawxxDP7pGlwU3IA4F01wYm3qKEu29Su8=
github.com/openshift/build-machinery-go v0.0.0-20200211121458-5e3d6e570160/go.mod h1:1CkcsT3aVebzRBzVTSbiKSkJMsC/CASqxesfqEMfJEc=
github.com/openshift/build-machinery-go v0.0.0-20210712174854-1bb7fd1518d3/go.mod h1:b1BuldmJlbA/xYtdZvKi+7j5YGB44qJUJDZ9zwiNCfE=
github.com/openshift/build-machinery-go v0.0.0-20210806203541-4ea9b6da3a37/go.mod h1:b1BuldmJlbA/xYtdZvKi+7j5YGB44qJUJDZ9zwiNCfE=
Expand Down
5 changes: 5 additions & 0 deletions lib/resourcemerge/machineconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,10 @@ func ensureControllerConfigSpec(modified *bool, existing *mcfgv1.ControllerConfi
existing.DNS = required.DNS
}

if !equality.Semantic.DeepEqual(existing.Network, required.Network) {
*modified = true
existing.Network = required.Network
}

mergeMap(modified, &existing.Images, required.Images)
}
46 changes: 46 additions & 0 deletions manifests/controllerconfig.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,52 @@ spec:
proper way. Nobody is also changing this once the cluster is up
and running the first time, so, disallow regeneration if this changes.'
type: string
network:
description: network contains additional network related information
nullable: true
properties:
mtuMigration:
description: mtuMigration contains the MTU migration configuration.
nullable: true
properties:
machine:
description: machine contains MTU migration configuration
for the machine's uplink.
nullable: true
properties:
from:
description: from is the MTU to migrate from.
nullable: true
format: int32
minimum: 0
type: integer
to:
description: to is the MTU to migrate to.
nullable: true
format: int32
minimum: 0
type: integer
type: object
network:
description: network contains information about MTU migration
for the default network.
nullable: true
properties:
from:
description: from is the MTU to migrate from.
nullable: true
format: int32
minimum: 0
type: integer
to:
description: to is the MTU to migrate to.
nullable: true
format: int32
minimum: 0
type: integer
type: object
type: object
type: object
osImageURL:
description: osImageURL is the location of the container image that
contains the OS update payload. Its value is taken from the data.osImageURL
Expand Down
11 changes: 11 additions & 0 deletions pkg/apis/machineconfiguration.openshift.io/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ type ControllerConfigSpec struct {
// Nobody is also changing this once the cluster is up and running the first time, so, disallow
// regeneration if this changes.
NetworkType string `json:"networkType,omitempty"`

// Network contains additional network related information
// +nullable
Network *NetworkInfo `json:"network"`
}

// IPFamiliesType indicates whether the cluster network is IPv4-only, IPv6-only, or dual-stack
Expand All @@ -108,6 +112,13 @@ const (
IPFamiliesDualStack IPFamiliesType = "DualStack"
)

// Network contains network related configuration
type NetworkInfo struct {
// MTUMigration contains the MTU migration configuration.
// +nullable
MTUMigration *configv1.MTUMigration `json:"mtuMigration"`
}

// ControllerConfigStatus is the status for ControllerConfig
type ControllerConfigStatus struct {
// observedGeneration represents the generation observed by the controller.
Expand Down

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

10 changes: 9 additions & 1 deletion pkg/controller/template/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,15 @@ func filterTemplates(toFilter map[string]string, path string, config *RenderConf
if err != nil {
return err
}
toFilter[info.Name()] = string(renderedData)

// A template may result in no data when rendered, for example if the
// whole template is conditioned to specific values in render config.
// The intention is there shouldn't be any resulting file or unit form
// this template and thus we filter it here.
if len(renderedData) > 0 {
toFilter[info.Name()] = string(renderedData)
}

return nil
}

Expand Down
46 changes: 35 additions & 11 deletions pkg/controller/template/render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,16 +288,17 @@ const templateDir = "../../../templates"

var (
configs = map[string]string{
"alibaba": "./test_data/controller_config_alibaba.yaml",
"aws": "./test_data/controller_config_aws.yaml",
"baremetal": "./test_data/controller_config_baremetal.yaml",
"gcp": "./test_data/controller_config_gcp.yaml",
"openstack": "./test_data/controller_config_openstack.yaml",
"libvirt": "./test_data/controller_config_libvirt.yaml",
"none": "./test_data/controller_config_none.yaml",
"vsphere": "./test_data/controller_config_vsphere.yaml",
"kubevirt": "./test_data/controller_config_kubevirt.yaml",
"powervs": "./test_data/controller_config_powervs.yaml",
"alibaba": "./test_data/controller_config_alibaba.yaml",
"aws": "./test_data/controller_config_aws.yaml",
"baremetal": "./test_data/controller_config_baremetal.yaml",
"gcp": "./test_data/controller_config_gcp.yaml",
"openstack": "./test_data/controller_config_openstack.yaml",
"libvirt": "./test_data/controller_config_libvirt.yaml",
"mtu-migration": "./test_data/controller_config_mtu_migration.yaml",
"none": "./test_data/controller_config_none.yaml",
"vsphere": "./test_data/controller_config_vsphere.yaml",
"kubevirt": "./test_data/controller_config_kubevirt.yaml",
"powervs": "./test_data/controller_config_powervs.yaml",
}
)

Expand Down Expand Up @@ -331,7 +332,7 @@ func TestInvalidPlatform(t *testing.T) {
}

func TestGenerateMachineConfigs(t *testing.T) {
for _, config := range configs {
for test, config := range configs {
controllerConfig, err := controllerConfigFromFile(config)
if err != nil {
t.Fatalf("failed to get controllerconfig config: %v", err)
Expand All @@ -346,6 +347,8 @@ func TestGenerateMachineConfigs(t *testing.T) {
foundPullSecretWorker := false
foundKubeletUnitMaster := false
foundKubeletUnitWorker := false
foundMTUMigrationMaster := false
foundMTUMigrationWorker := false

for _, cfg := range cfgs {
if cfg.Labels == nil {
Expand All @@ -368,13 +371,19 @@ func TestGenerateMachineConfigs(t *testing.T) {
if !foundKubeletUnitMaster {
foundKubeletUnitMaster = findIgnUnit(ign.Systemd.Units, "kubelet.service", t)
}
if !foundMTUMigrationMaster {
foundMTUMigrationMaster = findIgnFile(ign.Storage.Files, "/etc/cno/mtu-migration/config", t)
}
} else if role == "worker" {
if !foundPullSecretWorker {
foundPullSecretWorker = findIgnFile(ign.Storage.Files, "/var/lib/kubelet/config.json", t)
}
if !foundKubeletUnitWorker {
foundKubeletUnitWorker = findIgnUnit(ign.Systemd.Units, "kubelet.service", t)
}
if !foundMTUMigrationWorker {
foundMTUMigrationWorker = findIgnFile(ign.Storage.Files, "/etc/cno/mtu-migration/config", t)
}
} else {
t.Fatalf("Unknown role %s", role)
}
Expand All @@ -392,6 +401,21 @@ func TestGenerateMachineConfigs(t *testing.T) {
if !foundKubeletUnitWorker {
t.Errorf("Failed to find kubelet unit for worker")
}
if test == "mtu-migration" {
if !foundMTUMigrationMaster {
t.Errorf("Failed to find mtu-migration files for master")
}
if !foundMTUMigrationWorker {
t.Errorf("Failed to find mtu-migration files for worker")
}
} else {
if foundMTUMigrationMaster {
t.Errorf("Found mtu-migration files for master")
}
if foundMTUMigrationWorker {
t.Errorf("Found mtu-migration files for worker")
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: "machineconfigurations.openshift.io/v1"
kind: "ControllerConfig"
spec:
clusterDNSIP: "10.3.0.10"
cloudProviderConfig: ""
etcdInitialCount: 3
etcdCAData: ZHVtbXkgZXRjZC1jYQo=
rootCAData: ZHVtbXkgcm9vdC1jYQo=
pullSecret:
data: ZHVtbXkgZXRjZC1jYQo=
images:
etcd: image/etcd:1
setupEtcdEnv: image/setupEtcdEnv:1
infraImage: image/infraImage:1
kubeClientAgentImage: image/kubeClientAgentImage:1
infra:
apiVersion: config.openshift.io/v1
kind: Infrastructure
status:
apiServerInternalURI: https://api-int.my-test-cluster.installer.team.coreos.systems:6443
apiServerURL: https://api.my-test-cluster.installer.team.coreos.systems:6443
etcdDiscoveryDomain: my-test-cluster.installer.team.coreos.systems
infrastructureName: my-test-cluster
platformStatus:
type: "None"
network:
mtuMigration:
machine:
from: 1500
to: 9100
network:
from: 1400
to: 9000
7 changes: 7 additions & 0 deletions pkg/operator/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ func createDiscoveredControllerConfigSpec(infra *configv1.Infrastructure, networ
} else if network.Status.Migration != nil {
// At sdn migration prepare phase, use the value in status.migration to prepare the node.
ccSpec.NetworkType = network.Status.Migration.NetworkType

// Set any MTU migration parameters as well
if network.Status.Migration.MTU != nil {
ccSpec.Network = &mcfgv1.NetworkInfo{
MTUMigration: network.Status.Migration.MTU,
}
}
} else {
// After installation, the MCO should not assume the network is changing just because the spec changed, it needs to wait until CNO updates the status.
ccSpec.NetworkType = network.Status.NetworkType
Expand Down
34 changes: 34 additions & 0 deletions templates/common/_base/files/mtu-migration-conf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{{ $target_mtu := 0 -}}
{{ $current_mtu := 0 -}}
{{ $cni_target_mtu := 0 -}}
{{ if .Network }}{{ if .Network.MTUMigration -}}
{{ if .Network.MTUMigration.Machine -}}
{{ if .Network.MTUMigration.Machine.To -}}
{{ $target_mtu = .Network.MTUMigration.Machine.To -}}
{{ end -}}
{{ if .Network.MTUMigration.Machine.From -}}
{{ $current_mtu = .Network.MTUMigration.Machine.From -}}
{{ end -}}
{{ end -}}
{{ if .Network.MTUMigration.Network }}{{ if .Network.MTUMigration.Network.To -}}
{{ $cni_target_mtu = .Network.MTUMigration.Network.To -}}
{{ end }}{{ end -}}
{{ end }}{{ end -}}
{{ if or $target_mtu $cni_target_mtu -}}
mode: 0644
path: "/etc/cno/mtu-migration/config"
contents:
inline: |
NETWORK_TYPE={{ .NetworkType }}
{{ if $target_mtu -}}
TARGET_MTU={{ $target_mtu }}
{{ end -}}
{{ if $current_mtu -}}
CURRENT_MTU={{ $current_mtu }}
{{ end -}}
{{ if $cni_target_mtu -}}
# CNI_TARGET_MTU is a dummy value included to cause a reboot in case host
# MTUs are not changed.
CNI_TARGET_MTU={{ $cni_target_mtu }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe just comment that this is only for a use case where the host MTUs are not modified and just the CNI MTU is modified?

{{ end -}}
{{ end -}}

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

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

Loading