Skip to content

Conversation

@ricky-rav
Copy link
Contributor

During systemd daemon-reload (e.g., during MCO updates), the openshift-azure-routes.path unit may miss file change events from apiserver-watcher. This leaves the azure-vips nftables table empty even when the API server is back up.

Fix by adding a periodic timer that triggers reconciliation every 30 seconds as a fallback. The path unit still provides immediate response to file changes. Also wrap the service ExecStart with flock to prevent concurrent executions when both triggers fire simultaneously.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Nov 28, 2025
@openshift-ci-robot
Copy link
Contributor

@ricky-rav: This pull request references Jira Issue OCPBUGS-61487, which is invalid:

  • expected the bug to target the "4.21.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

During systemd daemon-reload (e.g., during MCO updates), the openshift-azure-routes.path unit may miss file change events from apiserver-watcher. This leaves the azure-vips nftables table empty even when the API server is back up.

Fix by adding a periodic timer that triggers reconciliation every 30 seconds as a fallback. The path unit still provides immediate response to file changes. Also wrap the service ExecStart with flock to prevent concurrent executions when both triggers fire simultaneously.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. label Nov 28, 2025
@openshift-ci openshift-ci bot requested a review from djoshy November 28, 2025 18:12
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 28, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ricky-rav
Once this PR has been reviewed and has the lgtm label, please assign djoshy for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ricky-rav
Copy link
Contributor Author

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Nov 28, 2025
@openshift-ci-robot
Copy link
Contributor

