-
Notifications
You must be signed in to change notification settings - Fork 629
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(standalone-canary-analysis): add SCAPE complete event listener a…
…nd archive the status response object in the object store. (#593)
- Loading branch information
Showing
29 changed files
with
208 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...alonecanaryanalysis/event/listener/StandaloneCanaryAnalysisExecutionArchivalListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.netflix.kayenta.standalonecanaryanalysis.event.listener; | ||
|
||
import com.netflix.kayenta.security.AccountCredentials; | ||
import com.netflix.kayenta.security.AccountCredentialsRepository; | ||
import com.netflix.kayenta.security.CredentialsHelper; | ||
import com.netflix.kayenta.standalonecanaryanalysis.event.StandaloneCanaryAnalysisExecutionCompletedEvent; | ||
import com.netflix.kayenta.storage.ObjectType; | ||
import com.netflix.kayenta.storage.StorageServiceRepository; | ||
import java.util.Optional; | ||
import lombok.extern.slf4j.Slf4j; | ||
import lombok.val; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.event.EventListener; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Slf4j | ||
@Component | ||
public class StandaloneCanaryAnalysisExecutionArchivalListener { | ||
|
||
private final AccountCredentialsRepository accountCredentialsRepository; | ||
private final StorageServiceRepository storageServiceRepository; | ||
|
||
@Autowired | ||
public StandaloneCanaryAnalysisExecutionArchivalListener( | ||
AccountCredentialsRepository accountCredentialsRepository, | ||
StorageServiceRepository storageServiceRepository) { | ||
this.accountCredentialsRepository = accountCredentialsRepository; | ||
this.storageServiceRepository = storageServiceRepository; | ||
} | ||
|
||
@EventListener | ||
public void onApplicationEvent(StandaloneCanaryAnalysisExecutionCompletedEvent event) { | ||
val response = event.getCanaryAnalysisExecutionStatusResponse(); | ||
|
||
Optional.ofNullable(response.getStorageAccountName()) | ||
.ifPresent( | ||
storageAccountName -> { | ||
val resolvedStorageAccountName = | ||
CredentialsHelper.resolveAccountByNameOrType( | ||
storageAccountName, | ||
AccountCredentials.Type.OBJECT_STORE, | ||
accountCredentialsRepository); | ||
|
||
val storageService = | ||
storageServiceRepository | ||
.getOne(resolvedStorageAccountName) | ||
.orElseThrow( | ||
() -> | ||
new IllegalArgumentException( | ||
"No storage service was configured; unable to archive results.")); | ||
|
||
storageService.storeObject( | ||
resolvedStorageAccountName, | ||
ObjectType.STANDALONE_CANARY_RESULT_ARCHIVE, | ||
response.getPipelineId(), | ||
response); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.