Skip to content

Commit

Permalink
Commonslimming (#7)
Browse files Browse the repository at this point in the history
* Replace tabs with spaces and add some missing env vars that could be passed

* Also push any changes to operator-install to its own repo

Since at the time the folder was named operator-install and the chart
pattern-install, let's push it out to the `pattern-install-chart` repo
which is a bit clearer.

* Update CRD from operator v0.0.55

* Fix chart name in pattern-install branch+split wf

* Tweak readme

* Use $group.name in clusterset metadata

Closes: validatedpatterns/regional-resiliency-pattern#5

* Expose originURL as helm value

This is needed, this way when this variable is set we can actually
detect that an in-cluster gitea instance has been set up.

* Update tests after common rebase

* Release clustergroup v0.8.13

* Release acm v0.1.2

* Drop schema required under the Main section

The "main" subsection of helm values is only used for kickstarting a
pattern. It is entirely possible to only set one value and then set the
other variables through other means (editing CRs e.g.). There is no
point on blocking this.

* Release clustergroup v0.8.14

* Drop all the helm charts

All the charts that can be used via an OCI registry or via a helm repo
are dropped in this change

* README fixes

* Drop the operator-install folder (pattern-install chart)

* Start using the OCI chart in lieu of operator-install

* Drop the chart splitting workflows

We do not push any changes from common to the chart because they do not
exist in common any longer

* Drop the test folder

It used to contain expected tests for the different charts, but those
have moved away, so let's start dropping these for now.

* Drop the json schema checking job

It only makes sense in the presence of helm charts. We should prolly
move it to each chart repo.

* Add a README note on the main branch

* Add a check to see if multisource for clustergroup is enabled

Without this in your values-global.yaml files, the deployment with a
slimmed down common would fail as follows:

    - lastTransitionTime: "2024-09-13T18:30:19Z"
    message: 'Failed to load target state: failed to generate manifest for source
      1 of 1: rpc error: code = Unknown desc = Manifest generation error (cached):
      common/clustergroup: app path does not exist'

* Move the common slim + multisource test into Makefile

This way yq is not required on the host. Tested as follows:

* No value set (assumes default is false)

❯ cat values-global.yaml
---
global:
  pattern: multicloud-gitops
  options:
    useCSV: false
    syncPolicy: Automatic
    installPlanApproval: Automatic
main:
  clusterGroupName: hub
  #  multiSourceConfig:
  #  enabled: true

❯ ./pattern.sh make validate-prereq
make -f common/Makefile validate-prereq
make[1]: Entering directory '/home/michele/Engineering/cloud-patterns/multicloud-gitops'
You must set ".main.multiSourceConfig.enabled: true" in your 'values-global.yaml' file
because your common subfolder is the slimmed down version with no helm charts in it
make[1]: *** [common/Makefile:161: validate-prereq] Error 1
make[1]: Leaving directory '/home/michele/Engineering/cloud-patterns/multicloud-gitops'
make: *** [Makefile:12: validate-prereq] Error 2

* Value set to false

❯ cat values-global.yaml
---
global:
  pattern: multicloud-gitops
  options:
    useCSV: false
    syncPolicy: Automatic
    installPlanApproval: Automatic
main:
  clusterGroupName: hub
  multiSourceConfig:
    enabled: false
❯ ./pattern.sh make validate-prereq
make -f common/Makefile validate-prereq
make[1]: Entering directory '/home/michele/Engineering/cloud-patterns/multicloud-gitops'
You must set ".main.multiSourceConfig.enabled: true" in your 'values-global.yaml' file
because your common subfolder is the slimmed down version with no helm charts in it
make[1]: *** [common/Makefile:161: validate-prereq] Error 1
make[1]: Leaving directory '/home/michele/Engineering/cloud-patterns/multicloud-gitops'
make: *** [Makefile:12: validate-prereq] Error 2

* Value set to true

❯ cat values-global.yaml
---
global:
  pattern: multicloud-gitops
  options:
    useCSV: false
    syncPolicy: Automatic
    installPlanApproval: Automatic
main:
  clusterGroupName: hub
  multiSourceConfig:
    enabled: true
❯ ./pattern.sh make validate-prereq
make -f common/Makefile validate-prereq
make[1]: Entering directory '/home/michele/Engineering/cloud-patterns/multicloud-gitops'
make[1]: Leaving directory '/home/michele/Engineering/cloud-patterns/multicloud-gitops'

* Drop last bit of operator-install and the common symlink

* Drop reference-output.yaml as it makes little sense in the slimmed common

* Remove ansible code in favor of external collection

* Make adjustments for ansible code moving into separate collection repo

* Add a note about the changes in common

* Add qe-tests target

* Remove assorted detritus

* We don't have charts to test anymore

* Drop lint.sh and its target in Makefile

* Drop test.sh and its target in Makefile and also kubeconform

* Read PATTERN_INSTALL_CHART from the env as well if it exists

* Update secret backend change script

The script is used in make secrets-backend-*. Update needed for slimed
common.

* Update preview script

Now the preview will work with remote charts, and local charts as well.
Default helm registry will be oci://quay.io/repository/hybridcloudpatterns/.

* Introduce PATTERN_DISCONNECTED_HOME

When doing disconnected installations this allows for setting a single
variable pointing to the internal disconnected registry.

* Update Makefile to reflect a warning if no storageclass is present

* Fix iib loading playbook name

After slimming common down the playbook needs renaming because
collections have slightly different naming constraints. Previous error:

❯ ./pattern.sh make load-iib
make -f common/Makefile load-iib
make[1]: Entering directory '/home/michele/Engineering/cloud-patterns/multicloud-gitops'
ERROR! the playbook: rhvp.cluster_utils.iib-ci could not be found
make[1]: *** [common/Makefile:117: load-iib] Error 1
make[1]: Leaving directory '/home/michele/Engineering/cloud-patterns/multicloud-gitops'
make: *** [Makefile:12: load-iib] Error 2

* Improve validate-origin

If we set the main.git.upstreamRepoURL then we need to check that one
for the presence of the branch and not whatever is configured as the
origin remote.

Tested as follows:

- Working upstreamRepoURL:

    ❯ yq -r '.main.git.repoUpstreamURL // (.main.git.repoUpstreamURL = "")' values-global.yaml
    https://github.com/mbaldessari/industrial-edge
    ❯ make validate-origin
    make -f common/Makefile validate-origin
    make[1]: Entering directory '/home/michele/Engineering/cloud-patterns/industrial-edge'
    Checking repository:
    Upstream URL set to: https://github.com/mbaldessari/industrial-edge
      https://github.com/mbaldessari/industrial-edge - branch 'for-max-s3-kafka-fix': OK
    make[1]: Leaving directory '/home/michele/Engineering/cloud-patterns/industrial-edge'

- upstreamRepoURL without the branch:

    ❯ yq -r '.main.git.repoUpstreamURL // (.main.git.repoUpstreamURL = "")' values-global.yaml
    https://github.com/mamurak/industrial-edge
    ❯ make validate-origin
    make -f common/Makefile validate-origin
    make[1]: Entering directory '/home/michele/Engineering/cloud-patterns/industrial-edge'
    Checking repository:
    Upstream URL set to: https://github.com/mamurak/industrial-edge
      https://github.com/mamurak/industrial-edge - branch 'for-max-s3-kafka-fix': NOT FOUND
    make[1]: *** [common/Makefile:138: validate-origin] Error 1
    make[1]: Leaving directory '/home/michele/Engineering/cloud-patterns/industrial-edge'
    make: *** [Makefile:24: validate-origin] Error 2

- No repoUpstreamURL set:

    ❯ yq -r '.main.git.repoUpstreamURL // (.main.git.repoUpstreamURL = "")' values-global.yaml
    ❯
    ❯ make validate-origin
    make -f common/Makefile validate-origin
    make[1]: Entering directory '/home/michele/Engineering/cloud-patterns/industrial-edge'
    Checking repository:
      https://github.com/mbaldessari/industrial-edge.git - branch 'for-max-s3-kafka-fix': OK
    make[1]: Leaving directory '/home/michele/Engineering/cloud-patterns/industrial-edge'

* Make the make install output less daunting

The current output is a bit daunting for first-time users as it outputs
things like the following a few times:

    customresourcedefinition.apiextensions.k8s.io/patterns.gitops.hybrid-cloud-patterns.io created
    configmap/patterns-operator-config created
    subscription.operators.coreos.com/patterns-operator created
    error: resource mapping not found for name: "rhoai-patterns-demo" namespace: "openshift-operators" from "STDIN": no matches for kind "Pattern" in version "gitops.hybrid-cloud-patterns.io/v1alpha1"
    ensure CRDs are installed first

Let's switch to something a bit more user-friendly:

    make -f common/Makefile operator-deploy
    make[1]: Entering directory '/home/michele/Engineering/cloud-patterns/multicloud-gitops'
    Checking repository:
      https://github.com/mbaldessari/multicloud-gitops.git - branch 'luis-demo': OK
    Checking cluster:
      cluster-info: OK
      storageclass: WARNING: No storageclass found
    Installing pattern: Done
    ...

Do some magic with file descriptors so we still manage to capture the
helm template stderr and the oc apply stdout+stderr and output them at
the end in case of failure.

In such cases the output will be something like the following:

    Installing pattern: .....Installation failed [5/5]. Error:
    Pulled: quay.io/hybridcloudpatterns/pattern-install:0.0.3
    Digest: sha256:dd2d35d462b75aa8358ff278757dca0ee3c878cadafa64df8c68f880b59569ef
    E1015 18:41:31.585465  196315 memcache.go:265] couldn't get current server API group list: Get "https://api.sno3.ocplab.ocp:6443/api?timeout=32s": tls: failed to verify certificate: x509: certificate signed by un
    known authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kube-apiserver-lb-signer")
    ...

