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

test: Use ExpectSingletonReconciled from operatorpkg #1663

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jeevanpuchakay
Copy link

@jeevanpuchakay jeevanpuchakay commented Sep 13, 2024

Fixes 1348

Description

  • Using expectations from operatorpkg so that we can avoid duplication at multiple places.
  • Changing only one expectation ExpectSingletonReconciled as part of this PR to align the overall change with reviewers before creating a bigger PR.

Issue tracker

How was this change tested?

  • Ran make test locally.
  • Command line output for tests.
linux@JeevanAsus:/mnt/c/Users/jeeva/Documents/GitHub/karpenter$ make test
go test ./pkg/... \
        -race \
        -timeout 20m \
        --ginkgo.focus="" \
        --ginkgo.randomize-all \
        --ginkgo.v \
        -cover -coverprofile=coverage.out -outputdir=. -coverpkg=./...
?       sigs.k8s.io/karpenter/pkg/apis  [no test files]
        sigs.k8s.io/karpenter/pkg/cloudprovider         coverage: 0.0% of statements
        sigs.k8s.io/karpenter/pkg/cloudprovider/fake            coverage: 0.0% of statements
        sigs.k8s.io/karpenter/pkg/controllers           coverage: 0.0% of statements
        sigs.k8s.io/karpenter/pkg/controllers/node/termination/terminator/events                coverage: 0.0% of statements
        sigs.k8s.io/karpenter/pkg/controllers/disruption/events         coverage: 0.0% of statements
ok      sigs.k8s.io/karpenter/pkg/apis/v1       22.971s coverage: 5.4% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/cloudprovider/metrics 1.300s  coverage: 0.6% of statements in ./...
        sigs.k8s.io/karpenter/pkg/controllers/state/informer            coverage: 0.0% of statements
        sigs.k8s.io/karpenter/pkg/operator/injection            coverage: 0.0% of statements
        sigs.k8s.io/karpenter/pkg/operator/logging              coverage: 0.0% of statements
        sigs.k8s.io/karpenter/pkg/test          coverage: 0.0% of statements
        sigs.k8s.io/karpenter/pkg/test/expectations             coverage: 0.0% of statements
        sigs.k8s.io/karpenter/pkg/test/v1alpha1         coverage: 0.0% of statements
        sigs.k8s.io/karpenter/pkg/utils/disruption              coverage: 0.0% of statements
        sigs.k8s.io/karpenter/pkg/utils/env             coverage: 0.0% of statements
        sigs.k8s.io/karpenter/pkg/utils/pdb             coverage: 0.0% of statements
        sigs.k8s.io/karpenter/pkg/utils/nodepool                coverage: 0.0% of statements
        sigs.k8s.io/karpenter/pkg/utils/pretty          coverage: 0.0% of statements
        sigs.k8s.io/karpenter/pkg/utils/pod             coverage: 0.0% of statements
        sigs.k8s.io/karpenter/pkg/utils/result          coverage: 0.0% of statements
        sigs.k8s.io/karpenter/pkg/utils/testing         coverage: 0.0% of statements
        sigs.k8s.io/karpenter/pkg/utils/volume          coverage: 0.0% of statements
ok      sigs.k8s.io/karpenter/pkg/controllers/disruption        318.957s        coverage: 51.4% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/controllers/disruption/orchestration  17.379s coverage: 12.3% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/controllers/metrics/node      9.918s  coverage: 7.1% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/controllers/metrics/nodepool  11.434s coverage: 3.8% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/controllers/metrics/pod       8.605s  coverage: 3.2% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/controllers/node/termination  106.845s        coverage: 12.9% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/controllers/node/termination/terminator       11.749s coverage: 3.6% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/controllers/nodeclaim/consistency     14.344s coverage: 9.1% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/controllers/nodeclaim/disruption      20.190s coverage: 10.9% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/controllers/nodeclaim/expiration      13.069s coverage: 6.7% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/controllers/nodeclaim/garbagecollection       16.371s coverage: 10.6% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/controllers/nodeclaim/lifecycle       82.982s coverage: 13.6% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/controllers/nodeclaim/podevents       11.698s coverage: 7.1% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/controllers/nodeclaim/termination     44.305s coverage: 12.5% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/controllers/nodepool/counter  11.720s coverage: 8.9% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/controllers/nodepool/hash     10.722s coverage: 5.0% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/controllers/nodepool/readiness        20.822s coverage: 4.4% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/controllers/nodepool/validation       29.552s coverage: 4.2% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/controllers/provisioning      35.685s coverage: 34.1% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/controllers/provisioning/scheduling   259.133s        coverage: 42.6% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/controllers/state     345.520s        coverage: 18.9% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/events        7.443s  coverage: 1.9% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/metrics       1.459s  coverage: 1.1% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/operator      1.293s  coverage: 0.8% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/operator/options      1.307s  coverage: 1.3% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/scheduling    28.156s coverage: 3.9% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/utils/atomic  1.139s  coverage: 0.0% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/utils/node    25.025s coverage: 3.8% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/utils/nodeclaim       10.243s coverage: 1.7% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/utils/resources       1.375s  coverage: 2.3% of statements in ./...
ok      sigs.k8s.io/karpenter/pkg/utils/termination     8.689s  coverage: 3.6% of statements in ./...
linux@JeevanAsus:/mnt/c/Users/jeeva/Documents/GitHub/karpenter$

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: jeevanpuchakay
Once this PR has been reviewed and has the lgtm label, please assign ellistarn for approval. For more information see the Kubernetes Code Review Process.

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

