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

"Initialization" Output Returned as Stdout #5003

Open
BoweFlex opened this issue Jul 30, 2024 · 3 comments
Open

"Initialization" Output Returned as Stdout #5003

BoweFlex opened this issue Jul 30, 2024 · 3 comments

Comments

@BoweFlex
Copy link

BoweFlex commented Jul 30, 2024

The first time that any mc command is run, the following output is given:

mc: Configuration written to `/root/.mc/config.json`. Please update your access credentials.
mc: Successfully created `/root/.mc/share`.
mc: Initialized share uploads `/root/.mc/share/uploads.json` file.
mc: Initialized share downloads `/root/.mc/share/downloads.json` file.

Because of this, some situations cannot be automated properly due to this being returned when retrieving stdout from a command that just happens to be the first execution of mc (i.e. putting the output of an mc cat command into a variable. This is especially problematic with something like running an automated job pushing data through mc on a docker container with environment variables to control MC access.

Expected behavior

I think there are a few potential fixes, but without looking more I'm not positive what makes the most sense for this project:

  1. Add an optional --quiet flag to filter out some "informational" messages like this.
  2. Add an mc init command, to create this configuration without any other expected output.
  3. Change sections that output informational messages (i.e. https://github.com/minio/mc/blob/master/cmd/main.go#L271) to use console.Errorln rather than console.Infoln, which should route these messages to stderr rather than stdout and allow users to filter to receive only the output they want.

Actual behavior

When run for the first time, or after removing config (i.e. rm -rf /root/.mc):

mc cat my_subdir/base_timestamp
mc: Configuration written to `/root/.mc/config.json`. Please update your access credentials.
mc: Successfully created `/root/.mc/share`.
mc: Initialized share uploads `/root/.mc/share/uploads.json` file.
mc: Initialized share downloads `/root/.mc/share/downloads.json` file.
<contents of file>

Results are the same with something like:

mc cat my_subdir/base_timestamp 2>/dev/null
mc: Configuration written to `/root/.mc/config.json`. Please update your access credentials.
mc: Successfully created `/root/.mc/share`.
mc: Initialized share uploads `/root/.mc/share/uploads.json` file.
mc: Initialized share downloads `/root/.mc/share/downloads.json` file.
<contents of file>

Steps to reproduce the behavior

Start docker container w/ mc installed, and/or remove /root/.mc, and try running an mc command.

mc --version

Confirmed on both:

  • mc version RELEASE.2024-04-29T09-56-05Z
  • mc version RELEASE.2021-03-23T05-46-11Z

System information

Tested on rocky linux 9

@taran-p
Copy link
Contributor

taran-p commented Jul 31, 2024

Does the --quiet flag fit your needs?

@harshavardhana
Copy link
Member

we will fix this @BoweFlex

@BoweFlex
Copy link
Author

BoweFlex commented Aug 6, 2024

Does the --quiet flag fit your needs?

No, this output is returned either way. I didn't realize the flag was already included, it must not be working as expected.

Thanks @harshavardhana

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

No branches or pull requests

3 participants