Suggested-by: Luis Tomas Bolivar <[email protected]>

* Record the exit code at the right time

Otherwise it records the exit code of the exec call which is always 0.

This now makes things error out correctly whereas previously it did not:

    ❯ ./pattern.sh make install
    make -f common/Makefile operator-deploy
    make[1]: Entering directory '/home/michele/Engineering/cloud-patterns/multicloud-gitops'
    Checking repository:
      https://github.com/mbaldessari/multicloud-gitops.git - branch 'debug': OK
    Checking cluster:
      cluster-info: OK
      storageclass: OK
    Installing pattern: .....Installation failed [5/5]. Error:
    Pulled: quay.io/rhn_support_mbaldess/pattern-install:0.0.4
    Digest: sha256:6a5431d257f4bf05d6ac91bca4f4aa010ecb1ee60d2e03c1d0984835d210a0a8

    customresourcedefinition.apiextensions.k8s.io/patterns.gitops.hybrid-cloud-patterns.io unchanged
    configmap/patterns-operator-config unchanged
    resource mapping not found for name: "patterns-operator" namespace: "openshift-operators" from "STDIN": no matches for kind "SubscriptionNotexistant" in version "operators.coreos.com/v1alpha1"
    ensure CRDs are installed first
    Error from server (NotFound): error when creating "STDIN": namespaces "openshift-operators-notexistant" not found
    make[1]: *** [common/Makefile:71: operator-deploy] Error 1
    make[1]: Leaving directory '/home/michele/Engineering/cloud-patterns/multicloud-gitops'
    make: *** [Makefile:12: operator-deploy] Error 2

