-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fail when package architecture doesn't match cluster architecture (#1495
) ## Description Fail `zarf init` and `zarf package deploy` when package architecture doesn't match cluster architecture Deployment scenarios that this PR covers: - If `zarf init` is ran in appliance mode(deploying k3s), verify that the package architecture matches the machine that zarf is attempting to initialize with a k3s cluster - If `zarf init` or `zarf package deploy` is ran, verify that the package architecture matches the target cluster architecture ## Related Issue Fixes #1491 Relates to #955 ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) ## Checklist before merging - [x] Test, docs, adr added or updated as needed - [x] [Contributor Guide Steps](https://github.com/defenseunicorns/zarf/blob/main/CONTRIBUTING.md#developer-workflow) followed --------- Co-authored-by: Wayne Starr <[email protected]>
- Loading branch information
1 parent
5fcdc3c
commit 84fb520
Showing
11 changed files
with
126 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-FileCopyrightText: 2021-Present The Zarf Authors | ||
|
||
// Package test provides e2e tests for Zarf. | ||
package test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// TestMismatchedArchitectures ensures that zarf produces an error | ||
// when the package architecture doesn't match the target cluster architecture. | ||
func TestMismatchedArchitectures(t *testing.T) { | ||
t.Log("E2E: Mismatched architectures") | ||
e2e.SetupWithCluster(t) | ||
defer e2e.Teardown(t) | ||
|
||
var ( | ||
mismatchedArch = e2e.GetMismatchedArch() | ||
mismatchedGamesPackage = fmt.Sprintf("zarf-package-dos-games-%s.tar.zst", mismatchedArch) | ||
initPackageVersion = "UnknownVersion" | ||
mismatchedInitPackage = fmt.Sprintf("zarf-init-%s-%s.tar.zst", mismatchedArch, initPackageVersion) | ||
expectedErrorMessage = fmt.Sprintf("this package architecture is %s", mismatchedArch) | ||
) | ||
|
||
// Build init package with different arch than the cluster arch. | ||
stdOut, stdErr, err := e2e.ExecZarfCommand("package", "create", ".", "--architecture", mismatchedArch, "--confirm") | ||
require.NoError(t, err, stdOut, stdErr) | ||
defer e2e.CleanFiles(mismatchedInitPackage) | ||
|
||
// Build dos-games package with different arch than the cluster arch. | ||
stdOut, stdErr, err = e2e.ExecZarfCommand("package", "create", "examples/dos-games/", "--architecture", mismatchedArch, "--confirm") | ||
require.NoError(t, err, stdOut, stdErr) | ||
defer e2e.CleanFiles(mismatchedGamesPackage) | ||
|
||
// Ensure zarf init returns an error because of the mismatched architectures. | ||
// We need to use the --architecture flag here to force zarf to find the package. | ||
_, stdErr, err = e2e.ExecZarfCommand("init", "--architecture", mismatchedArch, "--confirm") | ||
require.Error(t, err, stdErr) | ||
require.Contains(t, stdErr, expectedErrorMessage) | ||
|
||
// Ensure zarf package deploy returns an error because of the mismatched architectures. | ||
_, stdErr, err = e2e.ExecZarfCommand("package", "deploy", mismatchedGamesPackage, "--confirm") | ||
require.Error(t, err, stdErr) | ||
require.Contains(t, stdErr, expectedErrorMessage) | ||
} |