-
Notifications
You must be signed in to change notification settings - Fork 630
add owner ref to mtping deployment #3040
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
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 |
|---|---|---|
|
|
@@ -43,6 +43,10 @@ import ( | |
| type envConfig struct { | ||
| Image string `envconfig:"PING_IMAGE" required:"true"` | ||
| MTImage string `envconfig:"MT_PING_IMAGE" required:"true"` | ||
|
|
||
| // Add this for validation purpose only of validation. | ||
| ControllerName string `envconfig:"CONTROLLER_NAME" required:"true"` | ||
|
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. What are these for? |
||
| ControllerUID string `envconfig:"CONTROLLER_UID" required:"true"` | ||
| } | ||
|
|
||
| // NewController initializes the controller and is called by the generated code | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,11 +17,13 @@ limitations under the License. | |
| package resources | ||
|
|
||
| import ( | ||
| "os" | ||
|
|
||
| v1 "k8s.io/api/apps/v1" | ||
| corev1 "k8s.io/api/core/v1" | ||
| "k8s.io/apimachinery/pkg/api/resource" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
|
||
| "k8s.io/apimachinery/pkg/types" | ||
| "knative.dev/pkg/system" | ||
| ) | ||
|
|
||
|
|
@@ -41,6 +43,8 @@ type MTArgs struct { | |
| // MakeMTReceiveAdapter generates the mtping deployment for pingsources | ||
| func MakeMTReceiveAdapter(args MTArgs) *v1.Deployment { | ||
| replicas := int32(1) | ||
| blockOwnerDeletion := true | ||
| isController := true | ||
|
|
||
| return &v1.Deployment{ | ||
| TypeMeta: metav1.TypeMeta{ | ||
|
|
@@ -50,6 +54,16 @@ func MakeMTReceiveAdapter(args MTArgs) *v1.Deployment { | |
| ObjectMeta: metav1.ObjectMeta{ | ||
| Namespace: system.Namespace(), | ||
| Name: args.MTAdapterName, | ||
| OwnerReferences: []metav1.OwnerReference{ | ||
|
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. Setting the owner ref to the controller deployment seems like a bug to me, this means that the dataplane and control plane lifecycles are tied together and an upgrade of the control plane takes down the dataplane. |
||
| { | ||
| APIVersion: v1.SchemeGroupVersion.String(), | ||
| Kind: "Deployment", | ||
| Name: os.Getenv("CONTROLLER_NAME"), // guarantee to be non-empty | ||
|
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. you have already pulled this out of the environment, you should pass that var down so it is not also pulled from the env here. |
||
| UID: types.UID(os.Getenv("CONTROLLER_UID")), // guarantee to be non-empty | ||
| Controller: &isController, | ||
| BlockOwnerDeletion: &blockOwnerDeletion, | ||
| }, | ||
| }, | ||
| }, | ||
| Spec: v1.DeploymentSpec{ | ||
| Replicas: &replicas, | ||
|
|
||
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.
The downward API populates these with Pod values, so this PR is setting up bad owner references and Kubernetes GC will randomly delete the deployments as a result. We hit a similar issue with bad owner references in the webhook several months ago.
I believe @duglin was also just seeing a similar bad behavior in a separate context, and @markusthoemmes got bitten by this a month or two ago.