* Fix path when invoking the qe run_test.sh script

* Removed previous version of common to convert to subtree from https://github.com/hybrid-cloud-patterns/common.git main

---------

Co-authored-by: Michele Baldessari <[email protected]>
Co-authored-by: Martin Jackson <[email protected]>
Co-authored-by: Andrew Beekhof <[email protected]>
Co-authored-by: Akos Eros <[email protected]>
Co-authored-by: Sergio Garcia Martinez <[email protected]>
Co-authored-by: Akos Eros <[email protected]>
  • Loading branch information
7 people authored Dec 5, 2024
1 parent b56dad1 commit d1bcc78
Show file tree
Hide file tree
Showing 286 changed files with 165 additions and 97,596 deletions.
6 changes: 1 addition & 5 deletions common/.github/linters/.gitleaks.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
[whitelist]
# As of v4, gitleaks only matches against filename, not path in the
# files directive. Leaving content for backwards compatibility.
files = [
"ansible/plugins/modules/*.py",
"ansible/tests/unit/test_*.py",
"ansible/tests/unit/v1/*.yaml",
]
files = [ ]
17 changes: 0 additions & 17 deletions common/.github/workflows/ansible-lint.yml

This file was deleted.

52 changes: 0 additions & 52 deletions common/.github/workflows/ansible-unittest.yml

This file was deleted.

108 changes: 0 additions & 108 deletions common/.github/workflows/chart-branches.yml

This file was deleted.

42 changes: 0 additions & 42 deletions common/.github/workflows/chart-split.yml

This file was deleted.

57 changes: 0 additions & 57 deletions common/.github/workflows/jsonschema.yaml

This file was deleted.

65 changes: 0 additions & 65 deletions common/.github/workflows/linter.yml

This file was deleted.

8 changes: 8 additions & 0 deletions common/Changes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changes

## Sep 24, 2024

* Ansible has been moved out of the common code tree, you must use a clustergroup chart that is >= 0.9.1

## Sep 6, 2024

* Most charts have been removed from the tree. To get the charts you now have to point to them

## Sep 25, 2023

* Upgraded ESO to v0.9.5
Expand Down
Loading

0 comments on commit d1bcc78

Please sign in to comment.