Skip to content

Commit

Permalink
OP-16308: OP-16308: Wait and retry if connection fails. Also, css fil…
Browse files Browse the repository at this point in the history
…e missing fix. (spinnaker#217) (spinnaker#218)
  • Loading branch information
rahul-chekuri authored Jun 22, 2022
1 parent c9aeffe commit a64dfcd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions gate-core/gate-core.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ dependencies {
implementation "org.apache.commons:commons-lang3"
implementation group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.1'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-openfeign', version: '2.2.4.RELEASE'
compile group: 'org.springframework.retry', name: 'spring-retry', version: '1.2.2.RELEASE'
}

sourceSets {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.netflix.spinnaker.fiat.model.resources.Role
import com.netflix.spinnaker.fiat.shared.FiatPermissionEvaluator
import com.netflix.spinnaker.fiat.shared.FiatService
import com.netflix.spinnaker.fiat.shared.FiatStatus
import com.netflix.spinnaker.gate.retrofit.UpstreamBadRequest
import com.netflix.spinnaker.gate.security.SpinnakerUser
import com.netflix.spinnaker.gate.services.internal.ExtendedFiatService
import com.netflix.spinnaker.kork.core.RetrySupport
Expand All @@ -42,6 +43,8 @@ import javax.annotation.Nonnull
import java.time.Duration

import static com.netflix.spinnaker.gate.retrofit.UpstreamBadRequest.classifyError
import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Retryable;

@Slf4j
@Component
Expand Down Expand Up @@ -90,6 +93,8 @@ class PermissionService {
}
}


@Retryable(value = UpstreamBadRequest.class, maxAttempts = 3, backoff = @Backoff(delay = 4000l))
void loginWithRoles(String userId, Collection<String> roles) {
if (fiatStatus.isEnabled()) {
try {
Expand All @@ -98,6 +103,7 @@ class PermissionService {
permissionEvaluator.invalidatePermission(userId)
})
} catch (RetrofitError e) {
log.error("Exception caught while updating the roles. Will wait and retry: {}" , e)
throw classifyError(e)
}
}
Expand Down

Large diffs are not rendered by default.

0 comments on commit a64dfcd

Please sign in to comment.