Skip to content

Conversation

@dsneddon
Copy link
Member

This spec would create several new CLI flags: current-config,
rollback, no-abort, and add functionality to detect ip duplicates
when using --noop.
--current-config
Be able to remove interfaces without using the
overly disruptive --cleanup option, and pass os-net the existing
configuration file as well as the new one so that a delta may be
calculated and applied accordingly.
--rollback
In the event of failure to apply the network, revert back to the
previous configuration.
--no-abort
Continue to try and apply the rest of the configuration, even if one
interface fails, and exit with a special return code in this case.
--noop
Change behavior so that when using --noop os-net-config would
attempt to detect if any of the IP addresses are already in use on
hosts other than the current host. This would allow a trial run to
predict whether any IP conflicts would occur during a production
run.

Dan Sneddon added 3 commits April 16, 2025 20:41
This change would create several new CLI flags: current-config,
rollback, no-abort, and add functionality to detect ip duplicates
when using --noop.
--current-config
Be able to remove interfaces without using the
overly disruptive --cleanup option, and pass os-net the existing
configuration file as well as the new one so that a delta may be
calculated and applied accordingly.
--rollback
In the event of failure to apply the network, revert back to the
previous configuration.
--no-abort
Continue to try and apply the rest of the configuration, even if one
interface fails, and exit with a special return code in this case.
--noop
Change behavior so that when using --noop os-net-config would
attempt to detect if any of the IP addresses are already in use on
hosts other than the current host. This would allow a trial run to
predict whether any IP conflicts would occur during a production
run.
This spec proposes several new CLI flags which will improve the
workflow to allow for rollbacks, better error handling and more
graceful response to errors encountered during configuration, and
proactive duplicate error detection during a dry run using --noop.
new os-net-config cli flags [RHOSRFE-61]
of the --cleanup flag to limit cleanup to only removing interface configurations which were
present in the --current-config configuration provided but are not present in the new config
template which is being applied.
2. Add the --rollback flag which would either support rolling back to the original configuration
Copy link
Member

Choose a reason for hiding this comment

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

Instead of a complete rollback, can we consider configuring the minimal networks needed to enable ssh and other bare minimum tasks ?

template which is being applied.
2. Add the --rollback flag which would either support rolling back to the original configuration
or to the --current-config template which is specified on the command-line.
3. Add the --no-abort flag which would modify the workflow to not abort when a single interface
Copy link
Member

Choose a reason for hiding this comment

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

This is the current design as well. The errors in applying the configurations does not break the flow usually.

@yiytan
Copy link

yiytan commented Jun 12, 2025

May I suggest a different design option for removing interfaces in nmstate?

  1. let os-net-config save nmstate current config file in '/var/lib/os-net-config/nmstate_files/config.yaml' once configuration is successful
  2. keep using --cleanup flag instead of introducing a new --current-config flag: Currently in ifcfg, --cleanup is used to remove unconfigured interfaces that was configured by os-net-config, if we use the same --cleanup flag, we achieve parity with ifcfg
  3. remove cleanup_all_ifaces() function used by cleanup. I don't see when we will ever need to remove all interfaces including those not configured by os-net-config
  4. introduce delete_ifaces() function for the cleanup. This function read the current config file from '/var/lib/os-net-config/nmstate_files/config.yaml', and compare with the interface objects from the new configuration file. If it's no longer in these new interface objects, it will be deleted

This design will have no change to CLI command thus user don't need to be involved in interface deletion. This design will let nmstate handling of removing interface using --cleanup flag, the same way as ifcfg.

@karthiksundaravel
Copy link
Member

@yiytan

We have a recent patch [1] where the cleanup is done only for interfaces not defined in config.yaml with the exceptions that OVS interface, ovs bridges and SRIOV Pfs cannot be removed even when these are not defined in config.yaml

[1] os-net-config/os-net-config@805ec05

@yiytan
Copy link

yiytan commented Jun 12, 2025

@karthiksundaravel so what exactly it is to cleanup on nmstate cleanup? It will still cleanup interfaces that was not initially created by os-net-config right?

@yiytan
Copy link

yiytan commented Jun 12, 2025

@karthiksundaravel the issue is with using netinfo.show_running_config()[Interface.KEY], this gave all interfaces including the ones not configured by os-net-config (i.e. never was in the config.yaml)

@yiytan
Copy link

yiytan commented Jun 13, 2025

@karthiksundaravel

Based on your recent submission, we can add the support of deletion of existing interfaces that were in current config.yaml but not in new config.yaml. This will ensure we only delete interfaces that were configured by os-net-config

  1. save nmstate current config into '/var/lib/os-net-config/nmstate_files/config.yaml' once configuration is successful
  2. keep using --cleanup flag instead of introducing a new --current-config flag
  3. change cleanup_all_ifaces() function used by cleanup:
  • remove calling of netinfo.show_running_config()[Interface.KEY],
  • replace with function self.get_current_ifaces() to read in the current configured interfaces from '/var/lib/os-net-config/nmstate_files/config.yaml'

@karthiksundaravel
Copy link
Member

@yiytan The --cleanup flag is used to remove the configuration of network devices not mentioned in config.yaml. If we need to remove interfaces which are not defined in new-config.yaml but defined in the previous-config.yaml then we can do with the changes you have suggested but with a different config flag.

@yiytan
Copy link

yiytan commented Jun 19, 2025

@karthiksundaravel --cleanup flag is used to remove the interfaces that's not defined in os-net-config's config.yaml

However, in nmstate, we mistakenly deleted the interfaces that's not even configured by os-net-config, i.e. interfaces that was not in previous config.yaml got deleted.

I created this PR to restrict --cleanup to remove only interfaces that were configured by os-net-config. Please review it.

os-net-config/os-net-config#230

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants