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

Creating binding system:image-puller to role ClusterRole can fail with parallel runs in BuildManager #346

Open
mnovak1 opened this issue Feb 18, 2020 · 1 comment
Labels
Milestone

Comments

@mnovak1
Copy link
Contributor

mnovak1 commented Feb 18, 2020

In case that there are started multiple runs of test suite (in parallel) there is race in:
https://github.com/xtf-cz/xtf/blob/master/core/src/main/java/cz/xtf/core/bm/BuildManager.java#L24

which results in:

io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: POST at: https://api.eapqe-005-msb0.dynamic.xpaas:6443/apis/rbac.authorization.k8s.io/v1/namespaces/73-master/rolebindings. Message: rolebindings.rbac.authorization.k8s.io "system:image-puller" already exists. Received status: Status(apiVersion=v1, code=409, details=StatusDetails(causes=[], group=rbac.authorization.k8s.io, kind=rolebindings, name=system:image-puller, retryAfterSeconds=null, uid=null, additionalProperties={}), kind=Status, message=rolebindings.rbac.authorization.k8s.io "system:image-puller" already exists, metadata=ListMeta(_continue=null, remainingItemCount=null, resourceVersion=null, selfLink=null, additionalProperties={}), reason=AlreadyExists, status=Failure, additionalProperties={}).
	at io.fabric8.kubernetes.client.dsl.base.OperationSupport.requestFailure(OperationSupport.java:568)
	at io.fabric8.kubernetes.client.dsl.base.OperationSupport.assertResponseCode(OperationSupport.java:507)
	at io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleResponse(OperationSupport.java:471)
	at io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleResponse(OperationSupport.java:430)
	at io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleCreate(OperationSupport.java:251)
	at io.fabric8.kubernetes.client.dsl.base.BaseOperation.handleCreate(BaseOperation.java:802)
	at io.fabric8.kubernetes.client.dsl.base.BaseOperation.create(BaseOperation.java:322)
	at io.fabric8.kubernetes.client.dsl.base.BaseOperation.create(BaseOperation.java:318)
	at cz.xtf.core.openshift.OpenShift.createRoleBinding(OpenShift.java:821)
	at cz.xtf.core.openshift.OpenShift.getOrCreateRoleBinding(OpenShift.java:923)
	at cz.xtf.core.openshift.OpenShift.addRoleToGroup(OpenShift.java:900)
	at cz.xtf.core.bm.BuildManager.<init>(BuildManager.java:24)
	at cz.xtf.core.bm.BuildManagers.get(BuildManagers.java:23)
	at cz.xtf.junit5.listeners.ManagedBuildPrebuilder.testPlanExecutionStarted(ManagedBuildPrebuilder.java:70)
	at org.junit.platform.launcher.core.TestExecutionListenerRegistry$CompositeTestExecutionListener.lambda$testPlanExecutionStarted$6(TestExecutionListenerRegistry.java:97)
	at java.util.ArrayList.forEach(ArrayList.java:1257)
	at org.junit.platform.launcher.core.TestExecutionListenerRegistry.notifyTestExecutionListeners(TestExecutionListenerRegistry.java:59)
	at org.junit.platform.launcher.core.TestExecutionListenerRegistry.access$100(TestExecutionListenerRegistry.java:28)
	at org.junit.platform.launcher.core.TestExecutionListenerRegistry$CompositeTestExecutionListener.testPlanExecutionStarted(TestExecutionListenerRegistry.java:97)
	at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:183)
	at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:202)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:181)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128)
	at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:150)
	at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:124)
	at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
	at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)

Note that happens if there is used the same xtf.bm.namespace=xtf-builds namespace across the runs and when xtf.bm.namespace is created for the first time.

Solution can be to ignore AlreadyExists exception.

@simkam
Copy link
Contributor

simkam commented Feb 20, 2020

There is already check OpenShift.java#L911 whether RoleBinding exists.

@tommaso-borgato tommaso-borgato added this to the BACKLOG milestone Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants