Skip to content

Commit 3c98dc6

Browse files
author
Craig O'Donnell
committed
wip: don't overwrite installation after copying images
1 parent f9cc4b5 commit 3c98dc6

File tree

10 files changed

+31
-35
lines changed

10 files changed

+31
-35
lines changed

cmd/kots/cli/admin-console-push-images.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func AdminPushImagesCmd() *cobra.Command {
5454
}
5555

5656
if _, err := os.Stat(imageSource); err == nil {
57-
_, err = image.TagAndPushImagesFromBundle(imageSource, *options)
57+
err = image.TagAndPushImagesFromBundle(imageSource, *options)
5858
if err != nil {
5959
return errors.Wrap(err, "failed to push images")
6060
}

pkg/airgap/update.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ func UpdateAppFromPath(a *apptypes.App, airgapRoot string, airgapBundlePath stri
6969
return errors.Wrap(err, "failed to find airgap meta")
7070
}
7171

72+
fmt.Printf("***** UpdateAppFromPath found airgap metadata: %+v\n", airgap)
73+
7274
missingPrereqs, err := GetMissingRequiredVersions(a, airgap)
7375
if err != nil {
7476
return errors.Wrapf(err, "failed to check required versions")

pkg/image/airgap.go

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ func WriteProgressLine(progressWriter io.Writer, line string) {
108108
}
109109

110110
// CopyAirgapImages pushes images found in the airgap bundle/airgap root to the configured registry.
111-
func CopyAirgapImages(opts imagetypes.ProcessImageOptions, log *logger.CLILogger) (*imagetypes.CopyAirgapImagesResult, error) {
111+
func CopyAirgapImages(opts imagetypes.ProcessImageOptions, log *logger.CLILogger) error {
112112
if opts.AirgapBundle == "" {
113-
return &imagetypes.CopyAirgapImagesResult{}, nil
113+
return nil
114114
}
115115

116116
pushOpts := imagetypes.PushImagesOptions{
@@ -125,27 +125,25 @@ func CopyAirgapImages(opts imagetypes.ProcessImageOptions, log *logger.CLILogger
125125
LogForUI: true,
126126
}
127127

128-
copyResult, err := TagAndPushImagesFromBundle(opts.AirgapBundle, pushOpts)
128+
err := TagAndPushImagesFromBundle(opts.AirgapBundle, pushOpts)
129129
if err != nil {
130-
return nil, errors.Wrap(err, "failed to push images from bundle")
130+
return errors.Wrap(err, "failed to push images from bundle")
131131
}
132132

133-
return &imagetypes.CopyAirgapImagesResult{
134-
EmbeddedClusterArtifacts: copyResult.EmbeddedClusterArtifacts,
135-
}, nil
133+
return nil
136134
}
137135

138-
func TagAndPushImagesFromBundle(airgapBundle string, options imagetypes.PushImagesOptions) (*imagetypes.CopyAirgapImagesResult, error) {
136+
func TagAndPushImagesFromBundle(airgapBundle string, options imagetypes.PushImagesOptions) error {
139137
airgap, err := kotsutil.FindAirgapMetaInBundle(airgapBundle)
140138
if err != nil {
141-
return nil, errors.Wrap(err, "failed to find airgap meta")
139+
return errors.Wrap(err, "failed to find airgap meta")
142140
}
143141

144142
switch airgap.Spec.Format {
145143
case dockertypes.FormatDockerRegistry:
146144
extractedBundle, err := os.MkdirTemp("", "extracted-airgap-kots")
147145
if err != nil {
148-
return nil, errors.Wrap(err, "failed to create temp dir for unarchived airgap bundle")
146+
return errors.Wrap(err, "failed to create temp dir for unarchived airgap bundle")
149147
}
150148
defer os.RemoveAll(extractedBundle)
151149

@@ -155,34 +153,30 @@ func TagAndPushImagesFromBundle(airgapBundle string, options imagetypes.PushImag
155153
},
156154
}
157155
if err := tarGz.Unarchive(airgapBundle, extractedBundle); err != nil {
158-
return nil, errors.Wrap(err, "falied to unarchive airgap bundle")
156+
return errors.Wrap(err, "falied to unarchive airgap bundle")
159157
}
160158
if err := PushImagesFromTempRegistry(extractedBundle, airgap.Spec.SavedImages, options); err != nil {
161-
return nil, errors.Wrap(err, "failed to push images from docker registry bundle")
159+
return errors.Wrap(err, "failed to push images from docker registry bundle")
162160
}
163161
case dockertypes.FormatDockerArchive, "":
164162
if err := PushImagesFromDockerArchiveBundle(airgapBundle, options); err != nil {
165-
return nil, errors.Wrap(err, "failed to push images from docker archive bundle")
163+
return errors.Wrap(err, "failed to push images from docker archive bundle")
166164
}
167165
default:
168-
return nil, errors.Errorf("Airgap bundle format '%s' is not supported", airgap.Spec.Format)
166+
return errors.Errorf("Airgap bundle format '%s' is not supported", airgap.Spec.Format)
169167
}
170168

171169
pushEmbeddedArtifactsOpts := imagetypes.PushEmbeddedClusterArtifactsOptions{
172170
Registry: options.Registry,
173171
Tag: imageutil.SanitizeTag(fmt.Sprintf("%s-%s-%s", airgap.Spec.ChannelID, airgap.Spec.UpdateCursor, airgap.Spec.VersionLabel)),
174172
HTTPClient: orasretry.DefaultClient,
175173
}
176-
pushedArtifacts, err := PushEmbeddedClusterArtifacts(airgapBundle, pushEmbeddedArtifactsOpts)
174+
_, err = PushEmbeddedClusterArtifacts(airgapBundle, pushEmbeddedArtifactsOpts)
177175
if err != nil {
178-
return nil, errors.Wrap(err, "failed to push embedded cluster artifacts")
176+
return errors.Wrap(err, "failed to push embedded cluster artifacts")
179177
}
180178

181-
result := &imagetypes.CopyAirgapImagesResult{
182-
EmbeddedClusterArtifacts: pushedArtifacts,
183-
}
184-
185-
return result, nil
179+
return nil
186180
}
187181

188182
func PushImagesFromTempRegistry(airgapRootDir string, imageList []string, options imagetypes.PushImagesOptions) error {

pkg/kotsadm/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func Deploy(deployOptions types.DeployOptions, log *logger.CLILogger) error {
164164
}
165165

166166
if !deployOptions.DisableImagePush {
167-
_, err := image.TagAndPushImagesFromBundle(deployOptions.AirgapBundle, pushOptions)
167+
err := image.TagAndPushImagesFromBundle(deployOptions.AirgapBundle, pushOptions)
168168
if err != nil {
169169
return errors.Wrap(err, "failed to tag and push app images from path")
170170
}

pkg/midstream/write.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,18 +112,10 @@ func WriteMidstream(opts WriteOptions) (*Midstream, error) {
112112
io.WriteString(opts.ProcessImageOptions.ReportWriter, "Copying images\n")
113113

114114
if opts.ProcessImageOptions.IsAirgap {
115-
copyResult, err := image.CopyAirgapImages(opts.ProcessImageOptions, opts.Log)
115+
err := image.CopyAirgapImages(opts.ProcessImageOptions, opts.Log)
116116
if err != nil {
117117
return nil, errors.Wrap(err, "failed to copy airgap images")
118118
}
119-
120-
if err := image.UpdateInstallationEmbeddedClusterArtifacts(image.UpdateInstallationEmbeddedClusterArtifactsOptions{
121-
Artifacts: copyResult.EmbeddedClusterArtifacts,
122-
KotsKinds: opts.KotsKinds,
123-
UpstreamDir: opts.UpstreamDir,
124-
}); err != nil {
125-
return nil, errors.Wrap(err, "failed to update installation airgap artifacts")
126-
}
127119
} else {
128120
err := image.CopyOnlineImages(opts.ProcessImageOptions, allImages, opts.KotsKinds, opts.License, dockerHubRegistryCreds, opts.Log)
129121
if err != nil {

pkg/pull/pull.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ func Pull(upstreamURI string, pullOptions PullOptions) (string, error) {
231231
return "", errors.Wrap(err, "failed to find airgap meta")
232232
}
233233

234+
fmt.Printf("****** Pull airgap metadata: %+v\n", airgap)
235+
234236
if fetchOptions.AppVersionLabel != "" && fetchOptions.AppVersionLabel != airgap.Spec.VersionLabel {
235237
logger.Infof("Expecting to install version %s but airgap bundle version is %s.", fetchOptions.AppVersionLabel, airgap.Spec.VersionLabel)
236238
}
@@ -365,7 +367,7 @@ func Pull(upstreamURI string, pullOptions PullOptions) (string, error) {
365367
}
366368
if processImageOptions.RewriteImages && processImageOptions.IsAirgap {
367369
// if this is an airgap install, we still need to process the images
368-
if _, err := image.CopyAirgapImages(processImageOptions, log); err != nil {
370+
if err := image.CopyAirgapImages(processImageOptions, log); err != nil {
369371
return "", errors.Wrap(err, "failed to copy airgap images")
370372
}
371373
}

pkg/upstream/fetch.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package upstream
22

33
import (
4+
"fmt"
45
"net/url"
56

67
"github.com/pkg/errors"
@@ -122,6 +123,7 @@ func pickReplicatedChartNames(fetchOptions *types.FetchOptions) []string {
122123
}
123124

124125
func pickEmbeddedClusterArtifacts(fetchOptions *types.FetchOptions) []string {
126+
fmt.Printf("*** fetchOptions.Airgap: %+v\n", fetchOptions.Airgap)
125127
if fetchOptions.Airgap != nil {
126128
if fetchOptions.Airgap.Spec.EmbeddedClusterArtifacts == nil {
127129
return nil

pkg/upstream/replicated.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ func downloadReplicated(
186186

187187
release = downloadedRelease
188188
}
189+
fmt.Printf("**** Release: %+v\n", release)
189190

190191
application := findAppInRelease(release) // this function never returns nil
191192

@@ -301,8 +302,9 @@ func downloadReplicated(
301302
ReplicatedRegistryDomain: release.ReplicatedRegistryDomain,
302303
ReplicatedProxyDomain: release.ReplicatedProxyDomain,
303304
ReplicatedChartNames: release.ReplicatedChartNames,
304-
EmbeddedClusterArtifacts: embeddedClusterArtifacts,
305+
EmbeddedClusterArtifacts: release.EmbeddedClusterArtifacts,
305306
}
307+
fmt.Printf("**** Upstream: %+v\n", upstream)
306308

307309
return upstream, nil
308310
}

pkg/upstream/upgrade.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func Upgrade(appSlug string, options UpgradeOptions) (*UpgradeResponse, error) {
6969
}
7070

7171
if !options.DisableImagePush {
72-
_, err := image.TagAndPushImagesFromBundle(options.AirgapBundle, pushOptions)
72+
err := image.TagAndPushImagesFromBundle(options.AirgapBundle, pushOptions)
7373
if err != nil {
7474
return nil, errors.Wrap(err, "failed to tag and push app images from path")
7575
}

pkg/upstream/write.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package upstream
33
import (
44
"bytes"
55
"encoding/base64"
6+
"fmt"
67
"os"
78
"path"
89

@@ -158,6 +159,7 @@ func WriteUpstream(u *types.Upstream, options types.WriteOptions) error {
158159
}
159160

160161
installationBytes := kotsutil.MustMarshalInstallation(&installation)
162+
fmt.Printf("** WriteUpstream installation: %s\n", installationBytes)
161163

162164
u.Files = append(u.Files, types.UpstreamFile{
163165
Path: "userdata/installation.yaml",

0 commit comments

Comments
 (0)