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

🐛 fix: (helm/v1alpha1): install the prometheus-operator CRDs before installing a chart which configures a ServiceMonitor #4383

Merged
merged 1 commit into from
Nov 24, 2024

Conversation

monteiro-renato
Copy link
Contributor

Fixes: #4378

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 22, 2024
@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 22, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @monteiro-renato. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@monteiro-renato monteiro-renato marked this pull request as draft November 22, 2024 18:40
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 22, 2024
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 22, 2024
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 22, 2024
@monteiro-renato monteiro-renato force-pushed the patch-4378 branch 2 times, most recently from aba0330 to e545894 Compare November 22, 2024 20:12

- name: Check Presence of ServiceMonitor
run: |
kubectl wait --namespace project-v4-with-plugins-system --for=jsonpath='{.kind}'=ServiceMonitor servicemonitor/project-v4-with-plugins-controller-manager-metrics-monitor
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fails with exit 1 code if the resource does not exist.

Copy link
Member

@camilamacedo86 camilamacedo86 Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we have a bug.
For we are able to check it out we need enable prometheus in the HelmChart value.

By default it is

prometheus:
  enable: false

we need to use shell to change it in the GitHUb action to set true
Something like example: https://github.com/kubernetes-sigs/kubebuilder/blob/master/.github/workflows/test-e2e-samples.yml#L43-L44

Then, the error will be faced
Not sure if the error is with chart manifests or in the action:
pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates/github/test_chart.go

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm passing the value to the helm install command in line 78 :)
Check the --set flag of the helm install

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: how about adding an explicit timeout flag for kubectl wait:

--timeout=60s

Also, --for='' could be another choice to consider?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit of an hack since the kubectl wait is supposed to be used with resources that have a Status field.
The command fails right away if the resource doesn't exist so the --timeout flag isn't really needed here (I guess --timeout=0 would be ok).

If kubectl get on a non existent resource would somehow return a non zero exit code that's what I would have used but I don't think that's possible. And between processing the output of kubectl get and simply using the hack above, I think the hack above is easier to understand.

The --for='' could be an option yea; my thought was that it could lead to confusion as it might be less clear.

@monteiro-renato monteiro-renato marked this pull request as ready for review November 22, 2024 20:16
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 22, 2024
Copy link
Contributor

@Kavinjsir Kavinjsir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!


- name: Check Presence of ServiceMonitor
run: |
kubectl wait --namespace project-v4-with-plugins-system --for=jsonpath='{.kind}'=ServiceMonitor servicemonitor/project-v4-with-plugins-controller-manager-metrics-monitor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: how about adding an explicit timeout flag for kubectl wait:

--timeout=60s

Also, --for='' could be another choice to consider?

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 23, 2024
Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @monteiro-renato

We also need to change the github action taht we are scaffolding for the projects, see; pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates/github/test_chart.go

@k8s-ci-robot k8s-ci-robot removed the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Nov 23, 2024
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 23, 2024
@@ -118,9 +124,13 @@ jobs:

- name: Install Helm chart for project
run: |
helm install my-release ./dist/chart --create-namespace --namespace {{ .ProjectName }}-system
helm install my-release ./dist/chart --create-namespace --namespace {{ .ProjectName }}-system --set prometheus.enable=true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See, we cannot add this one here.
Because the Prometheus is disabled by default
If the person enables Prometheus in the chart and commits it.
Then, it will be enabled already, or if the author prefers, then it can be done.

Is that make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep updated it now 👍

Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just I nit all the rest shows great 🥇
Terrific work

See: https://github.com/kubernetes-sigs/kubebuilder/pull/4383/files#r1855209081

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm install prometheus-crds prometheus-community/prometheus-operator-crds

Copy link
Member

@camilamacedo86 camilamacedo86 Nov 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@monteiro-renato
this one needs to be commented on under # TODO: Uncomment if Prometheus is enabled
We should only install it if the chart enabled the option

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it would be a bit easier to just install the CRDs all the time as they shouldn't add too much time to the action run.

I've shifted them to be under the TODO now 👍.

…nstalling a chart which configures a ServiceMonitor
Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approved
/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 24, 2024
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 24, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: camilamacedo86, Kavinjsir, monteiro-renato

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [Kavinjsir,camilamacedo86]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 8911e2f into kubernetes-sigs:master Nov 24, 2024
22 checks passed
@monteiro-renato monteiro-renato deleted the patch-4378 branch November 24, 2024 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(helm/v1alpha1): Prometheus integration is not working well when enabled in the Chart
4 participants