-
Notifications
You must be signed in to change notification settings - Fork 60
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
new(cmd,internal/utils,pkg/driver): use correct engine.kind
config key
#357
Conversation
cmd/driver/config/config.go
Outdated
return err | ||
} | ||
if err = checkFalcoRunsWithDrivers(cfg.Engine.Kind); err != nil { | ||
return err |
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 am not sure whether we should error out in this case.
ConfigMap loop does just continue
to the next configmap found, if any.
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 think we might not want to give an error in this case but just print a warning?
Indeed, we might want to add a -f,--force
option to force the update.
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 added the changes in the latest commit.
Example output when running fine and when running with the warning:
sudo ./falcoctl driver config --host-root "." --type ebpf
2023-11-24 12:20:02 INFO Running falcoctl driver config driver host root: . driver type: ebpf
sudo ./falcoctl driver config --host-root "." --type ebpf
2023-11-24 12:20:09 INFO Running falcoctl driver config driver host root: . driver type: ebpf
2023-11-24 12:20:09 WARN Avoid updating Falco configuration config: etc/falco/falco.yaml reason: engine.kind is not driver driven: gvisor
@@ -28,7 +28,7 @@ import ( | |||
) | |||
|
|||
// TypeBpf is the string for the bpf driver type. | |||
const TypeBpf = "bpf" | |||
const TypeBpf = "ebpf" |
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.
New name. See falcosecurity/falco#2413
@@ -23,7 +23,7 @@ import ( | |||
) | |||
|
|||
// TypeModernBpf is the string for the bpf driver type. | |||
const TypeModernBpf = "modern-bpf" | |||
const TypeModernBpf = "modern_ebpf" |
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.
New name, see falcosecurity/falco#2413
…key. Moreover, added a new ReplaceTextInFile utils, and added tests for it and ReplaceLineInFile. Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
…a non-driver driven kind. Instead, print a warning. Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
7bc0860
to
635e873
Compare
Rebased on main. |
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.
Hey @FedeDP, left some comments.
type engineCfg struct { | ||
Kind string `yaml:"kind"` | ||
} | ||
type falcoCfg struct { | ||
Engine engineCfg `yaml:"engine"` | ||
} |
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.
Can we please declare these new types outside the function?
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 think they are good there since they are only needed to unmarshal the Falco engine.kind
configuration key; no need to expose them elsewhere in the package.
yamlFile, err := os.ReadFile(filepath.Clean(falcoCfgFile)) | ||
if err != nil { | ||
return err | ||
} | ||
cfg := falcoCfg{} | ||
if err = yaml.Unmarshal(yamlFile, &cfg); err != nil { | ||
return err | ||
} |
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.
Wondering if there is a better way to do this.
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.
We could just manually parse the file line by line, but i think this is the best way to achieve it actually.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com> Co-authored-by: Aldo Lacuku <aldo@lacuku.eu>
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alacuku, FedeDP, leogr The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/milestone v0.7.0 |
What type of PR is this?
/kind cleanup
Any specific area of the project related to this PR?
/area library
/area cli
/area tests
What this PR does / why we need it:
Moreover, added a new ReplaceTextInFile utils, and added tests for it and ReplaceLineInFile.
Which issue(s) this PR fixes:
Refs #327
Fixes #
Special notes for your reviewer: