New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Atm/plugin ingestion #2610
Atm/plugin ingestion #2610
Conversation
Signed-off-by: Alex Meijer <ameijer@kubecost.com>
Signed-off-by: Alex Meijer <ameijer@kubecost.com>
Signed-off-by: Alex Meijer <ameijer@kubecost.com>
Signed-off-by: Alex Meijer <ameijer@kubecost.com>
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
||
func TestPipelineService(t *testing.T) { | ||
// establish temporary test assets dir | ||
dir, err := os.MkdirTemp("", "ocplugin-*") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we update this to use t.TempDir()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good thinking
pkg/customcost/pipelineservice.go
Outdated
@@ -81,23 +82,18 @@ func getRegisteredPlugins(configDir string, execDir string) (map[string]*plugin. | |||
configs[name] = &plugin.ClientConfig{ | |||
HandshakeConfig: handshakeConfig, | |||
Plugins: pluginMap, | |||
Cmd: exec.Command(execDir+"/"+name+".ocplugin."+version.Architecture, config), | |||
Cmd: exec.Command(execDir+"/"+name+".ocplugin."+runtime.GOOS+"."+version.Architecture, config), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we pull out this duplicate string concatenation into a variable? Also, how is this string format determined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refactored it to use a fmt string, that hopefully cleans it up. Since the plugins run as binaries, the executable name depends on the OS and processor. The idea is that the person would get the binary built for their machine from here: https://github.com/opencost/opencost-plugins/releases/tag/v0.0.3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a couple small notes, but overall looks good!
Signed-off-by: Alex Meijer <ameijer@kubecost.com>
} | ||
|
||
key = strings.TrimPrefix(key, ",") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You make this key and then do nothing with it. What is it for?
@@ -54,116 +58,175 @@ type CustomCostIngestor struct { | |||
lastRun time.Time | |||
runs int | |||
creationTime time.Time | |||
coverage opencost.Window | |||
coverage map[string]opencost.Window |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stringly-typed keys are something I'm not a huge fan of -- what is the key supposed to represent here? If its a plugin, why not have one CustomCostIngestor per plugin?
// log.Infof("CloudCost: ingestor: is already running") | ||
// return | ||
// } | ||
func (ing *CustomCostIngestor) buildSingleDomain(start, end time.Time, domain string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel that this should return an error -- I lean towards having the highest-possible-level component log errors
|
||
dir := t.TempDir() | ||
|
||
err := os.MkdirAll(dir+"/config", 0777) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the future, its better to use
import "path/filepath"
os.MkdirAll(filepath.Join(dir, "config"))
instead of string ops when constructing paths
What does this PR change?
Does this PR relate to any other PRs?
How will this PR impact users?
Does this PR address any GitHub or Zendesk issues?
How was this PR tested?
Does this PR require changes to documentation?
Have you labeled this PR and its corresponding Issue as "next release" if it should be part of the next OpenCost release? If not, why not?