Skip to content
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

Merged

Conversation

ameijer
Copy link
Contributor

@ameijer ameijer commented Mar 5, 2024

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?

  • Closes ...

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?

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>
Copy link

vercel bot commented Mar 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
opencost ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 5, 2024 8:29pm


func TestPipelineService(t *testing.T) {
// establish temporary test assets dir
dir, err := os.MkdirTemp("", "ocplugin-*")
Copy link
Contributor

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()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good thinking

@@ -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),
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

@nik-kc nik-kc left a 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>
@cliffcolvin cliffcolvin merged commit c35bef4 into opencost:plugin-working-branch Mar 5, 2024
3 checks passed
}

key = strings.TrimPrefix(key, ",")
Copy link
Contributor

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
Copy link
Contributor

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) {
Copy link
Contributor

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)
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants