-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Kubebuilder layout ansible tests, by Fabian #3433
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we not run the commands and create the mock project to do the test instead of adding the files? e.g https://github.com/operator-framework/operator-sdk/blob/5725a5e3a90e2f2b580a7774b4e4d39e17335e0b/hack/tests/e2e-helm.sh
Otherwise, we are not acctually testing what is scaffold by the tool as well.
@camilamacedo86 these tests are not for scaffolding but for more advanced integration tests of Ansible + ansible-runner + the kubernetes modules, there's another test (that's not updated by this PR) that tests the scaffolded code |
Hi @fabianvf, I do see too much the point of we have tests in the project that are not executed from the code which is gen via the tool. However, if it is required for we move forward and have the Ansible plugin I am 100% OK with. See that with kbutils we can inject code and manipulating the files in the Go tests. (e.g https://github.com/kubernetes-sigs/kubebuilder/blob/master/test/e2e/v3/e2e_suite.go#L84-L92 and https://github.com/kubernetes-sigs/kubebuilder/blob/master/test/e2e/v3/e2e_suite.go#L124-L158) Could we track the need to replace this for a generated code via an issue in the repo and a todo in the project/dir to remember? Also, would not be better we put the mock project in a dir named testdata? |
I am of the same mindset as @camilamacedo86 is. Putting static scaffolded files in the repo isn't the best. That's what How much differs in this test project vs a vanilla test project? If it isn't much, could we do as Camila suggests and fully-regenerate it during the e2e using the actual plugin code and then applying the changes? +1 on putting this in a EDIT: I see we already have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are still a bunch of legacy files left over. E.g. build/Dockerfile
and all of deploy
. Are we waiting to remove those until we remove the legacy project scaffolding?
test/ansible/PROJECT
Outdated
- group: cache.example.com | ||
kind: Memcached | ||
version: v1alpha1 | ||
version: "2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
version: "2" | |
version: "3-alpha" |
test/ansible/PROJECT
Outdated
@@ -0,0 +1,7 @@ | |||
domain: com |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the layout
key/value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
value: layout: ansible.operator-sdk.io/v1
test/ansible/Makefile
Outdated
@@ -0,0 +1,85 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a whole bunch of Go-operator related code here.
Is the intention to fully rebuild this directory once the plugin can scaffold it with all of the ansible-specific stuff?
# - name: kube-rbac-proxy | ||
# image: gcr.io/kubebuilder/kube-rbac-proxy:v0.5.0 | ||
# args: | ||
# - "--secure-listen-address=0.0.0.0:8443" | ||
# - "--upstream=http://127.0.0.1:8080/" | ||
# - "--logtostderr=true" | ||
# - "--v=10" | ||
# ports: | ||
# - containerPort: 8443 | ||
# name: https | ||
- name: manager | ||
args: | ||
# - "--metrics-addr=127.0.0.1:8080" | ||
# - "--enable-leader-election" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll probably want a lot of this re-enabled. Should we add TODOs?
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
images: | ||
- name: controller | ||
newName: quay.io/asmacdo/controller | ||
newTag: v0.0.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these lines necessary? It looks like the default scaffolded file is usually just the resources
field.
test/ansible/PROJECT
Outdated
domain: com | ||
repo: wut | ||
resources: | ||
- group: cache.example.com |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is more than just the group. I think it will be cache.example
and the domain would be com
issuerRef: | ||
kind: Issuer | ||
name: selfsigned-issuer | ||
secretName: webhook-server-cert # this secret will not be prefixed, since it's not managed by kustomize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is webhooks supported with the current ansible image?
resources: | ||
- configmaps/status | ||
verbs: | ||
- get | ||
- update | ||
- patch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is something that does not exist. Also, for Ansible/Helm we need to add the roles that are required for the current impl/base image. See;
- apiGroups:
- monitoring.coreos.com
resources:
- servicemonitors
verbs:
- get
- create
- apiGroups:
- apps
resourceNames:
- ""
resources:
- deployments/finalizers
verbs:
- update
- apiGroups:
- ""
resources:
- pods
verbs:
- get
- apiGroups:
- apps
resources:
- replicasets
- deployments
verbs:
- get
- apiGroups:
- example.com
resources:
- '*'
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1c1c598
to
794eda6
Compare
794eda6
to
73c5963
Compare
go.mod
Outdated
github.com/go-logr/zapr v0.1.1 | ||
github.com/iancoleman/strcase v0.0.0-20191112232945-16388991a334 | ||
github.com/kr/text v0.1.0 | ||
github.com/kubernetes-sigs/kustomize v2.0.3+incompatible // indirect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where's this coming from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just go mod tidy will solve -> it is the reason for the PR fails in the sanity test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a good question, I have no idea why/how that's in there, my bad
--- | ||
- name: Build kustomize testing overlay | ||
# load_restrictor must be set to none so we can load patch files from the default overlay | ||
command: '{{ kustomize }} build --load_restrictor none .' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thee CI is failing here. If worked locally and not in the CI is because you have the kustomize
locally installed and can perform it directly. But in the CI it will have not.
make kustomize | ||
if [ -f ./bin/kustomize ] ; then | ||
KUSTOMIZE="$(realpath ./bin/kustomize)" | ||
else | ||
KUSTOMIZE="$(which kustomize)" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think might have a better way.
However, IMO the goal is to ensure that we are doing the same tests with the new layout.
I understand that all these tests will be migrated to GO tests, in this way in POV has no reason to be too precious with :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
terrific great work 🥇
dc6568d
to
26a7661
Compare
New changes are detected. LGTM label has been removed. |
Co-authored-by: Eric Stroczynski <estroczy@redhat.com>
26a7661
to
0a7b4b6
Compare
operator_image: ${OPERATOR_IMAGE:-""} | ||
operator_pull_policy: ${OPERATOR_PULL_POLICY:-"Always"} | ||
pull_policy: ${OPERATOR_PULL_POLICY:-"Always"} | ||
kustomize: ${KUSTOMIZE_PATH:-kustomize} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@asmacdo you will need to change here as well. https://github.com/operator-framework/operator-sdk/pull/3654/files :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
@asmacdo 50% of this pr is addressed already with #4011 and for the advanced scenarios, we have the issue; #4025. So, since it is outdated and if we close it we still able to use as a helper to achieve the #4025 I think it is fine to close this one. However, feel free to re-open if you think that it should not be close at all. |
**Description of the change:** - update advanced mock static scenario with 1.0+ layout (#3433) - (note that we need to ensure that the test works with the new layout) - Fix CI issue (blocker master): `The error was: urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='172.30.99.1', port=24443): Max retries exceeded with url: /version (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f28647cdb38>: Failed to establish a new connection: [Errno 110] Connection timed out',))` in GA. NOTE: The follow up here is to replace the test/ansible static mock with samples to ensure that we are testing it with the latest changes always. See the issue #4025 and its PR : #4312
**Description of the change:** - update advanced mock static scenario with 1.0+ layout (operator-framework#3433) - (note that we need to ensure that the test works with the new layout) - Fix CI issue (blocker master): `The error was: urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='172.30.99.1', port=24443): Max retries exceeded with url: /version (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f28647cdb38>: Failed to establish a new connection: [Errno 110] Connection timed out',))` in GA. NOTE: The follow up here is to replace the test/ansible static mock with samples to ensure that we are testing it with the latest changes always. See the issue operator-framework#4025 and its PR : operator-framework#4312 Signed-off-by: reinvantveer <rein.van.t.veer@geodan.nl>
No description provided.