Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #712 from navikt/dev/unleash-next
Browse files Browse the repository at this point in the history
Dev/unleash next
  • Loading branch information
jstnhlj authored Dec 1, 2023
2 parents 0ecf248 + 4cae226 commit cd38435
Show file tree
Hide file tree
Showing 24 changed files with 167 additions and 109 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,23 @@ jobs:
# tag_name: release/prod@${{ env.TAG }}
# name: Release to prod
# prerelease: false

apply-apitoken-unleash:
name: Legger til ApiToken for Unleash
runs-on: ubuntu-latest
needs: [test-build-and-push]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: deploy to dev
uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: dev-gcp
RESOURCE: nais/unleash-apitoken-dev.yaml
- name: deploy to prod
uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: prod-gcp
RESOURCE: nais/unleash-apitoken-prod.yaml
4 changes: 4 additions & 0 deletions nais/nais-dev-gcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ spec:
enabled: true
envFrom:
- secret: veilarbregistrering
- secret: veilarbregistrering-unleash-api-token
image: {{image}}
ingresses:
- https://veilarbregistrering.intern.dev.nav.no
Expand Down Expand Up @@ -65,6 +66,8 @@ spec:
value: https://ereg-services-q1.dev-fss-pub.nais.io/ereg
- name: SPRING_PROFILES_ACTIVE
value: gcp
- name: UNLEASH_SERVER_API_URL
value: https://paw-unleash-api.nav.cloud.nais.io/api
leaderElection: true
kafka:
pool: nav-dev
Expand Down Expand Up @@ -137,6 +140,7 @@ spec:
- host: norg2.dev-fss-pub.nais.io
- host: oppgave-q1.dev-fss-pub.nais.io
- host: ereg-services-q1.dev-fss-pub.nais.io
- host: paw-unleash-api.nav.cloud.nais.io
rules:
- application: aareg-services-nais-q1
namespace: arbeidsforhold
Expand Down
4 changes: 4 additions & 0 deletions nais/nais-prod-gcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ spec:
enabled: true
envFrom:
- secret: veilarbregistrering
- secret: veilarbregistrering-unleash-api-token
image: {{image}}
ingresses:
- https://veilarbregistrering.intern.nav.no
Expand Down Expand Up @@ -65,6 +66,8 @@ spec:
value: https://ereg-services.prod-fss-pub.nais.io/ereg
- name: SPRING_PROFILES_ACTIVE
value: gcp
- name: UNLEASH_SERVER_API_URL
value: https://paw-unleash-api.nav.cloud.nais.io/api
leaderElection: true
kafka:
pool: nav-prod
Expand Down Expand Up @@ -133,6 +136,7 @@ spec:
- host: norg2.prod-fss-pub.nais.io
- host: oppgave.prod-fss-pub.nais.io
- host: ereg-services.prod-fss-pub.nais.io
- host: paw-unleash-api.nav.cloud.nais.io
rules:
- application: aareg-services-nais
namespace: arbeidsforhold
Expand Down
14 changes: 14 additions & 0 deletions nais/unleash-apitoken-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: unleash.nais.io/v1
kind: ApiToken
metadata:
name: veilarbregistrering-unleash
namespace: paw
labels:
"team": "paw"
spec:
unleashInstance:
apiVersion: unleash.nais.io/v1
kind: RemoteUnleash
name: paw
secretName: veilarbregistrering-unleash-api-token
environment: development
14 changes: 14 additions & 0 deletions nais/unleash-apitoken-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: unleash.nais.io/v1
kind: ApiToken
metadata:
name: veilarbregistrering-unleash
namespace: paw
labels:
"team": "paw"
spec:
unleashInstance:
apiVersion: unleash.nais.io/v1
kind: RemoteUnleash
name: paw
secretName: veilarbregistrering-unleash-api-token
environment: production
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@
<artifactId>job</artifactId>
<version>${common.version}</version>
</dependency>
<dependency>
<groupId>no.nav.common</groupId>
<artifactId>feature-toggle</artifactId>
<version>${common.version}</version>
</dependency>
<dependency>
<groupId>no.nav.common</groupId>
<artifactId>token-client</artifactId>
Expand Down Expand Up @@ -188,6 +183,11 @@
<scope>runtime</scope>
<version>1</version>
</dependency>
<dependency>
<groupId>io.getunleash</groupId>
<artifactId>unleash-client-java</artifactId>
<version>9.1.1</version>
</dependency>


<!-- Test dependencies -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package no.nav.fo.veilarbregistrering.arbeidssoker.formidlingsgruppe.kafka

