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

chore: Use script to generate local module template with release meta #2054

Merged
merged 44 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
cd68c3e
use script to generate local module template with release meta
ruanxin Nov 22, 2024
13d71a7
update modulectl version
ruanxin Nov 22, 2024
1d5dd46
cp script to working directory
ruanxin Nov 24, 2024
98ea593
add module version
ruanxin Nov 25, 2024
b02914a
update test version
ruanxin Nov 25, 2024
61efe44
configure default cr
ruanxin Nov 25, 2024
3bfb6ab
Merge remote-tracking branch 'upstream/main' into update-moduetemplate
ruanxin Nov 25, 2024
8b20d1e
fix action
ruanxin Nov 25, 2024
5428422
cleanup yaml file
ruanxin Nov 25, 2024
5170b42
remove test
ruanxin Nov 25, 2024
1a187f0
add generate_modulereleasemeta.sh
ruanxin Nov 25, 2024
0e5f58e
introduce module version as input
ruanxin Nov 25, 2024
ff38963
display resource yaml
ruanxin Nov 25, 2024
6320f81
extract more env value
ruanxin Nov 25, 2024
bf9608d
apply moduletemplate before all tests
ruanxin Nov 25, 2024
23fb985
apply moduletemplate before all tests
ruanxin Nov 25, 2024
801b34a
apply moduletemplate before all tests
ruanxin Nov 25, 2024
e834835
separate upgrade test
ruanxin Nov 25, 2024
adf8666
fix test
ruanxin Nov 25, 2024
baf18ed
fix test
ruanxin Nov 25, 2024
fd6014f
fix test
ruanxin Nov 25, 2024
dc03b09
fix test
ruanxin Nov 25, 2024
ee465d5
fix test
ruanxin Nov 25, 2024
09a4c94
fix test
ruanxin Nov 25, 2024
9820ec3
fix lint
ruanxin Nov 26, 2024
97fcd31
display all moduletemplates
ruanxin Nov 26, 2024
b408fc8
debug kyma
ruanxin Nov 26, 2024
303492e
debug kyma
ruanxin Nov 26, 2024
cabfe6f
log kyma, manifest
ruanxin Nov 26, 2024
446ffd6
log kyma, manifest
ruanxin Nov 26, 2024
7c0e79e
Merge remote-tracking branch 'upstream/main' into update-moduetemplate
ruanxin Nov 26, 2024
afda7cb
fix manager state in Error but is not caught
ruanxin Nov 26, 2024
05618b9
refactor manager state update logic
ruanxin Nov 26, 2024
78218a8
revert manifest state update logic
ruanxin Nov 26, 2024
bb61210
modify generated raw manifest so that make kustomize config immutable…
ruanxin Nov 26, 2024
d61c326
fix moduletemplate yq patch
ruanxin Nov 27, 2024
ef268d3
Merge branch 'main' into update-moduetemplate
ruanxin Nov 27, 2024
d934e3f
Update .github/scripts/release/generate_moduletemplate.sh
ruanxin Nov 27, 2024
4274f17
rename scripts
ruanxin Nov 27, 2024
7c1e439
Merge remote-tracking branch 'origin/update-moduetemplate' into updat…
ruanxin Nov 27, 2024
2bb19e5
Update .github/actions/deploy-template-operator-with-modulereleasemet…
ruanxin Nov 27, 2024
ed1d51a
Update .github/actions/get-configuration/action.yml
ruanxin Nov 27, 2024
430cd45
refactor log instance
ruanxin Nov 27, 2024
93dc8d0
Merge remote-tracking branch 'origin/update-moduetemplate' into updat…
ruanxin Nov 27, 2024
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

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .github/actions/get-configuration/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ runs:
echo "k8s_version=${{ github.event.inputs.k8s_version || '1.30.3' }}" >> $GITHUB_OUTPUT
echo "istio_version=1.20.3" >> $GITHUB_OUTPUT
echo "k3d_version=5.7.4" >> $GITHUB_OUTPUT
echo "modulectl_version=1.1.1" >> $GITHUB_OUTPUT
echo "modulectl_version=1.1.3" >> $GITHUB_OUTPUT
echo "cert_manager_version=1.15.0" >> $GITHUB_OUTPUT
echo "klm_version_tag=PR-${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
echo "klm_image_repo=dev" >> $GITHUB_OUTPUT
Expand Down
34 changes: 34 additions & 0 deletions .github/scripts/release/deploy_modulereleasemeta.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
set -o nounset
set -o errexit
set -E
set -o pipefail

