From d804dcd8cce5c3b40ad6fd0f69451f62fc79d054 Mon Sep 17 00:00:00 2001 From: Gaurav <39389231+gsquared94@users.noreply.github.com> Date: Thu, 18 Nov 2021 23:37:06 +0530 Subject: [PATCH] fix: apply cmd should run `kubectl create --dry-run` to get the `ManifestList` (#6875) --- integration/apply_test.go | 4 ++++ integration/testdata/apply/pod.yaml | 8 ++++++++ integration/testdata/apply/skaffold.yaml | 4 ++++ pkg/skaffold/deploy/kubectl/kubectl.go | 4 ++-- 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 integration/testdata/apply/pod.yaml diff --git a/integration/apply_test.go b/integration/apply_test.go index abee2259ed6..c3292265770 100644 --- a/integration/apply_test.go +++ b/integration/apply_test.go @@ -95,6 +95,10 @@ func TestApplyStatusCheckFailure(t *testing.T) { description: "status check for config connector resources", profile: "configconnector", }, + { + description: "status check for standalone pods", + profile: "pod", + }, } for _, test := range tests { testutil.Run(t, test.description, func(t *testutil.T) { diff --git a/integration/testdata/apply/pod.yaml b/integration/testdata/apply/pod.yaml new file mode 100644 index 00000000000..c63db547e57 --- /dev/null +++ b/integration/testdata/apply/pod.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Pod +metadata: + name: zz-image-doesnt-exist +spec: + containers: + - image: zz-image-doesnt-exist + name: apply-status-check-failure \ No newline at end of file diff --git a/integration/testdata/apply/skaffold.yaml b/integration/testdata/apply/skaffold.yaml index 35ca4422609..860c8429426 100644 --- a/integration/testdata/apply/skaffold.yaml +++ b/integration/testdata/apply/skaffold.yaml @@ -14,3 +14,7 @@ profiles: kubectl: statusCheckDeadlineSeconds: 10 manifests: ["configconnector.yaml"] + - name: pod + deploy: + kubectl: + manifests: ["pod.yaml"] diff --git a/pkg/skaffold/deploy/kubectl/kubectl.go b/pkg/skaffold/deploy/kubectl/kubectl.go index 1485c92b496..1acde1fe712 100644 --- a/pkg/skaffold/deploy/kubectl/kubectl.go +++ b/pkg/skaffold/deploy/kubectl/kubectl.go @@ -180,8 +180,8 @@ func (k *Deployer) Deploy(ctx context.Context, out io.Writer, builds []graph.Art // also, manually set the labels to ensure the runID is added switch { case len(k.hydratedManifests) > 0: - _, endTrace = instrumentation.StartTrace(ctx, "Deploy_createManifestList") - manifests, err = createManifestList(k.hydratedManifests) + _, endTrace = instrumentation.StartTrace(ctx, "Deploy_readHydratedManifests") + manifests, err = k.kubectl.ReadManifests(ctx, k.hydratedManifests) if err != nil { endTrace(instrumentation.TraceEndError(err)) return err