From 97c520f821b105df7496112492978403ba5eddb3 Mon Sep 17 00:00:00 2001 From: Konstantin Kiess Date: Mon, 24 Jan 2022 17:33:54 +0100 Subject: [PATCH 1/2] Check if release needs to be updated do the same as for git and http url releases and check if we need to actually upload before uploading. requires the sha1sum to be present in the release config. --- cmd/upload_release.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/upload_release.go b/cmd/upload_release.go index 0a10ee36e..42caa5aed 100644 --- a/cmd/upload_release.go +++ b/cmd/upload_release.go @@ -55,7 +55,7 @@ func (c UploadReleaseCmd) Run(opts UploadReleaseOpts) error { case opts.Args.URL.IsGit(): return c.uploadIfNecessary(opts, c.uploadGit) default: - return c.uploadFile(opts) + return c.uploadIfNecessary(opts, c.uploadFile) } } From d5830b5977864a15e34d74b76df1793c7df3f098 Mon Sep 17 00:00:00 2001 From: Konstantin Kiess Date: Tue, 25 Jan 2022 16:09:30 +0100 Subject: [PATCH 2/2] Unify upload release handling to always check if skippable https://www.pivotaltracker.com/story/show/180980049 To improve deployment times we looked into the upload release section for local tarballs. we skipped the existing checks for tarballs and opted to always reupload. This PR changes this behaviour The new behaviour will skip uploading releases IF the specified name and version are available within the director. --fix will this override this behaviour within the cli subcommand (unlike when triggered through manifests) this will only be triggered if the --name and --version flags are specified. ```shell ubuntu@lighttaupe-ops-manager:~$ bosh upload-release file:///var/tempest/releases/pxc-0.39.0-ubuntu-xenial-621.192.tgz Using environment '10.0.0.5' as client 'ops_manager' [-----------------------------------------------------------------] 100.00% 0s Task 125 Task 125 | 15:14:26 | Extracting release: Extracting release (00:00:00) Task 125 | 15:14:26 | Verifying manifest: Verifying manifest (00:00:00) Task 125 | 15:14:26 | Resolving package dependencies: Resolving package dependencies (00:00:00) Task 125 | 15:14:26 | Processing 8 existing jobs: Processing 8 existing jobs (00:00:00) Task 125 | 15:14:26 | Compiled Release has been created: pxc/0.39.0 (00:00:00) Task 125 Started Tue Jan 25 15:14:26 UTC 2022 Task 125 Finished Tue Jan 25 15:14:26 UTC 2022 Task 125 Duration 00:00:00 Task 125 done Succeeded ubuntu@lighttaupe-ops-manager:~$ bosh upload-release file:///var/tempest/releases/pxc-0.39.0-ubuntu-xenial-621.192.tgz --version 0.39.0 --name pxc Using environment '10.0.0.5' as client 'ops_manager' Release 'pxc/0.39.0' already exists. Succeeded ``` Signed-off-by: Long Nguyen --- cmd/upload_release.go | 2 +- cmd/upload_release_test.go | 19 +++++++++++++++++++ integration/upload_release_test.go | 4 ++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/cmd/upload_release.go b/cmd/upload_release.go index 42caa5aed..6f7d08a72 100644 --- a/cmd/upload_release.go +++ b/cmd/upload_release.go @@ -49,7 +49,7 @@ func NewUploadReleaseCmd( func (c UploadReleaseCmd) Run(opts UploadReleaseOpts) error { switch { case opts.Release != nil: - return c.uploadRelease(opts.Release, opts) + return c.uploadIfNecessary(opts, c.uploadFile) case opts.Args.URL.IsRemote(): return c.uploadIfNecessary(opts, c.uploadRemote) case opts.Args.URL.IsGit(): diff --git a/cmd/upload_release_test.go b/cmd/upload_release_test.go index 97989afb0..9478062c8 100644 --- a/cmd/upload_release_test.go +++ b/cmd/upload_release_test.go @@ -276,6 +276,25 @@ var _ = Describe("UploadReleaseCmd", func() { Expect(rebase).To(BeFalse()) Expect(fix).To(BeFalse()) }) + It("does not upload release if name and version match existing release", func() { + releaseReader.ReadStub = func(path string) (boshrel.Release, error) { + Expect(path).To(Equal("./some-file.tgz")) + return release, nil + } + opts.Name = "existing-name" + opts.Version = VersionArg(semver.MustNewVersionFromString("existing-ver")) + director.HasReleaseReturns(true, nil) + err := act() + Expect(err).ToNot(HaveOccurred()) + + name, version, stemcell := director.HasReleaseArgsForCall(0) + Expect(name).To(Equal("existing-name")) + Expect(version).To(Equal("existing-ver")) + Expect(stemcell).To(Equal(boshdir.OSVersionSlug{})) + Expect(director.UploadReleaseFileCallCount()).To(Equal(0)) + Expect(ui.Said).To(Equal( + []string{"Release 'existing-name/existing-ver' already exists."})) + }) It("clean up release", func() { releaseReader.ReadStub = func(path string) (boshrel.Release, error) { diff --git a/integration/upload_release_test.go b/integration/upload_release_test.go index ae15a13d1..5ab92cb68 100644 --- a/integration/upload_release_test.go +++ b/integration/upload_release_test.go @@ -240,6 +240,10 @@ blobstore: ghttp.VerifyRequest("GET", "/info"), ghttp.RespondWith(http.StatusOK, `{"user_authentication":{"type":"basic","options":{}}}`), ), + ghttp.CombineHandlers( + ghttp.VerifyRequest("GET", "/releases"), + ghttp.RespondWith(http.StatusOK, "[]"), + ), ghttp.CombineHandlers( ghttp.VerifyRequest("POST", "/packages/matches"), ghttp.RespondWith(http.StatusOK, "[]"),