MODULE_NAME=$1
shift 1
CHANNELS=("$@")
cat <<EOF > module-release-meta.yaml
apiVersion: operator.kyma-project.io/v1beta2
kind: ModuleReleaseMeta
metadata:
name: ${MODULE_NAME}
namespace: kcp-system
spec:
moduleName: ${MODULE_NAME}
channels:
EOF

for CHANNEL in "${CHANNELS[@]}"; do
IFS=':' read -r CHANNEL_NAME CHANNEL_VERSION <<< "${CHANNEL}"
cat <<EOF >> module-release-meta.yaml
- channel: ${CHANNEL_NAME}
version: ${CHANNEL_VERSION}
EOF
done
kubectl apply -f module-release-meta.yaml

echo "ModuleReleaseMeta created successfully"
rm -f module-release-meta.yaml

kubectl get modulereleasemeta "${MODULE_NAME}" -n kcp-system -o yaml
kubectl get moduletemplate -n kcp-system
41 changes: 41 additions & 0 deletions .github/scripts/release/deploy_moduletemplate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
set -o nounset
set -o errexit
set -E
set -o pipefail

MODULE_NAME=$1
RELEASE_VERSION=$2
INCLUDE_DEFAULT_CR=${3:-true}

cat <<EOF > module-config-for-e2e.yaml
name: kyma-project.io/module/${MODULE_NAME}
version: ${RELEASE_VERSION}
security: sec-scanners-config.yaml
manifest: https://localhost:8080/template-operator.yaml
repository: https://github.com/kyma-project/template-operator
documentation: https://github.com/kyma-project/template-operator/blob/main/README.md
icons:
- name: module-icon
link: https://github.com/kyma-project/template-operator/blob/main/docs/assets/logo.png
EOF

if [ "${INCLUDE_DEFAULT_CR}" == "true" ]; then
cat <<EOF >> module-config-for-e2e.yaml
defaultCR: https://localhost:8080/config/samples/default-sample-cr.yaml
EOF
fi

cat module-config-for-e2e.yaml
modulectl create --config-file ./module-config-for-e2e.yaml --registry http://localhost:5111 --insecure
sed -i 's/localhost:5111/k3d-kcp-registry.localhost:5000/g' ./template.yaml
kubectl apply -f template.yaml

cat template.yaml
echo "ModuleTemplate created successfully"

rm -f module-config-for-e2e.yaml
rm -f template-operator.yaml
rm -f template.yaml
rm -f default-sample-cr.yaml
echo "Temporary files removed successfully"
19 changes: 15 additions & 4 deletions .github/workflows/test-e2e-with-modulereleasemeta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ jobs:
- module-without-default-cr
- module-consistency
- non-blocking-deletion
- upgrade-under-deletion
- modulereleasemeta-upgrade-under-deletion
- purge-controller
- purge-metrics
- module-upgrade-channel-switch
- module-upgrade-new-version
- modulereleasemeta-module-upgrade-new-version
- unmanage-module
- skip-manifest-reconciliation
- ca-certificate-rotation
Expand All @@ -55,7 +55,6 @@ jobs:
- mandatory-module-metrics
- misconfigured-kyma-secret
- rbac-privileges
- ocm-compatible-module-template
- modulereleasemeta-with-obsolete-moduletemplate
- modulereleasemeta-sync
- modulereleasemeta-watch-trigger
Expand Down Expand Up @@ -102,7 +101,19 @@ jobs:

- name: Deploy template-operator
uses: ./lifecycle-manager/.github/actions/deploy-template-operator-with-modulereleasemeta

env:
ModuleDeploymentName: template-operator-controller-manager
ModuleDeploymentNameInNewerVersion: template-operator-v2-controller-manager
ModuleDeploymentNameInOlderVersion: template-operator-v1-controller-manager
NewerVersion: 2.4.2-e2e-test
OlderVersion: 1.1.1-e2e-test
VersionForStatefulSetInWarning: 1.0.0-warning-statefulset
VersionForDeploymentInWarning: 1.0.0-warning-deployment
VersionForMisconfiguredDeploymentImage: 1.0.0-misconfigured-deployment
VersionForMisconfiguredStatefulSetImage: 1.0.0-misconfigured-statefulset
VersionForNoDefaultCR: 1.0.0-no-default-cr
MisconfiguredModuleName: template-operator-misconfigured
ModuleName: template-operator
- name: Run '${{ matrix.e2e-test }}' test
working-directory: lifecycle-manager
run: |
Expand Down
11 changes: 8 additions & 3 deletions internal/declarative/v2/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ import (
"github.com/kyma-project/lifecycle-manager/pkg/util"
)

var ErrResourceSyncDiffInSameOCILayer = errors.New("resource syncTarget diff detected but in " +
"same oci layer, prevent sync resource to be deleted")
var (
ErrManagerInErrorState = errors.New("manager is in error state")
ErrResourceSyncDiffInSameOCILayer = errors.New("resource syncTarget diff detected but in " +
"same oci layer, prevent sync resource to be deleted")
)

