Skip to content

Commit

Permalink
Merge branch 'main' into docs/loca-test-setup-using-scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
c-pius authored Jan 20, 2025
2 parents dfaf36a + 9d7efc4 commit 9fd559b
Show file tree
Hide file tree
Showing 44 changed files with 917 additions and 303 deletions.
45 changes: 45 additions & 0 deletions .github/actions/deploy-lifecycle-manager-e2e/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,51 @@ runs:
cat certificate_renewal.yaml
kustomize edit add patch --path certificate_renewal.yaml --kind Certificate --group cert-manager.io --version v1 --name watcher-serving
popd
- name: Create and use maintenance window policy
if: ${{matrix.e2e-test == 'maintenance-window-with-module-downtime'}}
working-directory: lifecycle-manager/config
shell: bash
run: |
current_time=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
time_plus_2_hours=$(date -u -d "2 hours" +"%Y-%m-%dT%H:%M:%SZ")
time_plus_1_day=$(date -u -d "1 day" +"%Y-%m-%dT%H:%M:%SZ")
time_plus_1_day_plus_2_hours=$(date -u -d "1 day 2 hours" +"%Y-%m-%dT%H:%M:%SZ")
cat <<EOF > ./maintenance_windows/policy.json
{
"rules": [
{
"match": {
"region": "asia"
},
"windows": [
{
"begin": "$current_time",
"end": "$time_plus_2_hours"
}
]
},
{
"match": {
"region": "europe"
},
"windows": [
{
"begin": "$time_plus_1_day",
"end": "$time_plus_1_day_plus_2_hours"
}
]
}
],
"default": {}
}
EOF
echo "Maintenance window policy:"
cat ./maintenance_windows/policy.json
cd watcher_local_test
kustomize edit add component ../maintenance_windows
- name: Deploy LM local testing kustomize
uses: ./lifecycle-manager/.github/actions/deploy-lifecycle-manager
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,22 @@ runs:
- name: Create and apply Template Operator ModuleTemplate with ModuleDeploymentNameInNewerVersion
working-directory: template-operator
if: ${{ matrix.e2e-test != 'mandatory-module' &&
matrix.e2e-test != 'mandatory-module-metrics'
matrix.e2e-test != 'mandatory-module-metrics'
}}
shell: bash
run: |
INCLUDE_DEFAULT_CR=true
MANDATORY=false
DEPLOY_MODULETEMPLATE=true
if [ "${{ matrix.e2e-test }}" == "modulereleasemeta-maintenance-window-with-module-downtime" ]; then
REQUIRE_DOWNTIME=true
else
REQUIRE_DOWNTIME=false
fi
make build-manifests
yq eval '(. | select(.kind == "Deployment") | .metadata.name) = "${{ env.ModuleDeploymentNameInNewerVersion }}"' -i template-operator.yaml
./deploy_moduletemplate.sh ${{ env.ModuleName }} ${{ env.NewerVersion }}
./deploy_moduletemplate.sh ${{ env.ModuleName }} ${{ env.NewerVersion }} $INCLUDE_DEFAULT_CR $MANDATORY $DEPLOY_MODULETEMPLATE $REQUIRE_DOWNTIME
- name: Create and apply ModuleReleaseMeta from the latest release
working-directory: template-operator
if: ${{ matrix.e2e-test == 'kyma-metrics' ||
Expand All @@ -75,7 +84,8 @@ runs:
matrix.e2e-test == 'modulereleasemeta-upgrade-under-deletion' ||
matrix.e2e-test == 'modulereleasemeta-sync' ||
matrix.e2e-test == 'module-status-on-skr-connection-lost' ||
matrix.e2e-test == 'modulereleasemeta-not-allowed-installation'
matrix.e2e-test == 'modulereleasemeta-not-allowed-installation' ||
matrix.e2e-test == 'modulereleasemeta-maintenance-window-with-module-downtime'
}}
shell: bash
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-e2e-with-modulereleasemeta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ jobs:
- modulereleasemeta-watch-trigger
- modulereleasemeta-not-allowed-installation
- labelling
- modulereleasemeta-maintenance-window-with-module-downtime

runs-on: ubuntu-latest
timeout-minutes: 20
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ COPY go.sum go.sum
# Copy the go source
COPY cmd cmd/
COPY api api/
COPY maintenancewindows maintenancewindows/
COPY internal internal/
COPY pkg pkg/
COPY skr-webhook skr-webhook/
Expand Down
5 changes: 4 additions & 1 deletion api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ go 1.23.4