Needs approval from an approver in each of these files:

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 added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 13, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @jeevanpuchakay. 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.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 13, 2024
@jeevanpuchakay jeevanpuchakay marked this pull request as draft September 13, 2024 17:04
@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 Sep 13, 2024
@jeevanpuchakay jeevanpuchakay marked this pull request as ready for review September 13, 2024 17:06
@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 Sep 13, 2024
Copy link
Author

@jeevanpuchakay jeevanpuchakay left a comment

Choose a reason for hiding this comment

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

Not sure about the PR review process on whether I need to ping someone from assigned reviewers on PR or they would look at it in on their own or need a whole different set of reviewers. Checking sop

@jeevanpuchakay jeevanpuchakay marked this pull request as draft September 13, 2024 17:14
@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 Sep 13, 2024
@jeevanpuchakay jeevanpuchakay marked this pull request as ready for review September 14, 2024 06: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 Sep 14, 2024
@jeevanpuchakay
Copy link
Author

jeevanpuchakay commented Sep 14, 2024

presubmit is failing with, dont think it has got to do anything with the changes in this PR (reviewers please help). See similar failure in one of the open PR #1625

go mod tidy
go generate ./...
hack/validation/taint.sh
hack/validation/requirements.sh
hack/validation/labels.sh
hack/validation/status.sh
cp -r pkg/apis/crds kwok/charts
hack/kwok/requirements.sh
hack/dependabot.sh
hack/boilerplate.sh
go vet ./...
cd kwok/charts && helm-docs
time="2024-09-13T1[7](https://github.com/kubernetes-sigs/karpenter/actions/runs/10853288294/job/30121240228?pr=1663#step:5:8):14:20Z" level=info msg="Found Chart directories [.]"
time="2024-0[9](https://github.com/kubernetes-sigs/karpenter/actions/runs/10853288294/job/30121240228?pr=1663#step:5:10)-13T17:14:20Z" level=info msg="Generating README Documentation for chart ."
golangci-lint run
New file modification detected in the Git working tree. Please check in before commit.
  - pkg/controllers/disruption/consolidation_test.go
make: *** [Makefile:[11](https://github.com/kubernetes-sigs/karpenter/actions/runs/10853288294/job/30121240228?pr=1663#step:5:12)1: verify] Error 1
Error: Process completed with exit code 2.

@@ -47,6 +47,7 @@ import (
"sigs.k8s.io/karpenter/pkg/scheduling"
"sigs.k8s.io/karpenter/pkg/test"
. "sigs.k8s.io/karpenter/pkg/test/expectations"
expectations "github.com/awslabs/operatorpkg/test/expectations"
Copy link
Contributor

Choose a reason for hiding this comment

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

We should ideally be able to import this as a dot import, and port whatever expectations are in the sigs.k8s.io/karpenter package into operatorpkg. Thoughts on waiting for that to be fixed before merging this?

Copy link
Contributor

@njtran njtran Sep 16, 2024

Choose a reason for hiding this comment

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

Rather, do you mind removing the function here in sigs/karpenter, and just use the operatorpkg one instead without needing a named import?

Copy link
Author

Choose a reason for hiding this comment

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

Sure, do you have any thoughts about importing specific functions from a different go module? This will improve readability into where exactly a function is imported from, also if a similar function is defined in multiple dependency modules it may lead to conflicts (not sure if go does handle it already during compile time). This way our imports will be humongous.

Copy link
Author

Choose a reason for hiding this comment

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

Infact I am running into this methods conflict issue when I am trying to import . and use the methods from operatorpkg where other non-migrated expectations are conflicting.

# sigs.k8s.io/karpenter/pkg/controllers/disruption_test [sigs.k8s.io/karpenter/pkg/controllers/disruption.test]
/mnt/c/Users/jeeva/Documents/GitHub/karpenter/pkg/controllers/disruption/consolidation_test.go:50:2: ExpectObjectReconciled redeclared in this block
   /mnt/c/Users/jeeva/Documents/GitHub/karpenter/pkg/test/expectations/expectations.go:179:6: other declaration of ExpectObjectReconciled
/mnt/c/Users/jeeva/Documents/GitHub/karpenter/pkg/controllers/disruption/consolidation_test.go:50:2: ExpectDeleted redeclared in this block
   /mnt/c/Users/jeeva/Documents/GitHub/karpenter/pkg/test/expectations/expectations.go:162:6: other declaration of ExpectDeleted
.....
.....
More errors

Copy link
Author

Choose a reason for hiding this comment

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

I would prefer we do this migration one expectation at a time (I am new to go and in general to kubernetes/karpenter) since migrating all at once may invite bunch of issues and it would be uphill battle to solve all at once. Open to hear your thoughts as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants