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

StringSliceTrySplit: return a copy of the underlying slice #3870

Merged
merged 2 commits into from Jun 15, 2020

Conversation

rhafer
Copy link
Contributor

@rhafer rhafer commented Jun 12, 2020

/kind bug

What this PR does / why we need it:

Make StringSliceTrySplit return a copy of the underlying slice as otherwise the underlying flags in the ctx might be overriden, which can cause issue when the config is reloaded (GetConfigFromContext() is called more than once).

Which issue(s) this PR fixes:

Fixes #3862

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Fix handling of the --cni-plugin-dir and other multivalue command line flags

@openshift-ci-robot openshift-ci-robot added dco-signoff: yes Indicates the PR's author has DCO signed all their commits. kind/bug Categorizes issue or PR as related to a bug. labels Jun 12, 2020
@openshift-ci-robot
Copy link

Hi @rhafer. Thanks for your PR.

I'm waiting for a cri-o member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

1 similar comment
@openshift-ci-robot
Copy link

Hi @rhafer. Thanks for your PR.

I'm waiting for a cri-o member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 12, 2020
@haircommander
Copy link
Member

/ok-to-test

@openshift-ci-robot openshift-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 12, 2020
Copy link
Member

@saschagrunert saschagrunert left a comment

Choose a reason for hiding this comment

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

LGTM
/retest

@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhafer, saschagrunert

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

1 similar comment
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhafer, saschagrunert

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 12, 2020
@haircommander
Copy link
Member

/ok-to-test

@saschagrunert
Copy link
Member

/test integration_crun

@TomSweeneyRedHat
Copy link
Contributor

LGTM

Comment on lines 52 to 54
conf, ok := c.App.Metadata["config"].(*libconfig.Config)
if !ok {
return errors.New("type assertion error when accessing server config")
Copy link
Member

Choose a reason for hiding this comment

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

what's the motivation for dropping this? I personally liked having this clunky piece of code in a function and not duplicated

Copy link
Member

Choose a reason for hiding this comment

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

ah! I see

instead of duplicating this code, we should rip out this part of the function

func GetConfigFromContext(c *cli.Context) (*libconfig.Config, error) {
    config, ok := c.App.Metadata["config"].(*libconfig.Config)
    if !ok {
        return nil, fmt.Errorf("type assertion error when accessing server config")
    }
}

func GetAndMergeConfigFromContext(c *cli.Context) (*libconfig.Config, error) {
    config, err := GetConfigFromContext(c)
    if err != nil {
        return nil, err
    }
    if err := mergeConfig(config, c); err != nil {
        return nil, err
    }
    return config, nil
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Otherwise the underlying flags in the ctx might be overriden, which
can cause issue when the config is reloaded (or GetConfigFromContext()
is called more than once).

Closes cri-o#3862

Signed-off-by: Ralf Haferkamp <rhafer@suse.com>
This splits out the config file loading and commandline argument
processing from GetConfigFromContext() so that subcommand like `crio
config' and `crio wipe` are able to fetch the configuration from the
context without reloading the config files. Apart from being inefficient
this also caused issues with StringSlice values being handled wrong.

Closes cri-o#3862

Signed-off-by: Ralf Haferkamp <rhafer@suse.com>
@umohnani8
Copy link
Member

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 15, 2020
@openshift-merge-robot openshift-merge-robot merged commit da5bf6f into cri-o:master Jun 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--cni-plugin-dir flag acts strangely
7 participants