require (
github.com/Masterminds/semver/v3 v3.3.1
k8s.io/apimachinery v0.32.0
github.com/stretchr/testify v1.10.0
k8s.io/apimachinery v0.32.1
sigs.k8s.io/controller-runtime v0.19.4
)

require github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect

require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
Expand Down
8 changes: 4 additions & 4 deletions api/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down Expand Up @@ -140,8 +140,8 @@ k8s.io/api v0.31.2 h1:3wLBbL5Uom/8Zy98GRPXpJ254nEFpl+hwndmk9RwmL0=
k8s.io/api v0.31.2/go.mod h1:bWmGvrGPssSK1ljmLzd3pwCQ9MgoTsRCuK35u6SygUk=
k8s.io/apiextensions-apiserver v0.31.2 h1:W8EwUb8+WXBLu56ser5IudT2cOho0gAKeTOnywBLxd0=
k8s.io/apiextensions-apiserver v0.31.2/go.mod h1:i+Geh+nGCJEGiCGR3MlBDkS7koHIIKWVfWeRFiOsUcM=
k8s.io/apimachinery v0.32.0 h1:cFSE7N3rmEEtv4ei5X6DaJPHHX0C+upp+v5lVPiEwpg=
k8s.io/apimachinery v0.32.0/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE=
k8s.io/apimachinery v0.32.1 h1:683ENpaCBjma4CYqsmZyhEzrGz6cjn1MY/X2jB2hkZs=
k8s.io/apimachinery v0.32.1/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE=
k8s.io/client-go v0.31.2 h1:Y2F4dxU5d3AQj+ybwSMqQnpZH9F30//1ObxOKlTI9yc=
k8s.io/client-go v0.31.2/go.mod h1:NPa74jSVR/+eez2dFsEIHNa+3o09vtNaWwWwb1qSxSs=
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
Expand Down
9 changes: 8 additions & 1 deletion api/shared/operator_labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package shared
import "strings"

const (
OperatorGroup = "operator.kyma-project.io"
KymaGroup = "kyma-project.io"
OperatorGroup = "operator." + KymaGroup
Separator = "/"
ControllerName = OperatorGroup + Separator + "controller-name"
ChannelLabel = OperatorGroup + Separator + "channel"
Expand Down Expand Up @@ -43,6 +44,12 @@ const (
// If put on a single ModuleTemplate, allows to disable sync just for this object.
SyncLabel = OperatorGroup + Separator + "sync"

GlobalAccountIDLabel = KymaGroup + Separator + "global-account-id"
RegionLabel = KymaGroup + Separator + "region"
PlatformRegionLabel = KymaGroup + Separator + "platform-region"
// to be confirmed https://github.com/kyma-project/kyma/issues/18611#issuecomment-2441158676
PlanLabel = KymaGroup + Separator + "broker-plan-name"

EnableLabelValue = "true"
DisableLabelValue = "false"
)
Expand Down
26 changes: 26 additions & 0 deletions api/v1beta2/kyma_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,15 @@ type KymaStatus struct {
shared.LastOperation `json:"lastOperation,omitempty"`
}

func (status *KymaStatus) GetModuleStatus(moduleName string) *ModuleStatus {
for _, moduleStatus := range status.Modules {
if moduleStatus.Name == moduleName {
return &moduleStatus
}
}
return nil
}

type ModuleStatus struct {
// Name defines the name of the Module in the Spec that the status is used for.
// It can be any kind of Reference format supported by Module.Name.
Expand Down Expand Up @@ -430,3 +439,20 @@ func (kyma *Kyma) GetNamespacedName() types.NamespacedName {
Name: kyma.GetName(),
}
}

func (kyma *Kyma) GetGlobalAccount() string {
return kyma.Labels[shared.GlobalAccountIDLabel]
}

func (kyma *Kyma) GetRegion() string {
return kyma.Labels[shared.RegionLabel]
}

func (kyma *Kyma) GetPlatformRegion() string {
return kyma.Labels[shared.PlatformRegionLabel]
}

// to be confirmed https://github.com/kyma-project/kyma/issues/18611#issuecomment-2441158676
func (kyma *Kyma) GetPlan() string {
return kyma.Labels[shared.PlanLabel]
}
Loading

0 comments on commit 9fd559b

Please sign in to comment.