-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'kfp-release-2.0.1' into 2.0.x
Signed-off-by: Yihong Wang <[email protected]>
- Loading branch information
Showing
42 changed files
with
487 additions
and
132 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.0.0 | ||
2.0.1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package client | ||
|
||
import ( | ||
log "github.com/sirupsen/logrus" | ||
"os" | ||
"sync" | ||
"time" | ||
) | ||
|
||
type TokenRefresherInterface interface { | ||
GetToken() string | ||
RefreshToken() error | ||
} | ||
|
||
const SaTokenFile = "/var/run/secrets/kubeflow/tokens/persistenceagent-sa-token" | ||
|
||
type FileReader interface { | ||
ReadFile(filename string) ([]byte, error) | ||
} | ||
|
||
type tokenRefresher struct { | ||
mu sync.RWMutex | ||
interval *time.Duration | ||
token string | ||
fileReader *FileReader | ||
} | ||
|
||
type FileReaderImpl struct{} | ||
|
||
func (r *FileReaderImpl) ReadFile(filename string) ([]byte, error) { | ||
return os.ReadFile(filename) | ||
} | ||
|
||
func NewTokenRefresher(interval time.Duration, fileReader FileReader) *tokenRefresher { | ||
if fileReader == nil { | ||
fileReader = &FileReaderImpl{} | ||
} | ||
|
||
tokenRefresher := &tokenRefresher{ | ||
interval: &interval, | ||
fileReader: &fileReader, | ||
} | ||
|
||
return tokenRefresher | ||
} | ||
|
||
func (tr *tokenRefresher) StartTokenRefreshTicker() error { | ||
err := tr.RefreshToken() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
ticker := time.NewTicker(*tr.interval) | ||
go func() { | ||
for range ticker.C { | ||
tr.RefreshToken() | ||
} | ||
}() | ||
return err | ||
} | ||
|
||
func (tr *tokenRefresher) GetToken() string { | ||
tr.mu.RLock() | ||
defer tr.mu.RUnlock() | ||
return tr.token | ||
} | ||
|
||
func (tr *tokenRefresher) RefreshToken() error { | ||
tr.mu.Lock() | ||
defer tr.mu.Unlock() | ||
b, err := (*tr.fileReader).ReadFile(SaTokenFile) | ||
if err != nil { | ||
log.Errorf("Error reading persistence agent service account token '%s': %v", SaTokenFile, err) | ||
return err | ||
} | ||
tr.token = string(b) | ||
return nil | ||
} |
Oops, something went wrong.