Merge pull request #76385 from sttts/sttts-kube-aggregator-openapi-fix-existing

kube-aggregator: update existing openapi spec info if pre-existing
This commit is contained in:
Kubernetes Prow Robot 2019-05-08 14:32:05 -07:00 committed by GitHub
commit 0adbd6989d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -202,15 +202,16 @@ func (s *specAggregator) tryUpdatingServiceSpecs(specInfo *openAPISpecInfo) erro
if specInfo == nil {
return fmt.Errorf("invalid input: specInfo must be non-nil")
}
orgSpecInfo, exists := s.openAPISpecs[specInfo.apiService.Name]
origSpecInfo, existedBefore := s.openAPISpecs[specInfo.apiService.Name]
s.openAPISpecs[specInfo.apiService.Name] = specInfo
// Skip aggregation if OpenAPI spec didn't change
if exists && orgSpecInfo != nil && orgSpecInfo.etag == specInfo.etag {
if existedBefore && origSpecInfo != nil && origSpecInfo.etag == specInfo.etag {
return nil
}
s.openAPISpecs[specInfo.apiService.Name] = specInfo
if err := s.updateOpenAPISpec(); err != nil {
if exists {
s.openAPISpecs[specInfo.apiService.Name] = orgSpecInfo
if existedBefore {
s.openAPISpecs[specInfo.apiService.Name] = origSpecInfo
} else {
delete(s.openAPISpecs, specInfo.apiService.Name)
}