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

feat(web): add a config property that allows front50 to be the source of truth for applications #1825

Merged
merged 2 commits into from
Sep 12, 2024

Conversation

kirangodishala
Copy link
Contributor

@kirangodishala kirangodishala commented Aug 30, 2024

This PR is to address the issue of UI showing synthetic applications created by Spinnaker itself which are unknown to Front50.

Clouddriver creates these synthetic applications when it is caching resources in a cluster. If the account doesn’t have onlySpinnakerManaged set to true, it will create an application using the first part of the manifest name. i.e. a deployment with a name of test-abc will result in an application called test being created.

Through spinnaker/clouddriver#5777, Clouddriver is equipped with discarding caching manifests whose application name(derived from moniker) doesn't exist in front50 but in spite of this, synthetic applications can exist in the following scenarios:

  1. When kubernetes.checkApplicationInFront50 is not enabled in clouddriver
  2. If any resources already cached (and created synthetic applications) before enabling kubernetes.checkApplicationInFront50 in clouddriver.

This PR makes sure that when gate is queried for the applications list, it gets the applications from front50 and clouddriver, and only considers the applications returned from front50 to be the source of truth.

It introduces the following property now in Gate, which when enabled discards all the applications that are obtained from clouddriver which are not known to front50.

application.useFront50AsSourceOfTruth: true # defaults to false

@kirangodishala kirangodishala marked this pull request as draft August 30, 2024 15:07
@kirangodishala kirangodishala force-pushed the front50-to-be-app-source branch 2 times, most recently from 11fdcdb to a49e888 Compare August 30, 2024 15:11
@kirangodishala kirangodishala marked this pull request as ready for review August 30, 2024 15:57
kirangodishala and others added 2 commits September 12, 2024 12:41
by using

>> { throw exception }

instead of

>> exception

so spock doesn't try to coerce the exception into the return type of the method, with errors like:

ApplicationServiceSpec > when UseFront50AsSourceOfTruth: #checkFront50 and application exists only in clouddriver, but front50 throws an exception > com.netflix.spinnaker.gate.ApplicationServiceSpec.when UseFront50AsSourceOfTruth: true and application exists only in clouddriver, but front50 throws an exception STANDARD_OUT
    --------------- Test when UseFront50AsSourceOfTruth: #checkFront50 and application exists only in clouddriver, but front50 throws an exception
    2024-09-10 19:21:01.226 ERROR   --- [pool-5-thread-1] c.n.s.gate.services.ApplicationService   : [] Falling back to application cache
    org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'java.lang.Exception: fatal exception' with class 'java.lang.Exception' to class 'java.util.Map'
    	at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnSAM(DefaultTypeTransformation.java:404)
    	at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnNumber(DefaultTypeTransformation.java:315)
    	at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:243)
    	at org.spockframework.runtime.GroovyRuntimeUtil.coerce(GroovyRuntimeUtil.java:49)
    	at org.spockframework.mock.response.ConstantResponseGenerator.doRespond(ConstantResponseGenerator.java:35)
    	at org.spockframework.mock.response.SingleResponseGenerator.respond(SingleResponseGenerator.java:32)
    	at org.spockframework.mock.response.ResponseGeneratorChain.respond(ResponseGeneratorChain.java:44)
    	at org.spockframework.mock.runtime.MockInteraction.accept(MockInteraction.java:73)
    	at org.spockframework.mock.runtime.MockInteractionDecorator.accept(MockInteractionDecorator.java:50)
    	at org.spockframework.mock.runtime.InteractionScope$1.accept(InteractionScope.java:57)
    	at org.spockframework.mock.runtime.MockController.handle(MockController.java:40)
    	at org.spockframework.mock.runtime.JavaMockInterceptor.intercept(JavaMockInterceptor.java:86)
    	at org.spockframework.mock.runtime.DynamicProxyMockInterceptorAdapter.invoke(DynamicProxyMockInterceptorAdapter.java:34)
    	at jdk.proxy3/jdk.proxy3.$Proxy96.getApplication(Unknown Source)
    	at com.netflix.spinnaker.gate.services.ApplicationService$Front50ApplicationRetriever$_callWithMdc_closure1.doCall(ApplicationService.groovy:533)
    	at com.netflix.spinnaker.gate.services.ApplicationService$Front50ApplicationRetriever$_callWithMdc_closure1.call(ApplicationService.groovy)
    	at com.netflix.spinnaker.security.AuthenticatedRequest.lambda$wrapCallableForPrincipal$0(AuthenticatedRequest.java:272)
    	at com.netflix.spinnaker.gate.services.ApplicationService$Front50ApplicationRetriever.callWithMdc(ApplicationService.groovy:531)
    	at com.netflix.spinnaker.gate.services.ApplicationService$Front50ApplicationRetriever.callWithMdc(ApplicationService.groovy)
    	at com.netflix.spinnaker.gate.services.MdcWrappedCallable.call(MdcWrappedCallable.java:41)
    	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    	at java.base/java.lang.Thread.run(Thread.java:833)
@dbyron-sf dbyron-sf added the ready to merge Approved and ready for merge label Sep 12, 2024
@mergify mergify bot added the auto merged label Sep 12, 2024
@mergify mergify bot merged commit bd9b281 into spinnaker:master Sep 12, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants