-
Notifications
You must be signed in to change notification settings - Fork 462
OPNET-282: Configure-ovs alternative implementation #4249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0798907
cad8c27
171223f
7a94ef8
16b8327
16d796a
397b18e
addcb11
c02974b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| mode: 0755 | ||
| path: "/usr/local/bin/wait-for-primary-ip.sh" | ||
| contents: | ||
| inline: | | ||
| #!/bin/bash | ||
| set -eux | ||
| if [ ! -e /etc/nmstate/openshift/applied ]; then | ||
| # No need to do this if no NMState configuration was applied | ||
| exit 0 | ||
| fi | ||
|
Comment on lines
+8
to
+11
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The guard is not needed, at the second boot the IP will be already stored at NetworkManager and this script will be super fast.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't for second boot, it's to avoid running this when the new mechanism is not in use at all. |
||
| # This logic is borrowed from configure-ovs.sh | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess this makes the check in configure-ovs dead code?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not in this case. We only run this if the new mechanism is used, so the configure-ovs version will still apply when we don't.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah ok. Why do you need to use
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this couldn't work exactly the same way configure-ovs does because it's not all one service. In this case, we have nmstate-configuration.service providing configuration files for nmstate.service, then run wait-for-primary-ip.service to ensure we have a usable address. The platform-agnostic solution is probably to split this into two services, one that runs before nmstate.service and stores off the primary IP, then this one that runs after to wait for it. I'll see how hard that would be to do now that we have a little more time to get this done. |
||
| # TODO: Find a platform-agnostic way to do this. It won't work on platforms where | ||
| # nodeip-configuration is not used. | ||
| ip=$(cat /run/nodeip-configuration/primary-ip) | ||
| if [[ "${ip}" == "" ]]; then | ||
| echo "No ip to bind was found" | ||
| exit 1 | ||
| fi | ||
| while : | ||
| do | ||
| random_port=$(shuf -i 50000-60000 -n 1) | ||
| echo "Trying to bind ${ip} on port ${random_port}" | ||
| exit_code=$(timeout 2s nc -l "${ip}" ${random_port}; echo $?) | ||
| if [[ exit_code -eq 124 ]]; then | ||
| echo "Address bound successfully" | ||
| exit 0 | ||
| fi | ||
| sleep 10 | ||
| done | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| name: wait-for-primary-ip.service | ||
| enabled: true | ||
| contents: | | ||
| [Unit] | ||
| Description=Ensure primary IP is assigned and usable | ||
| Requires=nmstate.service | ||
| After=nmstate.service | ||
| Before=kubelet-dependencies.target | ||
|
|
||
| [Service] | ||
| Type=oneshot | ||
| Restart=on-failure | ||
| RestartSec=10 | ||
| ExecStart=/usr/local/bin/wait-for-primary-ip.sh | ||
| StandardOutput=journal+console | ||
| StandardError=journal+console | ||
|
|
||
| {{if .Proxy -}} | ||
| EnvironmentFile=/etc/mco/proxy.env | ||
| {{end -}} | ||
|
|
||
| [Install] | ||
| WantedBy=network-online.target |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| mode: 0755 | ||
| path: "/usr/local/bin/nmstate-configuration.sh" | ||
| contents: | ||
| inline: | | ||
| #!/bin/bash | ||
| set -eux | ||
|
|
||
| # Clean up old config on behalf of mtu-migration | ||
| if ! systemctl -q is-enabled mtu-migration; then | ||
| echo "Cleaning up left over mtu migration configuration" | ||
| rm -rf /etc/cno/mtu-migration | ||
| fi | ||
|
|
||
| if [ -e /etc/nmstate/openshift/applied ]; then | ||
| echo "Configuration already applied, exiting" | ||
| exit 0 | ||
| fi | ||
|
|
||
| src_path="/etc/nmstate/openshift" | ||
| dst_path="/etc/nmstate" | ||
| hostname=$(hostname -s) | ||
| host_file="${hostname}.yml" | ||
| cluster_file="cluster.yml" | ||
| config_file="" | ||
| if [ -s "$src_path/$host_file" ]; then | ||
| config_file=$hostname_file | ||
| elif [ -s "$src_path/$cluster_file" ]; then | ||
| config_file=$cluster_file | ||
| else | ||
| echo "No configuration found at $src_path/$host_file or $src_path/$cluster_file" | ||
| exit 0 | ||
| fi | ||
|
|
||
| if [ -e "$dst_path/$config_file" ]; then | ||
| echo "ERROR: File $dst_path/$config_file exists. Refusing to overwrite." | ||
| exit 1 | ||
| fi | ||
|
|
||
| cp "$src_path/$config_file" /etc/nmstate | ||
| touch /etc/nmstate/openshift/applied |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| name: nmstate-configuration.service | ||
| enabled: true | ||
| contents: | | ||
| [Unit] | ||
| Description=Applies per-node NMState network configuration | ||
| Requires=openvswitch.service | ||
| Wants=NetworkManager-wait-online.service | ||
| After=NetworkManager-wait-online.service openvswitch.service network.service nodeip-configuration.service | ||
| Before=nmstate.service kubelet-dependencies.target ovs-configuration.service node-valid-hostname.service | ||
|
|
||
| [Service] | ||
| Type=oneshot | ||
| # Would prefer to do Restart=on-failure instead of this bash retry loop, but | ||
| # the version of systemd we have right now doesn't support it. It should be | ||
| # available in systemd v244 and higher. | ||
| ExecStart=/usr/local/bin/nmstate-configuration.sh | ||
| StandardOutput=journal+console | ||
| StandardError=journal+console | ||
|
|
||
| {{if .Proxy -}} | ||
| EnvironmentFile=/etc/mco/proxy.env | ||
| {{end -}} | ||
|
|
||
| [Install] | ||
| WantedBy=network-online.target |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just as a note we're trying to move from a hard-coded list to an API here: openshift/api#1764
So directories isn't part of our initially supported plans but we should eventually add support for this cc @djoshy