@ricky-rav: This pull request references Jira Issue OCPBUGS-61487, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.21.0) matches configured target version for branch (4.21.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@ricky-rav
Copy link
Contributor Author

/retest

1 similar comment
@ricky-rav
Copy link
Contributor Author

/retest

@ricky-rav
Copy link
Contributor Author

/retest
/test pull-ci-openshift-machine-config-operator-main-e2e-azure-ovn-upgrade

@ricky-rav
Copy link
Contributor Author

/test e2e-azure-ovn-upgrade

@ricky-rav
Copy link
Contributor Author

/hold
This generates logs in the journal every 30 seconds. I'll see how to limit the logging.

During systemd daemon-reload (e.g., during MCO updates), the
openshift-azure-routes.path unit may miss file change events from
apiserver-watcher. This leaves the azure-vips nftables table empty
even when the API server is back up.

Fix by adding a periodic timer that triggers reconciliation every 30
seconds as a fallback. The path unit still provides immediate response
to file changes. Also wrap the service ExecStart with flock to prevent
concurrent executions when both triggers fire simultaneously.

Reduce logging so that we do not log when there are not routes to add.
This prevents the journal from getting clogged, since the service is now
triggered every 30 seconds.

Signed-off-by: Riccardo Ravaioli <[email protected]>
@ricky-rav
Copy link
Contributor Author

/test e2e-azure-ovn-upgrade

@ricky-rav
Copy link
Contributor Author

ricky-rav commented Dec 5, 2025

This generates logs in the journal every 30 seconds. I'll see how to limit the logging.

I reduced the logs to a bare minimum, but systemd still logs to the journal every time the service is triggered:

sh-5.1# journalctl -u openshift-azure-routes
Dec 05 07:09:05 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: Started Work around Azure load balancer hairpin.
Dec 05 07:09:05 ci-ln-q64r0qb-1d09d-srt7k-master-0 openshift-azure-routes[2668]: time="2025-12-05T07:09:05Z" level=fatal msg="validate service connection: validate CRI v1 runtime API for endpoint \"unix:///var/run/crio/crio.sock\": rpc error: code = Unavailable desc = con>
Dec 05 07:09:05 ci-ln-q64r0qb-1d09d-srt7k-master-0 openshift-azure-routes[2681]: time="2025-12-05T07:09:05Z" level=fatal msg="validate service connection: validate CRI v1 runtime API for endpoint \"unix:///var/run/crio/crio.sock\": rpc error: code = Unavailable desc = con>
Dec 05 07:09:05 ci-ln-q64r0qb-1d09d-srt7k-master-0 openshift-azure-routes[2660]: OVN-Kubernetes is not running; no routes to add.
Dec 05 07:09:05 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: openshift-azure-routes.service: Deactivated successfully.
Dec 05 07:09:12 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: Started Work around Azure load balancer hairpin.
Dec 05 07:09:12 ci-ln-q64r0qb-1d09d-srt7k-master-0 openshift-azure-routes[2879]: OVN-Kubernetes is not running; no routes to add.
Dec 05 07:09:12 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: openshift-azure-routes.service: Deactivated successfully.
Dec 05 07:09:26 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: Started Work around Azure load balancer hairpin.
Dec 05 07:09:26 ci-ln-q64r0qb-1d09d-srt7k-master-0 openshift-azure-routes[2991]: OVN-Kubernetes is not running; no routes to add.
Dec 05 07:09:26 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: openshift-azure-routes.service: Deactivated successfully.
Dec 05 07:09:59 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: Started Work around Azure load balancer hairpin.
Dec 05 07:10:00 ci-ln-q64r0qb-1d09d-srt7k-master-0 openshift-azure-routes[3137]: OVN-Kubernetes is not running; no routes to add.
Dec 05 07:10:00 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: openshift-azure-routes.service: Deactivated successfully.
Dec 05 07:10:30 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: Started Work around Azure load balancer hairpin.
Dec 05 07:10:30 ci-ln-q64r0qb-1d09d-srt7k-master-0 openshift-azure-routes[3218]: OVN-Kubernetes is not running; no routes to add.
Dec 05 07:10:30 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: openshift-azure-routes.service: Deactivated successfully.
Dec 05 07:11:00 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: Started Work around Azure load balancer hairpin.
Dec 05 07:11:00 ci-ln-q64r0qb-1d09d-srt7k-master-0 openshift-azure-routes[3355]: OVN-Kubernetes is not running; no routes to add.
Dec 05 07:11:00 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: openshift-azure-routes.service: Deactivated successfully.
Dec 05 07:11:32 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: Started Work around Azure load balancer hairpin.
Dec 05 07:11:32 ci-ln-q64r0qb-1d09d-srt7k-master-0 openshift-azure-routes[3954]: OVN-Kubernetes is not running; no routes to add.
[...]
Dec 05 07:16:59 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: Started Work around Azure load balancer hairpin.
Dec 05 07:17:00 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: openshift-azure-routes.service: Deactivated successfully.
Dec 05 07:17:37 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: Started Work around Azure load balancer hairpin.
Dec 05 07:17:37 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: openshift-azure-routes.service: Deactivated successfully.
Dec 05 07:18:04 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: Started Work around Azure load balancer hairpin.
Dec 05 07:18:05 ci-ln-q64r0qb-1d09d-srt7k-master-0 openshift-azure-routes[11988]: adding route: ovn-nbctl lr-policy-add ovn_cluster_router 1010 inport == rtos-ci-ln-q64r0qb-1d09d-srt7k-master-0 && ip4.dst == 10.0.0.100 reroute 10.130.0.2
Dec 05 07:18:05 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: openshift-azure-routes.service: Deactivated successfully.
Dec 05 07:18:48 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: Started Work around Azure load balancer hairpin.
Dec 05 07:18:48 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: openshift-azure-routes.service: Deactivated successfully.
[...]
Dec 05 07:31:38 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: Started Work around Azure load balancer hairpin.
Dec 05 07:31:38 ci-ln-q64r0qb-1d09d-srt7k-master-0 openshift-azure-routes[25688]: removing stale route: ovn-nbctl lr-policy-del ovn_cluster_router 1010 inport == rtos-ci-ln-q64r0qb-1d09d-srt7k-master-0 && ip4.dst == 10.0.0.100
Dec 05 07:31:39 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: openshift-azure-routes.service: Deactivated successfully.
Dec 05 07:32:18 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: Started Work around Azure load balancer hairpin.
Dec 05 07:32:18 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: openshift-azure-routes.service: Deactivated successfully.
Dec 05 07:32:48 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: Started Work around Azure load balancer hairpin.
Dec 05 07:32:49 ci-ln-q64r0qb-1d09d-srt7k-master-0 openshift-azure-routes[26512]: adding route: ovn-nbctl lr-policy-add ovn_cluster_router 1010 inport == rtos-ci-ln-q64r0qb-1d09d-srt7k-master-0 && ip4.dst == 10.0.0.100 reroute 10.130.0.2
Dec 05 07:32:49 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: openshift-azure-routes.service: Deactivated successfully.
Dec 05 07:33:59 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: Started Work around Azure load balancer hairpin.
Dec 05 07:34:00 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: openshift-azure-routes.service: Deactivated successfully.
Dec 05 07:34:37 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: Started Work around Azure load balancer hairpin.
Dec 05 07:34:37 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: openshift-azure-routes.service: Deactivated successfully.
Dec 05 07:35:08 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: Started Work around Azure load balancer hairpin.
Dec 05 07:35:08 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: openshift-azure-routes.service: Deactivated successfully.
Dec 05 07:35:40 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: Started Work around Azure load balancer hairpin.
Dec 05 07:35:40 ci-ln-q64r0qb-1d09d-srt7k-master-0 systemd[1]: openshift-azure-routes.service: Deactivated successfully.

I'm still wondering what a better solution might be...

Without this setting, journal entries appear under "bash" instead of
the service name, making it harder to filter logs with journalctl -u.

Before:
  Oct 31 22:33:06 master-0 bash[983]: Processing route for NIC 0/... for 10.0.0.2

After:
  Oct 31 22:33:06 master-0 openshift-gcp-routes[983]: Processing route for NIC 0/... for 10.0.0.2

Signed-off-by: Riccardo Ravaioli <[email protected]>
@ricky-rav
Copy link
Contributor Author

in the end we log a lot also on GCP, where inotifywait is not supported yet by RHEL 9 and we re-evaluate everything every 5 seconds:
https://github.com/openshift/machine-config-operator/blob/main/templates/master/00-master/gcp/files/opt-libexec-openshift-gcp-routes-sh.yaml#L195-L205

@ricky-rav
Copy link
Contributor Author

/assign @tssurya

Copy link
Contributor

@tssurya tssurya left a comment

Choose a reason for hiding this comment

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

During systemd daemon-reload the openshift-azure-routes.path unit may miss file change events from apiserver-watcher

hmm why does it miss it? cause process is not yet correctly up ? so a timing issue during reload? In that case wouldn't a better fix be if a reload or restart has happened then we trigger a sync 30seconds after reload and/or on startup? I wonder if there is an option for ordering the firing that way instead of doing it every 30seconds..I worry we are going to do unwanted work too frequently?

if [ -z "${ovnkContainerID}" ]; then
return
fi
echo "Found ovnkube-controller pod... ${ovnkContainerID}"
Copy link
Contributor

@tssurya tssurya Dec 10, 2025

Choose a reason for hiding this comment

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

reason I had added sooo many echo statements was because script was soo raw and we were directly touching the DBs that I was super worried what command we are transaction for history purposes....plus I wasn't a bash expert really :) so wanted to be extra careful with each step I was doing LOL

But I think its been some years now, which hopefully means this is stable, so I'm ok to remove these statements and have less logs. - but also OK with what you did, which is consolidate them into a single line.

systemd logging it every 30 seconds is going to be annoying a bit

Description=Periodic reconciliation of Azure VIP routes
[Timer]
OnBootSec=30
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm does it mean it will run 30sec after bootup as a one time thing? or this is every 30seconds like you said in PR description.. cause isn't it too much if we act on the filechange and run this every 30seconds?
and what does onunitactivesec mean? 30seconds after the unit gets active?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So it gets triggered the first time 30 seconds after boot (OnBootSec=30) and then 30 seconds after the service last finished (OnUnitActiveSec=30), repeatedly.

ExecStart=/bin/bash /opt/libexec/openshift-gcp-routes.sh start
ExecStopPost=/bin/bash /opt/libexec/openshift-gcp-routes.sh cleanup
User=root
SyslogIdentifier=openshift-gcp-routes
Copy link
Contributor

Choose a reason for hiding this comment

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

nice, didn't know about this setting.

@ricky-rav
Copy link
Contributor Author

During systemd daemon-reload the openshift-azure-routes.path unit may miss file change events from apiserver-watcher

hmm why does it miss it? cause process is not yet correctly up ? so a timing issue during reload?

Yes, if the .up/.down file gets created while a systemd daemon-reload happens, the file change is missed and we never converge again until another file change happens.

More precisely, apiserver-watcher (https://github.com/openshift/machine-config-operator/blob/main/templates/master/00-master/azure/files/etc-kubernetes-manifests-apiserver-watcher.yaml) is a static pod that runs independently of systemd, and writes .up/.down files to /run/cloud-routes/. The systemd path unit watches this directory to trigger route updates. When there's a systemd daemon-reload, the path unit's inotify watch is temporarily disrupted and if apiserver-watcher happens to write a file during this brief time window, the path unit misses the event and openshift-azure-routes.service is never triggered, leaving nftables rules and OVN routes stale.

In that case wouldn't a better fix be if a reload or restart has happened then we trigger a sync 30seconds after reload and/or on startup?

That was my initial idea too, but I couldn't find a trigger in systemd (man systemd.timer ) that would be activated n seconds after daemon-reload :-/
I tried convincing claude code from different angles that I needed such option, it confirmed to me that it doesn't exist :-(

I wonder if there is an option for ordering the firing that way instead of doing it every 30seconds..I worry we are going to do unwanted work too frequently?

I'm not very happy about it either, I'm just comforted by the fact that we're doing the same thing with gcp and we do it every 5 seconds...

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 10, 2025

@ricky-rav: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/bootstrap-unit e4fdefc link false /test bootstrap-unit
ci/prow/e2e-gcp-op-2of2 e4fdefc link true /test e2e-gcp-op-2of2
ci/prow/e2e-gcp-op-single-node e4fdefc link true /test e2e-gcp-op-single-node

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants