generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Major refactoring & implement standalone mode (#12)
* Major refactoring & start work on standalone mode (part 1) Overhaul the code from a PoC to a semi-productive state. Major changes done to the Processors, mainly the UpdateWatchConfig handler, which provisions k8s managers. Simplify large parts of the codebase. Handle context cancellation propagation properly. Ensure resource cleanup on graceful shutdown - do not leave hanging goroutines. * Start gRPC stream with proper context * Refactoring part 2 Fix comments Exit Pod with status 1 in case the Manager can't be started (in K8s mode) Remove caching of auth header in HTTP executor Improvement of error messages * Fix client cert creation in standalone mode * Update env vars names * Improve logging and fix some issues * Handle session auto-config better * Delete redundant cache struct * Add some more logs to task processors * Fix k8s managers and controllers * Renaming * Fix some TODOs * Fix build * Refactoring final: Reimplement auth header caching properly * Small cleanup * Bump vulnerable dependencies * Fix basic auth header * Fix comments
- Loading branch information
Showing
71 changed files
with
1,550 additions
and
2,227 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package main | ||
|
||
import ( | ||
"crypto/sha256" | ||
"encoding/hex" | ||
"flag" | ||
"io" | ||
"log" | ||
"os" | ||
) | ||
|
||
type Options struct { | ||
DisplayVersion bool | ||
StandaloneMode bool | ||
InstanceId string | ||
MaxConnRetries uint | ||
} | ||
|
||
const ( | ||
standaloneModeOpt = "standalone-mode" | ||
instanceIdOpt = "instance-id" | ||
connRetriesOpt = "conn-retries" | ||
versionOpt = "version" | ||
) | ||
|
||
func (opts *Options) BindFlags(fs *flag.FlagSet) { | ||
hostname := getHashedHostname() | ||
|
||
fs.BoolVar(&opts.StandaloneMode, standaloneModeOpt, false, | ||
"Whether to run the Remote Work Processor in Standalone mode") | ||
fs.StringVar(&opts.InstanceId, instanceIdOpt, hostname, | ||
"Instance Identifier for the Remote Work Processor (only applicable for Standalone mode)") | ||
fs.UintVar(&opts.MaxConnRetries, connRetriesOpt, 3, "Number of retries for gRPC connection to AutoPi server") | ||
fs.BoolVar(&opts.DisplayVersion, versionOpt, false, "Display binary version and exit") | ||
} | ||
|
||
func getHashedHostname() string { | ||
hostname, err := os.Hostname() | ||
if err != nil { | ||
log.Printf("could not get hostname: %v\n", err) | ||
} else { | ||
hasher := sha256.New() | ||
io.WriteString(hasher, hostname) | ||
hostname = hex.EncodeToString(hasher.Sum(nil)) | ||
} | ||
return hostname | ||
} |
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.