Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not process online images in airgap mode for v1beta2 Helm charts #4449

Merged
merged 4 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/airgap/airgap.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ func CreateAppFromAirgap(opts CreateAirgapAppOpts) (finalError error) {
LicenseFile: licenseFile.Name(),
ConfigFile: configFile,
IdentityConfigFile: identityConfigFile,
IsAirgap: true,
AirgapRoot: archiveDir,
AirgapBundle: airgapBundle,
Silent: !opts.IsAutomated,
Expand Down
1 change: 1 addition & 0 deletions pkg/airgap/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ func UpdateAppFromPath(a *apptypes.App, airgapRoot string, airgapBundlePath stri
Namespace: appNamespace,
ConfigFile: filepath.Join(archiveDir, "upstream", "userdata", "config.yaml"),
IdentityConfigFile: identityConfigFile,
IsAirgap: true,
AirgapRoot: airgapRoot,
AirgapBundle: airgapBundlePath,
InstallationFile: filepath.Join(archiveDir, "upstream", "userdata", "installation.yaml"),
Expand Down
2 changes: 1 addition & 1 deletion pkg/apparchive/helm-v1beta2.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func WriteV1Beta2HelmCharts(opts WriteV1Beta2HelmChartsOptions) error {
return errors.Wrap(err, "failed to write values file")
}

if !opts.ProcessImageOptions.RewriteImages || opts.ProcessImageOptions.AirgapRoot != "" {
if !opts.ProcessImageOptions.RewriteImages || opts.ProcessImageOptions.IsAirgap {
// if an on-prem registry is not configured (which means it's an online installation)
// there's no need to process/copy the images as they will be pulled from their original registries or through the replicated proxy.
// if an on-prem registry is configured, but it's an airgap installation, we also don't need to process/copy the images
Expand Down
2 changes: 1 addition & 1 deletion pkg/image/airgap.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func CopyAirgapImages(opts imagetypes.ProcessImageOptions, log *logger.CLILogger
if err != nil {
return errors.Wrap(err, "failed to push images from bundle")
}
} else {
} else if opts.AirgapRoot != "" {
err := TagAndPushImagesFromPath(opts.AirgapRoot, pushOpts)
if err != nil {
return errors.Wrap(err, "failed to push images from dir")
Expand Down
10 changes: 5 additions & 5 deletions pkg/midstream/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ func WriteMidstream(opts WriteOptions) (*Midstream, error) {
opts.Log.ActionWithSpinner("Copying images")
io.WriteString(opts.ProcessImageOptions.ReportWriter, "Copying images\n")

if opts.ProcessImageOptions.AirgapRoot == "" {
err := image.CopyOnlineImages(opts.ProcessImageOptions, allImages, opts.KotsKinds, opts.License, dockerHubRegistryCreds, opts.Log)
if opts.ProcessImageOptions.IsAirgap {
err := image.CopyAirgapImages(opts.ProcessImageOptions, opts.Log)
if err != nil {
return nil, errors.Wrap(err, "failed to copy online images")
return nil, errors.Wrap(err, "failed to copy airgap images")
}
} else {
err := image.CopyAirgapImages(opts.ProcessImageOptions, opts.Log)
err := image.CopyOnlineImages(opts.ProcessImageOptions, allImages, opts.KotsKinds, opts.License, dockerHubRegistryCreds, opts.Log)
if err != nil {
return nil, errors.Wrap(err, "failed to copy airgap images")
return nil, errors.Wrap(err, "failed to copy online images")
}
}
}
Expand Down
11 changes: 6 additions & 5 deletions pkg/pull/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type PullOptions struct {
LicenseFile string
LicenseEndpointOverride string // only used for testing
InstallationFile string
IsAirgap bool
AirgapRoot string
AirgapBundle string
ConfigFile string
Expand Down Expand Up @@ -295,7 +296,7 @@ func Pull(upstreamURI string, pullOptions PullOptions) (string, error) {
IsOpenShift: k8sutil.IsOpenShift(clientset),
IsGKEAutopilot: k8sutil.IsGKEAutopilot(clientset),
IncludeMinio: pullOptions.IncludeMinio,
IsAirgap: pullOptions.AirgapRoot != "",
IsAirgap: pullOptions.IsAirgap,
KotsadmID: k8sutil.GetKotsadmID(clientset),
AppID: pullOptions.AppID,
}
Expand All @@ -321,7 +322,7 @@ func Pull(upstreamURI string, pullOptions PullOptions) (string, error) {
Log: log,
AppSlug: pullOptions.AppSlug,
Sequence: pullOptions.AppSequence,
IsAirgap: pullOptions.AirgapRoot != "",
IsAirgap: pullOptions.IsAirgap,
}
log.ActionWithSpinner("Rendering KOTS custom resources")
io.WriteString(pullOptions.ReportWriter, "Rendering KOTS custom resources\n")
Expand All @@ -339,7 +340,7 @@ func Pull(upstreamURI string, pullOptions PullOptions) (string, error) {
}
log.FinishSpinner()

needsConfig, err := kotsadmconfig.NeedsConfiguration(pullOptions.AppSlug, pullOptions.AppSequence, pullOptions.AirgapRoot != "", renderedKotsKinds, registrySettings)
needsConfig, err := kotsadmconfig.NeedsConfiguration(pullOptions.AppSlug, pullOptions.AppSequence, pullOptions.IsAirgap, renderedKotsKinds, registrySettings)
if err != nil {
return "", errors.Wrap(err, "failed to check if version needs configuration")
}
Expand All @@ -351,7 +352,7 @@ func Pull(upstreamURI string, pullOptions PullOptions) (string, error) {
RegistrySettings: pullOptions.RewriteImageOptions,
CopyImages: !pullOptions.RewriteImageOptions.IsReadOnly,
RootDir: pullOptions.RootDir,
IsAirgap: pullOptions.AirgapRoot != "",
IsAirgap: pullOptions.IsAirgap,
AirgapRoot: pullOptions.AirgapRoot,
AirgapBundle: pullOptions.AirgapBundle,
CreateAppDir: pullOptions.CreateAppDir,
Expand All @@ -362,7 +363,7 @@ func Pull(upstreamURI string, pullOptions PullOptions) (string, error) {
if err := kotsutil.WriteKotsKinds(renderedKotsKindsMap, u.GetKotsKindsDir(writeUpstreamOptions)); err != nil {
return "", errors.Wrap(err, "failed to write the rendered kots kinds")
}
if processImageOptions.RewriteImages && processImageOptions.AirgapRoot != "" {
if processImageOptions.RewriteImages && processImageOptions.IsAirgap {
// if this is an airgap install, we still need to process the images
if err := image.CopyAirgapImages(processImageOptions, log); err != nil {
return "", errors.Wrap(err, "failed to copy airgap images")
Expand Down
1 change: 0 additions & 1 deletion pkg/tests/pull/cases/configcontext/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Name: test helm pull
PullOptions:
Namespace: app-namespace
ExcludeAdminConsole: true
IsAirgap: true
Silent: true
LocalPath: cases/configcontext/upstream
RootDir: cases/configcontext/results
Expand Down
1 change: 0 additions & 1 deletion pkg/tests/pull/cases/customhostnames/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Name: test custom hostnames
PullOptions:
Namespace: app-namespace
ExcludeAdminConsole: true
IsAirgap: true
Silent: true
LocalPath: cases/customhostnames/upstream
RootDir: cases/customhostnames/results
Expand Down
1 change: 0 additions & 1 deletion pkg/tests/pull/cases/kotskinds/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Name: test templating kots kinds
PullOptions:
Namespace: app-namespace
ExcludeAdminConsole: true
IsAirgap: true
Silent: true
LocalPath: cases/kotskinds/upstream
RootDir: cases/kotskinds/results
Expand Down
1 change: 0 additions & 1 deletion pkg/tests/pull/cases/multidoc/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Name: test multiple docs in a single file
PullOptions:
Namespace: app-namespace
ExcludeAdminConsole: true
IsAirgap: true
Silent: true
LocalPath: cases/multidoc/upstream
RootDir: cases/multidoc/results
Expand Down
1 change: 0 additions & 1 deletion pkg/tests/pull/cases/needsconfig/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Name: test pulling with unset required config items
PullOptions:
Namespace: app-namespace
ExcludeAdminConsole: true
IsAirgap: true
Silent: true
LocalPath: cases/needsconfig/upstream
RootDir: cases/needsconfig/results
Expand Down
1 change: 0 additions & 1 deletion pkg/tests/pull/cases/replicatedhelm/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Name: test replicated helm pull without rewrite
PullOptions:
Namespace: app-namespace
ExcludeAdminConsole: true
IsAirgap: true
Silent: true
LocalPath: cases/replicatedhelm/upstream
RootDir: cases/replicatedhelm/results
Expand Down
1 change: 0 additions & 1 deletion pkg/tests/pull/cases/samechartvariations/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Name: test deploying variations of same helm chart
PullOptions:
Namespace: app-namespace
ExcludeAdminConsole: true
IsAirgap: true
Silent: true
LocalPath: cases/samechartvariations/upstream
RootDir: cases/samechartvariations/results
Expand Down
1 change: 0 additions & 1 deletion pkg/tests/pull/cases/simple/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Name: test simple pull
PullOptions:
Namespace: app-namespace
ExcludeAdminConsole: true
IsAirgap: true
Silent: true
LocalPath: cases/simple/upstream
RootDir: cases/simple/results
Expand Down
1 change: 0 additions & 1 deletion pkg/tests/pull/cases/subchart-alias/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Name: subchart alias
PullOptions:
Namespace: app-namespace
ExcludeAdminConsole: true
IsAirgap: true
Silent: true
LocalPath: cases/subchart-alias/upstream
RootDir: cases/subchart-alias/results
Expand Down
1 change: 0 additions & 1 deletion pkg/tests/pull/cases/subchart-crds/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Name: test subchart crds
PullOptions:
Namespace: app-namespace
ExcludeAdminConsole: true
IsAirgap: true
Silent: true
LocalPath: cases/subchart-crds/upstream
RootDir: cases/subchart-crds/results
Expand Down
1 change: 0 additions & 1 deletion pkg/tests/pull/cases/subcharts/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Name: test subcharts pull
PullOptions:
Namespace: app-namespace
ExcludeAdminConsole: true
IsAirgap: true
Silent: true
LocalPath: cases/subcharts/upstream
RootDir: cases/subcharts/results
Expand Down
1 change: 0 additions & 1 deletion pkg/tests/pull/cases/taganddigest-norewrite/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Name: test tag and digest no rewrite
PullOptions:
Namespace: app-namespace
ExcludeAdminConsole: true
IsAirgap: true
Silent: true
LocalPath: cases/taganddigest-norewrite/upstream
RootDir: cases/taganddigest-norewrite/results
Expand Down
1 change: 0 additions & 1 deletion pkg/tests/pull/cases/taganddigest-rewrite/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Name: test tag and digest with rewrite
PullOptions:
Namespace: app-namespace
ExcludeAdminConsole: true
IsAirgap: true
Silent: true
LocalPath: cases/taganddigest-rewrite/upstream
RootDir: cases/taganddigest-rewrite/results
Expand Down
1 change: 0 additions & 1 deletion pkg/tests/pull/cases/v1beta2-charts/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Name: test v1beta2 charts
PullOptions:
Namespace: app-namespace
ExcludeAdminConsole: true
IsAirgap: true
Silent: true
LocalPath: cases/v1beta2-charts/upstream
RootDir: cases/v1beta2-charts/results
Expand Down
Loading