{"action":"created","issue":{"url":"https://api.github.com/repos/kubernetes/kubernetes/issues/67546","repository_url":"https://api.github.com/repos/kubernetes/kubernetes","labels_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/67546/labels{/name}","comments_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/67546/comments","events_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/67546/events","html_url":"https://github.com/kubernetes/kubernetes/issues/67546","id":351625982,"node_id":"MDU6SXNzdWUzNTE2MjU5ODI=","number":67546,"title":"PATCH with {\"$patch\": \"delete\"} creates key if non-existing","user":{"login":"bronger","id":2184938,"node_id":"MDQ6VXNlcjIxODQ5Mzg=","avatar_url":"https://avatars2.githubusercontent.com/u/2184938?v=4","gravatar_id":"","url":"https://api.github.com/users/bronger","html_url":"https://github.com/bronger","followers_url":"https://api.github.com/users/bronger/followers","following_url":"https://api.github.com/users/bronger/following{/other_user}","gists_url":"https://api.github.com/users/bronger/gists{/gist_id}","starred_url":"https://api.github.com/users/bronger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bronger/subscriptions","organizations_url":"https://api.github.com/users/bronger/orgs","repos_url":"https://api.github.com/users/bronger/repos","events_url":"https://api.github.com/users/bronger/events{/privacy}","received_events_url":"https://api.github.com/users/bronger/received_events","type":"User","site_admin":false},"labels":[{"id":105146071,"node_id":"MDU6TGFiZWwxMDUxNDYwNzE=","url":"https://api.github.com/repos/kubernetes/kubernetes/labels/kind/bug","name":"kind/bug","color":"e11d21","default":false},{"id":173493835,"node_id":"MDU6TGFiZWwxNzM0OTM4MzU=","url":"https://api.github.com/repos/kubernetes/kubernetes/labels/sig/api-machinery","name":"sig/api-machinery","color":"d2b48c","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-08-17T14:53:05Z","updated_at":"2018-08-20T09:05:10Z","closed_at":null,"author_association":"NONE","body":"Having a deployment like:\r\n\r\n    apiVersion: extensions/v1beta1\r\n    kind: Deployment\r\n    spec:\r\n      template:\r\n        spec:\r\n          containers:\r\n          - name: mycontainer\r\n    ...\r\nand applying the following patch:\r\n\r\n    kubectl patch deployment mydeployment -p '{\"spec\": {\"template\": {\"spec\": {\"containers\": [{\"name\": \"mycontainer\", \"env\": [{\"$patch\": \"delete\", \"name\": \"FOOBAR\"}]}]}}}}'\r\nresults in:\r\n\r\n    apiVersion: extensions/v1beta1\r\n    kind: Deployment\r\n    spec:\r\n      template:\r\n        spec:\r\n          containers:\r\n          - name: mycontainer\r\n            env:\r\n            - name: FOOBAR\r\n    ...\r\n\r\nApplying it over and over again results in oscillating behaviour: The key is deleted and re-created over and over again.\r\n\r\nExpected behaviour is that the operation is idempotent, leaving the key non-existing.\r\n\r\nKubernetes v1.11\r\n/kind bug\r\n"},"comment":{"url":"https://api.github.com/repos/kubernetes/kubernetes/issues/comments/414248506","html_url":"https://github.com/kubernetes/kubernetes/issues/67546#issuecomment-414248506","issue_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/67546","id":414248506,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNDI0ODUwNg==","user":{"login":"yue9944882","id":12049380,"node_id":"MDQ6VXNlcjEyMDQ5Mzgw","avatar_url":"https://avatars1.githubusercontent.com/u/12049380?v=4","gravatar_id":"","url":"https://api.github.com/users/yue9944882","html_url":"https://github.com/yue9944882","followers_url":"https://api.github.com/users/yue9944882/followers","following_url":"https://api.github.com/users/yue9944882/following{/other_user}","gists_url":"https://api.github.com/users/yue9944882/gists{/gist_id}","starred_url":"https://api.github.com/users/yue9944882/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yue9944882/subscriptions","organizations_url":"https://api.github.com/users/yue9944882/orgs","repos_url":"https://api.github.com/users/yue9944882/repos","events_url":"https://api.github.com/users/yue9944882/events{/privacy}","received_events_url":"https://api.github.com/users/yue9944882/received_events","type":"User","site_admin":false},"created_at":"2018-08-20T09:05:10Z","updated_at":"2018-08-20T09:05:10Z","author_association":"MEMBER","body":"@liggitt i thought it's the buggy merge key this time again.. but i finally found out that it's the strategic patch stops recursion at the following lines when it does the patch for a container without `env`. so it won't go on respect the directives inside `env` like `$patch: delete` in this case.\r\n\r\n[https://github.com/kubernetes/kubernetes/blob/39e341c11f9a18d7fcbf78e4dce6801131e2ba38/staging/src/k8s.io/apimachinery/pkg/util/strategicpatch/patch.go#L1332-L1337](https://github.com/kubernetes/kubernetes/blob/39e341c11f9a18d7fcbf78e4dce6801131e2ba38/staging/src/k8s.io/apimachinery/pkg/util/strategicpatch/patch.go#L1332-L1337)\r\n\r\ni open a fix and wrote another integration test to verity the patch behavior according to this issue in #67586."}}
{"actor":{"display_login":"yue9944882"}}