sclorg / container-common-scripts

Apache License 2.0
20 stars 45 forks source link

Fixes: #195 turn of set +e while 'oc cluster down' #220

Closed phracek closed 2 years ago

phracek commented 2 years ago

Turn of 'set +e' while oc cluster down and switch user to system:admin

Signed-off-by: Petr "Stone" Hracek phracek@redhat.com

phracek commented 2 years ago

The question is: will this work together with https://github.com/sclorg/s2i-python-container/blob/master/test/run-openshift#L18? From my bash knowledge point of view it should work.

pkubatrh commented 2 years ago

The oc login addition makes sense to me if it is needed. But I do not think we want to ignore potential errors. What if the change does not help? Would we know if it does not fail the tests?

zmiklank commented 2 years ago

@pkubatrh Wouldn't the potential errors be still present in the logs, as "set +e" only disables exit on error?

pkubatrh commented 2 years ago

@zmiklank Yes, but do you ever check the logs for test runs that did not fail?

phracek commented 2 years ago

@pkubatrh @zmiklank Well, basically, ct_os_cluster_down is called at the end of each OpenShift 3 test suite.

See here: https://github.com/sclorg/s2i-php-container/blob/master/test/run-openshift-local-cluster#L100 https://github.com/sclorg/postgresql-container/blob/master/test/run-openshift-local-cluster#L465

In most cases, our OpenShift 3 tests are failing for this reason: https://github.com/sclorg/container-common-scripts/issues/195#issuecomment-896638997

What I am missing in the function is something like the log, which will tell us more. Something like "Cluster is going down" and then call oc cluster down. More logs can be added by this pull request. I will add it.

No resources found.
Error from server (Forbidden): pods is forbidden: User "developer" cannot list pods in the namespace "sclorg-test-15517": no RBAC policy matched
Error from server (Forbidden): replicationcontrollers is forbidden: User "developer" cannot list replicationcontrollers in the namespace "sclorg-test-15517": no RBAC policy matched
Error from server (Forbidden): services is forbidden: User "developer" cannot list services in the namespace "sclorg-test-15517": no RBAC policy matched
Error from server (Forbidden): daemonsets.apps is forbidden: User "developer" cannot list daemonsets.apps in the namespace "sclorg-test-15517": no RBAC policy matched
Error from server (Forbidden): deployments.apps is forbidden: User "developer" cannot list deployments.apps in the namespace "sclorg-test-15517": no RBAC policy matched
Error from server (Forbidden): replicasets.apps is forbidden: User "developer" cannot list replicasets.apps in the namespace "sclorg-test-15517": no RBAC policy matched
Error from server (Forbidden): statefulsets.apps is forbidden: User "developer" cannot list statefulsets.apps in the namespace "sclorg-test-15517": no RBAC policy matched
Error from server (Forbidden): horizontalpodautoscalers.autoscaling is forbidden: User "developer" cannot list horizontalpodautoscalers.autoscaling in the namespace "sclorg-test-15517": no RBAC policy matched
Error from server (Forbidden): jobs.batch is forbidden: User "developer" cannot list jobs.batch in the namespace "sclorg-test-15517": no RBAC policy matched
Error from server (Forbidden): cronjobs.batch is forbidden: User "developer" cannot list cronjobs.batch in the namespace "sclorg-test-15517": no RBAC policy matched
Error from server (Forbidden): deploymentconfigs.apps.openshift.io is forbidden: User "developer" cannot list deploymentconfigs.apps.openshift.io in the namespace "sclorg-test-15517": no RBAC policy matched
Error from server (Forbidden): buildconfigs.build.openshift.io is forbidden: User "developer" cannot list buildconfigs.build.openshift.io in the namespace "sclorg-test-15517": no RBAC policy matched
Error from server (Forbidden): builds.build.openshift.io is forbidden: User "developer" cannot list builds.build.openshift.io in the namespace "sclorg-test-15517": no RBAC policy matched
Error from server (Forbidden): imagestreams.image.openshift.io is forbidden: User "developer" cannot list imagestreams.image.openshift.io in the namespace "sclorg-test-15517": no RBAC policy matched
Error from server (Forbidden): routes.route.openshift.io is forbidden: User "developer" cannot list routes.route.openshift.io in the namespace "sclorg-test-15517": no RBAC policy matched
OpenShift tests for quay.io/centos7/mariadb-103-centos7:1 failed.
make: *** [test-openshift] Error 1
phracek commented 2 years ago

@zmiklank Yes, but do you ever check the logs for test runs that did not fail?

I don't follow this. If the test failed, before oc_cluster_down, this function is called https://github.com/sclorg/s2i-php-container/blob/master/test/run-openshift-local-cluster#L21 or this one https://github.com/sclorg/postgresql-container/blob/master/test/run-openshift-local-cluster#L19. Only if all tests are passing the function oc_cluster_down is called.

At the beginning of each OpenShift 3 tests set -eo is called like here: https://github.com/sclorg/s2i-php-container/blob/master/test/run-openshift-local-cluster#L19 https://github.com/sclorg/postgresql-container/blob/master/test/run-openshift-local-cluster#L17

pkubatrh commented 2 years ago

@phracek I understand what the problem is, but what do we want to fix with this PR? Do we want to fix the underlying problem (adding oc login so that oc cluster down does not fail), or do we just not care if oc cluster down fails (hence the set +e so that the test suite does not end in failure)? The PR currently tries to do both and it seems to me that this contradicts each other - we should either ignore the failure if we do not care, or make sure it does not happen.

pkubatrh commented 2 years ago

If we do both, then it implies we care about both. But we will never know the next time oc cluster down fails again for some different reason, because the failure is ignored.

phracek commented 2 years ago

Then I would prefer to start with login into admin account and we will see later on. Let's do it step by step.

phracek commented 2 years ago

[test]

phracek commented 2 years ago

@pkubatrh I have change this PR only for logging as admin. WDYT?

pkubatrh commented 2 years ago

lgtm, guess the only way to test it out now is to merge it. :)

phracek commented 2 years ago

This pull request https://github.com/sclorg/s2i-python-container/pull/485 tests the proper OpenShift 3 functionality.