const (
namespaceNotBeRemoved = "kyma-system"
Expand Down Expand Up @@ -376,7 +379,9 @@ func (r *Reconciler) checkManagerState(ctx context.Context, clnt Client, target
if err != nil {
return shared.StateError, err
}

if managerState == shared.StateError {
return shared.StateError, ErrManagerInErrorState
}
return managerState, nil
}

Expand Down
9 changes: 4 additions & 5 deletions pkg/testutils/modulereleasemeta.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@ import (

var ErrNotExpectedChannelVersion = errors.New("channel-version pair not found")

func UpdateChannelVersionIfModuleReleaseMetaExists(ctx context.Context, clnt client.Client,
func UpdateChannelVersionInModuleReleaseMeta(ctx context.Context, clnt client.Client,
moduleName, namespace, channel, version string,
) error {
mrm, err := GetModuleReleaseMeta(ctx, moduleName, namespace, clnt)
if err != nil {
if util.IsNotFound(err) {
return nil
}
return fmt.Errorf("get module release meta: %w", err)
}

Expand Down Expand Up @@ -105,7 +102,9 @@ func DeleteModuleReleaseMeta(ctx context.Context, moduleName, namespace string,
return nil
}

func UpdateAllModuleReleaseMetaChannelVersions(ctx context.Context, client client.Client, namespace, name, version string) error {
func UpdateAllModuleReleaseMetaChannelVersions(ctx context.Context, client client.Client,
namespace, name, version string,
) error {
meta := &v1beta2.ModuleReleaseMeta{}
if err := client.Get(ctx, types.NamespacedName{Namespace: namespace, Name: name}, meta); err != nil {
return err
Expand Down
28 changes: 6 additions & 22 deletions tests/e2e/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,28 +67,6 @@ e2e-coverage: ginkgo ## Generate the effective Acceptance Criteria for all the t

##@ E2E Tests

test: kyma-deprovision-with-foreground-propagation \
kyma-deprovision-with-background-propagation \
kyma-metrics \
mandatory-module-metrics \
watcher-enqueue \
module-status-decoupling-with-deployment \
module-status-decoupling-with-statefulset \
module-without-default-cr \
module-consistency \
mandatory-module \
non-blocking-deletion \
skip-manifest-reconciliation \
upgrade-under-deletion \
purge-controller \
purge-metrics \
module-upgrade-channel-switch \
module-upgrade-new-version \
module-install-by-version \
ca-certificate-rotation \
self-signed-certificate-rotation \
misconfigured-kyma-secret

kyma-deprovision-with-foreground-propagation:
go test -timeout 20m -ginkgo.v -ginkgo.focus "KCP Kyma CR Deprovision With Foreground Propagation After SKR Cluster Removal"

Expand Down Expand Up @@ -128,6 +106,9 @@ skip-manifest-reconciliation:
upgrade-under-deletion:
go test -timeout 20m -ginkgo.v -ginkgo.focus "Kyma Module Upgrade Under Deletion"

modulereleasemeta-upgrade-under-deletion:
go test -timeout 20m -ginkgo.v -ginkgo.focus "Kyma Module with ModuleReleaseMeta Upgrade Under Deletion"

unmanage-module:
go test -timeout 20m -ginkgo.v -ginkgo.focus "Unmanaging Kyma Module"

Expand All @@ -143,6 +124,9 @@ module-upgrade-channel-switch:
module-upgrade-new-version:
go test -timeout 20m -ginkgo.v -ginkgo.focus "Module Upgrade By New Version"

modulereleasemeta-module-upgrade-new-version:
go test -timeout 20m -ginkgo.v -ginkgo.focus "Module with ModuleReleaseMeta Upgrade By New Version"

module-install-by-version:
go test -timeout 20m -ginkgo.v -ginkgo.focus "Module Install By Version"

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/mandatory_module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ var _ = Describe("Mandatory Module Installation and Deletion", Ordered, func() {
WithContext(ctx).
WithArguments(skrClient, defaultRemoteKymaName, RemoteNamespace, v1beta2.Module{
Name: TestModuleName,
Channel: "regular",
Channel: v1beta2.DefaultChannel,
Managed: true,
}).
Should(Succeed())
Expand Down
5 changes: 2 additions & 3 deletions tests/e2e/mandatory_modules_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ var _ = Describe("Mandatory Module Metrics", Ordered, func() {
CleanupKymaAfterAll(kyma)

Context("Given SKR Cluster", func() {
const deployName = "template-operator-v1-controller-manager"
It("Then mandatory module is installed on the SKR cluster", func() {
Eventually(DeploymentIsReady).
WithContext(ctx).
WithArguments(skrClient, deployName,
WithArguments(skrClient, ModuleDeploymentNameInOlderVersion,
TestModuleResourceNamespace).
Should(Succeed())
By("And the SKR Module Default CR is in a \"Ready\" State", func() {
Expand Down Expand Up @@ -68,7 +67,7 @@ var _ = Describe("Mandatory Module Metrics", Ordered, func() {
It("Then mandatory SKR module is removed", func() {
Eventually(DeploymentIsReady).
WithContext(ctx).
WithArguments(skrClient, deployName,
WithArguments(skrClient, ModuleDeploymentNameInOlderVersion,
TestModuleResourceNamespace).
Should(Equal(ErrNotFound))

Expand Down
6 changes: 0 additions & 6 deletions tests/e2e/module_deletion_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,6 @@ var _ = Describe("Kyma Module Upgrade Under Deletion", Ordered, func() {
out, err := cmd.CombinedOutput()
Expect(err).NotTo(HaveOccurred())
GinkgoWriter.Printf(string(out))

By("And ModuleReleaseMeta is updated if it exists")
Eventually(UpdateChannelVersionIfModuleReleaseMetaExists).
WithContext(ctx).
WithArguments(kcpClient, module.Name, ControlPlaneNamespace, v1beta2.DefaultChannel, "2.4.2-e2e-test").
Should(Succeed())
})

It("Then Kyma Module is updated on SKR Cluster", func() {
Expand Down
5 changes: 3 additions & 2 deletions tests/e2e/module_install_by_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

var _ = Describe("Module Install By Version", Ordered, func() {
kyma := NewKymaWithSyncLabel("kyma-sample", ControlPlaneNamespace, v1beta2.DefaultChannel)
templateOperatorModule := NewTemplateOperatorWithVersion("2.4.2-e2e-test")
templateOperatorModule := NewTemplateOperatorWithVersion(NewerVersion)
moduleCR := builder.NewModuleCRBuilder().
WithName("sample-2.4.2-e2e-test").
WithNamespace(RemoteNamespace).Build()
Expand Down Expand Up @@ -50,7 +50,8 @@ var _ = Describe("Module Install By Version", Ordered, func() {
By("And Module is in \"Ready\" State")
Eventually(CheckModuleState).
WithContext(ctx).
WithArguments(kcpClient, kyma.GetName(), kyma.GetNamespace(), templateOperatorModule.Name, shared.StateReady).
WithArguments(kcpClient, kyma.GetName(), kyma.GetNamespace(), templateOperatorModule.Name,
shared.StateReady).
Should(Succeed())
})
})
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/module_status_decoupling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const (
func RunModuleStatusDecouplingTest(resourceKind ResourceKind) {
kyma := NewKymaWithSyncLabel("kyma-sample", ControlPlaneNamespace, v1beta2.DefaultChannel)
module := NewTemplateOperator(v1beta2.DefaultChannel)
moduleWrongConfig := NewTestModuleWithFixName("template-operator-misconfigured", "regular", "")
moduleWrongConfig := NewTestModuleWithFixName(MisconfiguredModuleName, v1beta2.DefaultChannel, "")
moduleCR := NewTestModuleCR(RemoteNamespace)
InitEmptyKymaBeforeAll(kyma)
CleanupKymaAfterAll(kyma)
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/module_upgrade_channel_switch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ var _ = Describe("Module Upgrade By Channel Switch", Ordered, func() {
It("When downgrade version by switch Channel", func() {
Eventually(UpdateKymaModuleChannel).
WithContext(ctx).
WithArguments(skrClient, defaultRemoteKymaName, RemoteNamespace, "regular").
WithArguments(skrClient, defaultRemoteKymaName, RemoteNamespace, v1beta2.DefaultChannel).
Should(Succeed())
})

Expand Down
8 changes: 1 addition & 7 deletions tests/e2e/module_upgrade_new_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,8 @@ var _ = Describe("Module Upgrade By New Version", Ordered, func() {
kcpClient,
newTemplateFilePath)).
Should(Succeed())

By("And ModuleReleaseMeta is updated if it exists")
Eventually(UpdateChannelVersionIfModuleReleaseMetaExists).
WithContext(ctx).
WithArguments(kcpClient, module.Name, ControlPlaneNamespace, v1beta2.DefaultChannel, "2.4.2-e2e-test").
Should(Succeed())
})

//nolint:dupl //this test will be deleted during this issue https://github.com/kyma-project/lifecycle-manager/issues/2060
It("Then Module CR exists", func() {
Eventually(ModuleCRExists).
WithContext(ctx).
Expand Down
Loading
Loading