Skip to content

Commit

Permalink
network: disallow legacy hostNetwork together with non-default provider
Browse files Browse the repository at this point in the history
Fixes: #13692

Since the introduction of the "host" network provider, the  legacy
"hostNetwork" setting is intended to be used only in combination with
the default network provider (""), but the code did not enforce this.

This change adds the required validation checks to throw errors
in invalid constellations.

Signed-off-by: Michael Adam <obnox@samba.org>
  • Loading branch information
obnoxxx committed Feb 6, 2024
1 parent a33aa90 commit 210e2a1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/apis/ceph.rook.io/v1/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ func (n *NetworkSpec) IsHost() bool {
}

func ValidateNetworkSpec(clusterNamespace string, spec NetworkSpec) error {
if spec.HostNetwork && (spec.Provider != NetworkProviderDefault) {
return errors.Errorf("the legacy hostNetwork setting is only valid with the default network provider'\"\"' and not with '%q'", spec.Provider)
}
if spec.IsMultus() {
if len(spec.Selectors) == 0 {
return errors.Errorf("at least one network selector must be specified when using the %q network provider", NetworkProviderMultus)
Expand Down

0 comments on commit 210e2a1

Please sign in to comment.