import no.nav.common.featuretoggle.UnleashClient
import io.getunleash.DefaultUnleash
import io.getunleash.Unleash
import no.nav.common.log.MDCConstants
import no.nav.fo.veilarbregistrering.arbeidssoker.formidlingsgruppe.FormidlingsgruppeMottakService
import no.nav.fo.veilarbregistrering.arbeidssoker.formidlingsgruppe.kafka.FormidlingsgruppeMapper.Companion.map
Expand All @@ -25,7 +26,7 @@ class FormidlingsgruppeKafkaConsumer internal constructor(
private val kafkaConsumerProperties: Properties,
private val topic: String,
private val formidlingsgruppeMottakService: FormidlingsgruppeMottakService,
private val unleashClient: UnleashClient
private val unleashClient: Unleash
) : Runnable {
init {
val forsinkelseIMinutterVedOppstart = 5
Expand Down Expand Up @@ -96,4 +97,4 @@ class FormidlingsgruppeKafkaConsumer internal constructor(
private const val mdcTopicKey = "topic"
private const val KILL_SWITCH_TOGGLE_NAME = "veilarbregistrering.stopKonsumeringAvFormidlingsgruppe"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package no.nav.fo.veilarbregistrering.arbeidssoker.meldekort.kafka

import no.nav.common.featuretoggle.UnleashClient
import io.getunleash.Unleash
import no.nav.common.log.MDCConstants
import no.nav.fo.veilarbregistrering.arbeidssoker.meldekort.MeldekortMottakService
import no.nav.fo.veilarbregistrering.config.objectMapper
Expand All @@ -17,7 +17,7 @@ import java.util.concurrent.TimeUnit
class MeldekortKafkaConsumer internal constructor(
private val kafkaConsumerProperties: Properties,
private val topic: String,
private val unleashClient: UnleashClient,
private val unleashClient: Unleash,
private val meldekortMottakService: MeldekortMottakService
) : Runnable {
init {
Expand Down Expand Up @@ -93,4 +93,4 @@ class MeldekortKafkaConsumer internal constructor(
private const val KILL_SWITCH_TOGGLE_NAME = "veilarbregistrering.stopKonsumeringAvMeldekort"
}

}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package no.nav.fo.veilarbregistrering.config

import io.getunleash.Unleash
import no.nav.common.auth.context.AuthContextHolder
import no.nav.common.featuretoggle.UnleashClient
import no.nav.common.health.selftest.SelfTestChecks
import no.nav.common.job.leader_election.LeaderElectionClient
import no.nav.fo.veilarbregistrering.aktorIdCache.AktorIdCacheService
Expand Down Expand Up @@ -189,7 +189,7 @@ class ServiceBeansConfig {
fun sykmeldtResource(
tilgangskontrollService: TilgangskontrollService,
userService: UserService,
unleashClient: UnleashClient,
unleashClient: Unleash,
sykmeldtRegistreringService: SykmeldtRegistreringService,
navVeilederService: NavVeilederService,
): SykmeldtResource {
Expand All @@ -201,7 +201,7 @@ class ServiceBeansConfig {
@Bean
fun reaktiveringResource(
userService: UserService,
unleashClient: UnleashClient,
unleashClient: Unleash,
tilgangskontrollService: TilgangskontrollService,
reaktiveringBrukerService: ReaktiveringBrukerService
): ReaktiveringResource {
Expand All @@ -216,7 +216,7 @@ class ServiceBeansConfig {
userService: UserService,
brukerRegistreringService: BrukerRegistreringService,
navVeilederService: NavVeilederService,
unleashClient: UnleashClient
unleashClient: Unleash
): OrdinaerBrukerRegistreringResource {
return OrdinaerBrukerRegistreringResource(
tilgangskontrollService, userService, brukerRegistreringService, navVeilederService, unleashClient
Expand Down Expand Up @@ -259,7 +259,7 @@ class ServiceBeansConfig {
}

@Bean
fun featuretoggleResource(unleashClient: UnleashClient): FeaturetoggleResource {
fun featuretoggleResource(unleashClient: Unleash): FeaturetoggleResource {
return FeaturetoggleResource(unleashClient)
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package no.nav.fo.veilarbregistrering.featuretoggle

import no.nav.common.auth.context.AuthContextHolder
import no.nav.common.featuretoggle.UnleashClient
import no.nav.common.featuretoggle.UnleashClientImpl
import no.nav.fo.veilarbregistrering.config.requireApplicationName
import io.getunleash.DefaultUnleash
import io.getunleash.Unleash
import io.getunleash.util.UnleashConfig
import no.nav.fo.veilarbregistrering.config.requireProperty
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
Expand All @@ -12,15 +11,20 @@ import org.springframework.context.annotation.Configuration
class UnleashConfig {

@Bean
fun unleashClient(authContextHolder: AuthContextHolder): UnleashClient {
return UnleashClientImpl(
requireProperty(UNLEASH_API_URL_PROPERTY),
requireApplicationName(),
listOf(ByUserIdStrategy(authContextHolder))
)
fun unleashClient(): Unleash {
val config = UnleashConfig.builder()
.appName(APP_NAME)
.instanceId(APP_NAME)
.unleashAPI(requireProperty(UNLEASH_SERVER_API_URL))
.apiKey(requireProperty(UNLEASH_SERVER_API_TOKEN))
.build()

return DefaultUnleash(config)
}

companion object {
const val UNLEASH_API_URL_PROPERTY = "UNLEASH_API_URL"
const val UNLEASH_SERVER_API_URL = "UNLEASH_SERVER_API_URL"
const val UNLEASH_SERVER_API_TOKEN = "UNLEASH_SERVER_API_TOKEN"
const val APP_NAME = "veilarbregistrering"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package no.nav.fo.veilarbregistrering.featuretoggle.resources

import no.nav.common.featuretoggle.UnleashClient
import io.getunleash.Unleash
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController

@RestController
class FeaturetoggleResource(private val unleashClient: UnleashClient) {
class FeaturetoggleResource(private val unleashClient: Unleash) {

@GetMapping("/api/featuretoggle")
fun hentFeatureToggles(@RequestParam("feature") vararg featureName: String): Map<String, Boolean> {
return featureName.associateWith { unleashClient.isEnabled(it) }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package no.nav.fo.veilarbregistrering.helsesjekk

import no.nav.common.abac.Pep
import no.nav.common.featuretoggle.UnleashClient
import no.nav.common.health.selftest.SelfTestCheck
import no.nav.common.health.selftest.SelfTestChecks
import no.nav.common.health.selftest.SelfTestMeterBinder
Expand All @@ -23,7 +22,7 @@ class HelsesjekkConfig {
fun selfTestChecks(
dbHelsesjekk: DatabaseHelsesjekk,
veilarbPep: Pep,
unleashClient: UnleashClient,
// unleashClient: Unleash,
oppfolgingClient: OppfolgingClient,
krrClient: DigDirKrrProxyClient,
aaregRestClient: AaregRestClient,
Expand All @@ -35,7 +34,7 @@ class HelsesjekkConfig {
val selfTestChecks = listOf(
SelfTestCheck("Ping (sporring) mot Databasen til veilarregistrering.", true, dbHelsesjekk),
SelfTestCheck("Ping mot ABAC tilgangskontroll", true, veilarbPep.abacClient),
SelfTestCheck("Ping mot Unleash (tilbyr feature-toggles)", false, unleashClient),
// SelfTestCheck("Ping mot Unleash (tilbyr feature-toggles)", false, unleashClient),
SelfTestCheck("Ping Oppfolging", false, oppfolgingClient),
SelfTestCheck("Ping Kontakt og reservasjonsregisteret (KRR)", false, krrClient),
SelfTestCheck("Ping Arbeid og arbeidstager registeret (Aareg)", false, aaregRestClient),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import io.confluent.kafka.schemaregistry.client.SchemaRegistryClientConfig
import io.confluent.kafka.serializers.KafkaAvroDeserializerConfig
import io.confluent.kafka.serializers.KafkaAvroSerializer
import io.confluent.kafka.serializers.KafkaAvroSerializerConfig
import io.getunleash.Unleash
import no.nav.arbeid.soker.profilering.ArbeidssokerProfilertEvent
import no.nav.arbeid.soker.registrering.ArbeidssokerRegistrertEvent
import no.nav.common.featuretoggle.UnleashClient
import no.nav.fo.veilarbregistrering.arbeidssoker.formidlingsgruppe.FormidlingsgruppeMottakService
import no.nav.fo.veilarbregistrering.arbeidssoker.formidlingsgruppe.kafka.FormidlingsgruppeKafkaConsumer
import no.nav.fo.veilarbregistrering.arbeidssoker.meldekort.MeldekortMottakService
Expand Down Expand Up @@ -82,7 +82,7 @@ class KafkaConfig {

@Bean
fun formidlingsgruppeKafkaConsumer(
unleashClient: UnleashClient,
unleashClient: Unleash,
formidlingsgruppeMottakService: FormidlingsgruppeMottakService
): FormidlingsgruppeKafkaConsumer {
val envSuffix = if (isProduction()) "p" else "q"
Expand All @@ -100,7 +100,7 @@ class KafkaConfig {

@Bean
fun meldekortKafkaConsumer(
unleashClient: UnleashClient,
unleashClient: Unleash,
meldekortMottakService: MeldekortMottakService
): MeldekortKafkaConsumer {
val envSuffix = if (isProduction()) "p" else "q1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package no.nav.fo.veilarbregistrering.registrering.ordinaer.resources

import no.nav.common.featuretoggle.UnleashClient
import io.getunleash.Unleash
import no.nav.fo.veilarbregistrering.autorisasjon.TilgangskontrollService
import no.nav.fo.veilarbregistrering.bruker.UserService
import no.nav.fo.veilarbregistrering.registrering.ordinaer.BrukerRegistreringService
Expand All @@ -18,7 +18,7 @@ class OrdinaerBrukerRegistreringResource(
private val userService: UserService,
private val brukerRegistreringService: BrukerRegistreringService,
private val navVeilederService: NavVeilederService,
private val unleashClient: UnleashClient
private val unleashClient: Unleash
) : OrdinaerBrukerRegistreringApi {

@PostMapping("/fullfoerordinaerregistrering")
Expand All @@ -38,4 +38,4 @@ class OrdinaerBrukerRegistreringResource(
}

private fun tjenesteErNede(): Boolean = unleashClient.isEnabled("arbeidssokerregistrering.nedetid")
}
}
Loading

0 comments on commit cd38435

Please sign in to comment.