Skip to content

Allow to change the cluster default network type#438

Merged
openshift-merge-robot merged 1 commit intoopenshift:masterfrom
pliurh:cold_migration
Jan 24, 2020
Merged

Allow to change the cluster default network type#438
openshift-merge-robot merged 1 commit intoopenshift:masterfrom
pliurh:cold_migration

Conversation

@pliurh
Copy link
Contributor

@pliurh pliurh commented Jan 7, 2020

Allow users to change the cluster default network type by updating the 'networkType' field of the network.config.openshift.io CR. This not only support the use case of migrating the cluster network from Openshift SDN to OVN-Kubernetes, but also the use case vise Versa.

@openshift-ci-robot openshift-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 7, 2020
@pliurh pliurh force-pushed the cold_migration branch 2 times, most recently from 2929c8b to 7cb3a11 Compare January 8, 2020 08:19
@danwinship
Copy link
Contributor

/hold
We can't allow this in general; it would completely break the cluster. We need to have some way of allowing it as part of the supported migration procedure, but blocking it otherwise.

@openshift-ci-robot openshift-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jan 8, 2020
#!/bin/bash
/usr/share/openvswitch/scripts/ovs-ctl stop
rm -rf /run/openvswitch/*
rm -rf /var/lib/openvswitch/*
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't want to do this on ordinary termination; it would mean that every upgrade would tear down the network. (Likewise for the ovn-kube change.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

lifecycle:
preStop:
exec:
command: ["rm","-f","/etc/cni/net.d/80-openshift-network.conf"]
Copy link
Contributor

Choose a reason for hiding this comment

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

there is already a preStop handler at the end of the container spec that does this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

ports:
- name: metrics
port: 9101
port: 9103
Copy link
Contributor

Choose a reason for hiding this comment

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

(this could be done as a separate PR...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do.

objToDelete.SetNamespace(currentObj.Namespace)
objToDelete.SetGroupVersionKind(gvk)
if objToDelete.GetKind() == "Namespace" {
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this added? We want to delete unused namespaces...
(Though... I guess probably we need to fix it to do that last.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Due to some reason, the 'namespace' deletion is always stuck at the "Terminating" state forever, even when all the related objects in that namespace have been deleted. And it will block the same Namespace creation if we what to perform a rollback from ovn-kubernetes to openshift-sdn.

I agree that we need to remove the unused namespaces anyway. But I think maybe we can fix it later.

Copy link
Contributor

Choose a reason for hiding this comment

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

Due to some reason, the 'namespace' deletion is always stuck at the "Terminating" state forever, even when all the related objects in that namespace have been deleted.

Maybe there is something else in that Namespace that isn't in the related objects then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, there are some objects which are not managed by the CNO. I am not sure what is the proper way to delete all of them, then delete the namespace itself.

Copy link
Contributor

Choose a reason for hiding this comment

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

hm. do you remember what objects?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did some further tests. It turns out that the namespace will be stuck in 'Terminating' before the cluster reboot, but can be deleted eventually after that. Therefore I remove the lines above.

oldStatus := co.Status.DeepCopy()
status.deleteRelatedObjectsNotRendered(co)
status.deleteDaemonSetNotRendered(co)
status.deleteDeploymentNotRendered(co)
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this needed? The DaemonSets and Deployments should also be in RelatedObjects

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The origin intention is to remove the deployment and daemonset before other objects. But I found it is unnecessary after more tests. It shall be removed.

@pliurh
Copy link
Contributor Author

pliurh commented Jan 13, 2020

/hold
We can't allow this in general; it would completely break the cluster. We need to have some way of allowing it as part of the supported migration procedure, but blocking it otherwise.

Agree. What's your suggestion on how to do it? How about adding an annotation like maintenance: "migration" in the cluster CR to indicate if this kind of operation can be allowed or not?

@danwinship
Copy link
Contributor

An annotation sounds good. It should be more namespaced than that though. Maybe something like

"networkoperator.openshift.io/network-migration": ""

(Standard annotation semantics are that if there's nothing to say about the annotation beyond the fact that it exists, then you just give it an empty-string value rather than "true" or something like that.)

You still need to figure out exactly what that entails though; you don't want CNO to start changing DaemonSets right away because that would interfere with the controlled node-by-node migration plan... do you stop the CNO during the migration? Is the rest of the code for dealing with migrations posted somewhere?

@openshift-ci-robot openshift-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 13, 2020
@pliurh
Copy link
Contributor Author

pliurh commented Jan 13, 2020

An annotation sounds good. It should be more namespaced than that though. Maybe something like

"networkoperator.openshift.io/network-migration": ""

(Standard annotation semantics are that if there's nothing to say about the annotation beyond the fact that it exists, then you just give it an empty-string value rather than "true" or something like that.)

You still need to figure out exactly what that entails though; you don't want CNO to start changing DaemonSets right away because that would interfere with the controlled node-by-node migration plan... do you stop the CNO during the migration? Is the rest of the code for dealing with migrations posted somewhere?

In 4.4, we plan to take the cluster reboot approach, which means all the nodes will be rebooted during the migration. Therefore, the whole cluster shall be considered as out of service during the migration. So all the pod will be connected to the new network backend after reboot. I gave a live demo at the Group C demo on Jan 8th, however, the demo record has not been added to the agenda doc yet. But here is a previous demo record, which shows the whole procedure of the 'cluster reboot' migration.

@pliurh pliurh force-pushed the cold_migration branch 2 times, most recently from 9dc3053 to b455578 Compare January 13, 2020 15:25
@pliurh
Copy link
Contributor Author

pliurh commented Jan 20, 2020

/test e2e-gcp

1 similar comment
@pliurh
Copy link
Contributor Author

pliurh commented Jan 20, 2020

/test e2e-gcp

Copy link
Contributor

@danwinship danwinship left a comment

Choose a reason for hiding this comment

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

So this is looking pretty simple now. We still need to figure out what's going wrong with deleting the namespace


const (
// The Network Migration Annotation which indicates if the operator is allowed to change the cluster network type.
MigrationAnno = "networkoperator.openshift.io/network-migration"
Copy link
Contributor

Choose a reason for hiding this comment

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

move this to pkg/names/names.go and spell out "Annotation" in full, please

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

@danwinship
Copy link
Contributor

Thanks. Can you squash the commits?

Allow users to change the cluster default network type by updating the 'networkType'
field of the network.config.openshift.io CR. This not only supports the use case of
migrating the cluster network from Openshift SDN to OVN-Kubernetes, but also the case
vise Versa.

By default, this operation is not allowed by the operator. Users need to add annotation
'networkoperator.openshift.io/network-migration: ""' to the Network.operator.openshift.io
CR 'cluster' before executing.
@pliurh
Copy link
Contributor Author

pliurh commented Jan 23, 2020

Thanks. Can you squash the commits?

Done.

@pliurh
Copy link
Contributor Author

pliurh commented Jan 24, 2020

So this is looking pretty simple now. We still need to figure out what's going wrong with deleting the namespace

Before rebooting, the cluster is in an unstable status. The stuck namespace has a finalizer 'kubernetes', which blocks the deletion. I think it should be fine, as long as, the namespace can be deleted successfully after the cluster back to normal.

p.s. There is a way to force delete the namespace kubernetes/kubernetes#60807 (comment), it could be a way out if the namespace deletion went wrong.

@danwinship
Copy link
Contributor

/lgtm
/hold cancel

@openshift-ci-robot openshift-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Jan 24, 2020
@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 24, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: danwinship, pliurh

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

The pull request process is described 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

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit bfc8b01 into openshift:master Jan 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants