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

Newer common #286

Merged
merged 7 commits into from
Oct 25, 2024
Merged

Conversation

mbaldessari
Copy link
Contributor

  • Improve validate-origin
  • Make the make install output less daunting
  • Record the exit code at the right time

mbaldessari and others added 7 commits October 14, 2024 11:40
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'
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 <ltomasbo@redhat.com>
Make the make install output less daunting
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
Record the exit code at the right time
@mbaldessari mbaldessari merged commit 063a3f3 into validatedpatterns:wip-next-gen Oct 25, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants