{"action":"created","issue":{"url":"https://api.github.com/repos/kubernetes/kubernetes/issues/34413","repository_url":"https://api.github.com/repos/kubernetes/kubernetes","labels_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/34413/labels{/name}","comments_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/34413/comments","events_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/34413/events","html_url":"https://github.com/kubernetes/kubernetes/issues/34413","id":181884931,"number":34413,"title":"Intermittent error when doing kubectl apply -f for a HorizontalPodAutoscaler: 'unable to find api field in struct HorizontalPodAutoscalerSpec for the json field \"scaleTargetRef\"'","user":{"login":"bes","id":85731,"avatar_url":"https://avatars.githubusercontent.com/u/85731?v=3","gravatar_id":"","url":"https://api.github.com/users/bes","html_url":"https://github.com/bes","followers_url":"https://api.github.com/users/bes/followers","following_url":"https://api.github.com/users/bes/following{/other_user}","gists_url":"https://api.github.com/users/bes/gists{/gist_id}","starred_url":"https://api.github.com/users/bes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bes/subscriptions","organizations_url":"https://api.github.com/users/bes/orgs","repos_url":"https://api.github.com/users/bes/repos","events_url":"https://api.github.com/users/bes/events{/privacy}","received_events_url":"https://api.github.com/users/bes/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/kubernetes/kubernetes/labels/0%20-%20Triage","name":"0 - Triage","color":"AAAAAA"},{"url":"https://api.github.com/repos/kubernetes/kubernetes/labels/component/kubectl","name":"component/kubectl","color":"0052cc"},{"url":"https://api.github.com/repos/kubernetes/kubernetes/labels/kind/bug","name":"kind/bug","color":"e11d21"},{"url":"https://api.github.com/repos/kubernetes/kubernetes/labels/team/ux","name":"team/ux","color":"d2b48c"},{"url":"https://api.github.com/repos/kubernetes/kubernetes/labels/ux-triaged","name":"ux-triaged","color":"5319e7"}],"state":"open","locked":false,"assignee":{"login":"ymqytw","id":2589105,"avatar_url":"https://avatars.githubusercontent.com/u/2589105?v=3","gravatar_id":"","url":"https://api.github.com/users/ymqytw","html_url":"https://github.com/ymqytw","followers_url":"https://api.github.com/users/ymqytw/followers","following_url":"https://api.github.com/users/ymqytw/following{/other_user}","gists_url":"https://api.github.com/users/ymqytw/gists{/gist_id}","starred_url":"https://api.github.com/users/ymqytw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ymqytw/subscriptions","organizations_url":"https://api.github.com/users/ymqytw/orgs","repos_url":"https://api.github.com/users/ymqytw/repos","events_url":"https://api.github.com/users/ymqytw/events{/privacy}","received_events_url":"https://api.github.com/users/ymqytw/received_events","type":"User","site_admin":false},"assignees":[{"login":"ymqytw","id":2589105,"avatar_url":"https://avatars.githubusercontent.com/u/2589105?v=3","gravatar_id":"","url":"https://api.github.com/users/ymqytw","html_url":"https://github.com/ymqytw","followers_url":"https://api.github.com/users/ymqytw/followers","following_url":"https://api.github.com/users/ymqytw/following{/other_user}","gists_url":"https://api.github.com/users/ymqytw/gists{/gist_id}","starred_url":"https://api.github.com/users/ymqytw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ymqytw/subscriptions","organizations_url":"https://api.github.com/users/ymqytw/orgs","repos_url":"https://api.github.com/users/ymqytw/repos","events_url":"https://api.github.com/users/ymqytw/events{/privacy}","received_events_url":"https://api.github.com/users/ymqytw/received_events","type":"User","site_admin":false}],"milestone":null,"comments":11,"created_at":"2016-10-09T12:42:31Z","updated_at":"2016-10-24T20:35:19Z","closed_at":null,"body":"**What keywords did you search in Kubernetes issues before filing this one?**\r\n* unable to find api field in struct HorizontalPodAutoscalerSpec for the json field \"scaleTargetRef\"\r\n* HorizontalPodAutoscaler\r\n* scaleTargetRef\r\n\r\nAlso searched google/stackoverflow\r\n\r\n---\r\n\r\n**Is this a BUG REPORT or FEATURE REQUEST?**\r\nBug report\r\n\r\n**Kubernetes version** (use `kubectl version`):\r\nv1.4.0\r\n\r\n**Environment**:\r\n- GKE with kubernetes v1.4.0\r\n\r\n**What happened**:\r\nDo `kubectl apply -f my-service.yaml`\r\n\r\nIntermittently, since upgrading to 1.4.0 I have been getting\r\n```shell\r\nerror: error when applying patch:\r\n\r\nto:\r\n&{0xc8203546c0 0xc8202e3340 default my-service-horizpodautoscaler /my-service/build/k8s/my-service.yaml &HorizontalPodAutoscaler{ObjectMeta:k8s_io_kubernetes_pkg_api_v1.ObjectMeta{Name:my-service-horizpodautoscaler,GenerateName:,Namespace:,SelfLink:,UID:,ResourceVersion:,Generation:0,CreationTimestamp:0001-01-01 00:00:00 +0000 UTC,DeletionTimestamp:<nil>,DeletionGracePeriodSeconds:nil,Labels:map[string]string{},Annotations:map[string]string{kubectl.kubernetes.io/last-applied-configuration: ,},OwnerReferences:[],Finalizers:[],ClusterName:,},Spec:HorizontalPodAutoscalerSpec{ScaleTargetRef:CrossVersionObjectReference{Kind:Deployment,Name:my-service-frontend,APIVersion:extensions/v1beta1,},MinReplicas:*1,MaxReplicas:3,TargetCPUUtilizationPercentage:nil,},Status:HorizontalPodAutoscalerStatus{ObservedGeneration:nil,LastScaleTime:<nil>,CurrentReplicas:0,DesiredReplicas:0,CurrentCPUUtilizationPercentage:nil,},} &TypeMeta{Kind:,APIVersion:,} 1537793 false}\r\nfor: \"/my-service/build/k8s/my-service.yaml\": error when creating patch with:\r\noriginal:\r\n{\"kind\":\"HorizontalPodAutoscaler\",\"apiVersion\":\"autoscaling/v1\",\"metadata\":{\"name\":\"my-service-horizpodautoscaler\",\"creationTimestamp\":null},\"spec\":{\"scaleTargetRef\":{\"kind\":\"Deployment\",\"name\":\"my-service-frontend\",\"apiVersion\":\"extensions/v1beta1\"},\"minReplicas\":1,\"maxReplicas\":3},\"status\":{\"currentReplicas\":0,\"desiredReplicas\":0}}\r\nmodified:\r\n{\"kind\":\"HorizontalPodAutoscaler\",\"apiVersion\":\"autoscaling/v1\",\"metadata\":{\"name\":\"my-service-horizpodautoscaler\",\"creationTimestamp\":null,\"annotations\":{\"kubectl.kubernetes.io/last-applied-configuration\":\"{\\\"kind\\\":\\\"HorizontalPodAutoscaler\\\",\\\"apiVersion\\\":\\\"autoscaling/v1\\\",\\\"metadata\\\":{\\\"name\\\":\\\"my-service-horizpodautoscaler\\\",\\\"creationTimestamp\\\":null},\\\"spec\\\":{\\\"scaleTargetRef\\\":{\\\"kind\\\":\\\"Deployment\\\",\\\"name\\\":\\\"my-service-frontend\\\",\\\"apiVersion\\\":\\\"extensions/v1beta1\\\"},\\\"minReplicas\\\":1,\\\"maxReplicas\\\":3},\\\"status\\\":{\\\"currentReplicas\\\":0,\\\"desiredReplicas\\\":0}}\"}},\"spec\":{\"scaleTargetRef\":{\"kind\":\"Deployment\",\"name\":\"my-service-frontend\",\"apiVersion\":\"extensions/v1beta1\"},\"minReplicas\":1,\"maxReplicas\":3},\"status\":{\"currentReplicas\":0,\"desiredReplicas\":0}}\r\ncurrent:\r\n{\"kind\":\"HorizontalPodAutoscaler\",\"apiVersion\":\"extensions/v1beta1\",\"metadata\":{\"name\":\"my-service-horizpodautoscaler\",\"namespace\":\"default\",\"selfLink\":\"/apis/autoscaling/v1/namespaces/default/horizontalpodautoscalers/my-service-horizpodautoscaler\",\"uid\":\"REDACTED-REDA-REDA-REDA-REDACTED\",\"resourceVersion\":\"1537793\",\"creationTimestamp\":\"2016-09-28T15:51:27Z\",\"annotations\":{\"kubectl.kubernetes.io/last-applied-configuration\":\"{\\\"kind\\\":\\\"HorizontalPodAutoscaler\\\",\\\"apiVersion\\\":\\\"autoscaling/v1\\\",\\\"metadata\\\":{\\\"name\\\":\\\"my-service-horizpodautoscaler\\\",\\\"creationTimestamp\\\":null},\\\"spec\\\":{\\\"scaleTargetRef\\\":{\\\"kind\\\":\\\"Deployment\\\",\\\"name\\\":\\\"my-service-frontend\\\",\\\"apiVersion\\\":\\\"extensions/v1beta1\\\"},\\\"minReplicas\\\":1,\\\"maxReplicas\\\":3},\\\"status\\\":{\\\"currentReplicas\\\":0,\\\"desiredReplicas\\\":0}}\"}},\"spec\":{\"scaleRef\":{\"kind\":\"Deployment\",\"name\":\"my-service-frontend\",\"apiVersion\":\"extensions/v1beta1\",\"subresource\":\"scale\"},\"minReplicas\":1,\"maxReplicas\":3,\"cpuUtilization\":{\"targetPercentage\":80}},\"status\":{\"lastScaleTime\":\"2016-10-08T23:19:12Z\",\"currentReplicas\":1,\"desiredReplicas\":1,\"currentCPUUtilizationPercentage\":0}}\r\n\r\nfor: \"/my-service/build/k8s/my-service.yaml\": unable to find api field in struct HorizontalPodAutoscalerSpec for the json field \"scaleTargetRef\"\r\n```\r\n\r\nAs you can see, it seems that the \"current\" metadata specifies \"apiVersion\" as extensions/v1beta1, that might be correct, but it seems suspicious to me...\r\n\r\nI have the feeling it works every second time I do apply, but hard to say from my small sample size.\r\n\r\n**What you expected to happen**:\r\nThe apply to work every time.\r\n\r\n\r\n**How to reproduce it**\r\n\r\nI used this yaml file (cleaned)\r\n\r\n```yaml\r\napiVersion: v1\r\nkind: Service\r\nmetadata:\r\n  name: my-service\r\n  labels:\r\n    app: my-service\r\n    tier: frontend\r\nspec:\r\n  type: NodePort\r\n  ports:\r\n  - name: http8080\r\n    protocol: TCP\r\n    port: 8080\r\n    targetPort: 8080\r\n  selector:\r\n    app: my-service\r\n    tier: frontend\r\n---\r\napiVersion: extensions/v1beta1\r\nkind: Deployment\r\nmetadata:\r\n  name: my-service-frontend\r\nspec:\r\n  replicas: 1\r\n  template:\r\n    metadata:\r\n      labels:\r\n        app: my-service\r\n        tier: frontend\r\n    spec:\r\n      containers:\r\n      - name: my-service\r\n        image: eu.gcr.io/my-project/my-service:v0.0.0\r\n        env:\r\n        - name: MY_ENVIRONMENT\r\n          value: dev\r\n        ports:\r\n        - containerPort: 8080\r\n        resources:\r\n          requests:\r\n            cpu: 100m\r\n            memory: 800Mi\r\n---\r\napiVersion: autoscaling/v1 #I've tried with extensions/v1beta1 and \"scaleRef\" below, but that doesn't work properly either (similar error message)\r\nkind: HorizontalPodAutoscaler\r\nmetadata:\r\n  name: my-service-horizpodautoscaler\r\nspec:\r\n  scaleTargetRef:\r\n    kind: Deployment\r\n    name: my-service-frontend\r\n    apiVersion: extensions/v1beta1 #I've tried with and without this, makes no difference\r\n  minReplicas: 1\r\n  maxReplicas: 3\r\n```\r\n\r\n**Anything else do we need to know**:\r\n\r\nGET on clusters using https://cloud.google.com/container-engine/reference/rest/v1/projects.zones.clusters/get reveals:\r\n```json\r\n[...]\r\n \"addonsConfig\": {\r\n  \"httpLoadBalancing\": {\r\n  },\r\n  \"horizontalPodAutoscaling\": {\r\n  }\r\n },\r\n[...]\r\n   \"initialNodeCount\": 1,\r\n   \"autoscaling\": {\r\n    \"enabled\": true,\r\n    \"minNodeCount\": 1,\r\n    \"maxNodeCount\": 3\r\n   },\r\n[...]\r\n\r\n \"initialClusterVersion\": \"1.3.6\",\r\n \"currentMasterVersion\": \"1.4.0\",\r\n \"currentNodeVersion\": \"1.4.0\",\r\n```\r\n\r\nTo solve this I have temporarily moved the HPA section out of the file into a separate file, but I prefer having the complete configuration in one place.\r\n\r\n\r\nAm I doing something wrong?\r\n\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/kubernetes/kubernetes/issues/comments/255858168","html_url":"https://github.com/kubernetes/kubernetes/issues/34413#issuecomment-255858168","issue_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/34413","id":255858168,"user":{"login":"ymqytw","id":2589105,"avatar_url":"https://avatars.githubusercontent.com/u/2589105?v=3","gravatar_id":"","url":"https://api.github.com/users/ymqytw","html_url":"https://github.com/ymqytw","followers_url":"https://api.github.com/users/ymqytw/followers","following_url":"https://api.github.com/users/ymqytw/following{/other_user}","gists_url":"https://api.github.com/users/ymqytw/gists{/gist_id}","starred_url":"https://api.github.com/users/ymqytw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ymqytw/subscriptions","organizations_url":"https://api.github.com/users/ymqytw/orgs","repos_url":"https://api.github.com/users/ymqytw/repos","events_url":"https://api.github.com/users/ymqytw/events{/privacy}","received_events_url":"https://api.github.com/users/ymqytw/received_events","type":"User","site_admin":false},"created_at":"2016-10-24T20:35:19Z","updated_at":"2016-10-24T20:35:19Z","body":"I will prioritize this issue.\r\ncc: @caesarxuchao "}}
{"actor":{"display_login":"ymqytw"}}