{"action":"created","issue":{"url":"https://api.github.com/repos/kubernetes/kubernetes/issues/70864","repository_url":"https://api.github.com/repos/kubernetes/kubernetes","labels_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/70864/labels{/name}","comments_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/70864/comments","events_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/70864/events","html_url":"https://github.com/kubernetes/kubernetes/issues/70864","id":379128307,"node_id":"MDU6SXNzdWUzNzkxMjgzMDc=","number":70864,"title":"ValidationWebhookConfiguration causes deployments to maintain two underlying RS at the same time","user":{"login":"Suhas-Git","id":15986746,"node_id":"MDQ6VXNlcjE1OTg2NzQ2","avatar_url":"https://avatars0.githubusercontent.com/u/15986746?v=4","gravatar_id":"","url":"https://api.github.com/users/Suhas-Git","html_url":"https://github.com/Suhas-Git","followers_url":"https://api.github.com/users/Suhas-Git/followers","following_url":"https://api.github.com/users/Suhas-Git/following{/other_user}","gists_url":"https://api.github.com/users/Suhas-Git/gists{/gist_id}","starred_url":"https://api.github.com/users/Suhas-Git/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Suhas-Git/subscriptions","organizations_url":"https://api.github.com/users/Suhas-Git/orgs","repos_url":"https://api.github.com/users/Suhas-Git/repos","events_url":"https://api.github.com/users/Suhas-Git/events{/privacy}","received_events_url":"https://api.github.com/users/Suhas-Git/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":404091735,"node_id":"MDU6TGFiZWw0MDQwOTE3MzU=","url":"https://api.github.com/repos/kubernetes/kubernetes/labels/sig/apps","name":"sig/apps","color":"d2b48c","default":false},{"id":125550211,"node_id":"MDU6TGFiZWwxMjU1NTAyMTE=","url":"https://api.github.com/repos/kubernetes/kubernetes/labels/sig/scheduling","name":"sig/scheduling","color":"d2b48c","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-11-09T11:37:11Z","updated_at":"2018-11-10T20:55:59Z","closed_at":null,"author_association":"NONE","body":"<!-- Please use this template while reporting a bug and provide as much info as possible. Not doing so may result in your bug not being addressed in a timely manner. Thanks!-->\r\n\r\n**What happened**:\r\nI have ValidationWebhookConfiguration that checks the deployments for the availability of `spec.template.spec.tolerations` and throws an error if it does not have `tolerations`. Thus enforcing deployments to have `tolerations`. I enforce `tolerations` on staging namespaces only in order to enforce deployments to run on pre-emptive nodes. \r\n\r\nAfter I add the `tolerations` because of the above enforcement(ie.update the deployment with tolerations). The deployment maintains two of its underlying ReplicaSet. Thus keeping the old pods and new pods as well. It is important to note that I cannot simply delete old RS by --force too, it is just recreated again.\r\n\r\nWhen I remove the  ValidationWebhookConfiguration, I have no problems, I can update the deployments with tolerations(or for that matter any other key/map) and the deployment maintains only one RS i.e., it has only new pods. I can also delete the old RS(if needed).\r\n\r\n**Please find below, the ValidationWebhookConfiguration that I am using:-**\r\n```\r\napiVersion: admissionregistration.k8s.io/v1beta1\r\nkind: ValidatingWebhookConfiguration\r\nmetadata:\r\n  name: deny-absence-of-tolerations\r\nwebhooks:\r\n  - name: deny.absence.of.tolerations\r\n    rules:\r\n      - apiGroups: [\"apps\",\"extensions\"]\r\n        apiVersions: [\"v1\",\"v1beta1\",\"v1beta2\"]\r\n        operations: [ \"CREATE\",\"UPDATE\" ]\r\n        #operations: [ \"*\" ]\r\n        resources: [\"deployments\",\"replicasets\"]\r\n    namespaceSelector:\r\n      matchExpressions:\r\n      - key: namespace\r\n        operator: In\r\n        values:\r\n        - test-namespace\r\n    failurePolicy: Fail\r\n    clientConfig:\r\n      url: \"https://deny_absence_of_tolerations\"\r\n      caBundle: cabundlevaluehere \r\n```\r\n\r\n\r\n**And the core part of my backend server goes like this:-**\r\n\r\n```\r\n  var admissionResponse = {\r\n    allowed: false\r\n  };\r\n\r\n  var found = false;\r\n\r\n  if (!object.spec.template.spec.tolerations) {\r\n\r\n      console.log(\"Workload is not using tolerations\");\r\n\r\n      admissionResponse.status = {\r\n        status: 'Failure',\r\n          message: \"On Staging/Testing please use tolerations\",\r\n        reason: \" Workload ( ie.,deployment ) Requirement Failed\",\r\n        code: 402\r\n      };\r\n\r\n      found = true;\r\n\r\n  };\r\n\r\n  if (!found) {\r\n    admissionResponse.allowed = true;\r\n  }\r\n\r\n  var admissionReview = {\r\n    response: admissionResponse\r\n  };\r\n\r\n  res.setHeader('Content-Type', 'application/json');\r\n  res.send(JSON.stringify(admissionReview));\r\n  res.status(200).end();\r\n```\r\n\r\n\r\n \r\n\r\n**What you expected to happen**:\r\nExpected behaviour of deployment i.e., deployment should maintain only one RS.\r\n\r\n**How to reproduce it (as minimally and precisely as possible)**:\r\n   1).   First of all, have no validationWebhookConfiguration.\r\n   2).  Create a deployment(without tolerations) in a namespace(lets call it :- test-namespace)\r\n   3).  Add validationWebhookConfiguration now to test-namespace in order to enforce tolerations.\r\n   4).  Now update the  deployment with tolerations and apply it.\r\n   5). As mentioned above in detail, now the ValidationWebhookConfiguration causes deployments to maintain two underlying RS at the same time\r\n\r\n\r\n**Anything else we need to know?**: A complete delete of deployment and applying the updated deployment does not cause the above problem. But deleting a complete deployment is a downtime to consider.\r\n\r\n**Environment**:\r\n- Kubernetes version (use `kubectl version`): 1.10.6-gke.9\r\n- Cloud provider or hardware configuration: Google Kubernetes Enginer\r\n- OS (e.g. from /etc/os-release): COS\r\n- Kernel (e.g. `uname -a`): 4.14.56+ #1 SMP x86_64 Intel(R) Xeon(R) CPU @ 2.30GHz GenuineIntel GNU/Linux\r\n- Install tools:\r\n- Others:\r\n\r\n@kubernetes/sig-scheduling-bug\r\n@kubernetes/sig-apps-bug\r\n<!-- DO NOT EDIT BELOW THIS LINE -->\r\n/kind bug"},"comment":{"url":"https://api.github.com/repos/kubernetes/kubernetes/issues/comments/437620628","html_url":"https://github.com/kubernetes/kubernetes/issues/70864#issuecomment-437620628","issue_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/70864","id":437620628,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNzYyMDYyOA==","user":{"login":"liggitt","id":980082,"node_id":"MDQ6VXNlcjk4MDA4Mg==","avatar_url":"https://avatars0.githubusercontent.com/u/980082?v=4","gravatar_id":"","url":"https://api.github.com/users/liggitt","html_url":"https://github.com/liggitt","followers_url":"https://api.github.com/users/liggitt/followers","following_url":"https://api.github.com/users/liggitt/following{/other_user}","gists_url":"https://api.github.com/users/liggitt/gists{/gist_id}","starred_url":"https://api.github.com/users/liggitt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liggitt/subscriptions","organizations_url":"https://api.github.com/users/liggitt/orgs","repos_url":"https://api.github.com/users/liggitt/repos","events_url":"https://api.github.com/users/liggitt/events{/privacy}","received_events_url":"https://api.github.com/users/liggitt/received_events","type":"User","site_admin":false},"created_at":"2018-11-10T20:55:59Z","updated_at":"2018-11-10T20:55:59Z","author_association":"MEMBER","body":"cc @janetkuo for fragile detection of current revision based on template comparisons"}}
{"actor":{"display_login":"liggitt"}}