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

oci os object put from STDIN not working in Cloud shell #490

Closed
RichardExley opened this issue Dec 16, 2021 · 15 comments
Closed

oci os object put from STDIN not working in Cloud shell #490

RichardExley opened this issue Dec 16, 2021 · 15 comments
Labels
SDK Issue pertains to the SDK itself and not specific to any service

Comments

@RichardExley
Copy link
Member

I am testing with oci cli 3.3.2. Here is a test script:

export BUCKET_NAME=bucketawk 'BEGIN { srand(); print int(1 + rand() * 1000000)}'`
oci os bucket create --compartment-id "$OCI_TENANCY" --name "$BUCKET_NAME"
TEXT="TextText"

oci os object put --bucket-name "$BUCKET_NAME" --name "Test1" --file - <<<"$TEXT"
echo -n "$TEXT" | oci os object put --bucket-name "$BUCKET_NAME" --name "Test2" --file -
echo "$TEXT" >TEXT_FILE
oci os object put --bucket-name "$BUCKET_NAME" --name "Test3" --file TEXT_FILE

for t in Test1 Test2 Test3; do
echo "$t:"
echo $(oci os object get -bn "$BUCKET_NAME" --name "$t" --file -)
done
`

Result (no errors) is:

`Test1:

Test2:

Test3:
TextText
`

@harshkumar-dev
Copy link
Member

I just tried in 3.4.0 and it worked fine. Could you try latest CLI?

16:34 $ oci --version
3.4.0

16:37 $ echo "my test" | oci os object put --bucket-name "$BUCKET_NAME" --name "Test1" --file -
Uploading object part [####################################] 100%
{
"etag": "eca02bb6-74d5-4f3c-ac2a-c43ec6e09a24",
"last-modified": "Fri, 17 Dec 2021 00:38:52 GMT",
"opc-multipart-md5": "w1Crx5PAkfat0nDCnmDfcg==-1"
}

@harshkumar-dev harshkumar-dev added the SDK Issue pertains to the SDK itself and not specific to any service label Dec 17, 2021
@harshkumar-dev
Copy link
Member

16:41 $ oci os object put --bucket-name "$BUCKET_NAME" --name "Test2" --file - <<<"my test"
Uploading object part [####################################] 100%
{
"etag": "f8b48c06-651e-46cd-81cd-b86c25c1af9e",
"last-modified": "Fri, 17 Dec 2021 00:41:54 GMT",
"opc-multipart-md5": "mvMVYVKv58zwwqD/PXVb3w==-1"
}

@RichardExley
Copy link
Member Author

I tried on 3.4.0 on MacOS and was unable to repro the bug. I can repro on Linux (cloud shell) 3.3.2. That is the current version on cloud shell. Are you able to repro on 3.3.2. This bug results in silent data loss and so I regard as very serious.

@harshkumar-dev
Copy link
Member

Normally Cloud shell lags by around 2 weeks to install latest version. Since this is not reproducible on latest CLI version, I would suggest installing latest version on CLI on Cloud shell using.

bash -c "$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)"

https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/cliinstall.htm

@harshkumar-dev
Copy link
Member

I just checked in 3.3.3 version and couldn't reproduce the error. Cloud shell is releasing 3.3.3 version. It should be updated in cloud shell soon.

10:06 $ oci --version
3.3.3
(cli-3.3.3) ✔ ~
10:06 $ echo "harsh test" | oci os object put --bucket-name "$BUCKET_NAME"--name "Test3" --file -
Uploading object part [####################################] 100%
{
"etag": "70bed229-6e18-4e6d-bf82-96ae9ac03161",
"last-modified": "Fri, 17 Dec 2021 18:06:53 GMT",
"opc-multipart-md5": "w1Crx5PAkfat0nDCnmDfcg==-1"
}
(cli-3.3.3) ✔ ~
10:06 $ oci os object put --bucket-name "$BUCKET_NAME" --name "Test4" --file - <<<"my test"
Uploading object part [####################################] 100%
{
"etag": "5d3d8ef3-2f6a-44c6-92e2-a18cb9d9e4a6",
"last-modified": "Fri, 17 Dec 2021 18:07:48 GMT",
"opc-multipart-md5": "mvMVYVKv58zwwqD/PXVb3w==-1"
}

@RichardExley
Copy link
Member Author

Have you identified the code change that introduced this bug? I ask because it may have had an impact on other functionality, for example other commands that accept input from STDIN.

I am puzzled that the unit test basic_cli_test_script.sh didn't detect this?

@harshkumar-dev
Copy link
Member

Are you sure its a bug in 3.3.2 version as I couldn't reproduce it? Can you create a virtual env and install "pip install oci-cli==3.3.2" and try?

(cli-3.3.2) ✘-1 ~
12:57 $ oci --version
3.3.2
(cli-3.3.2) ✔ ~
12:57 $ echo "harsh test" | oci os object put --bucket-name "$BUCKET_NAME" --name "Test5" --file -
Uploading object part [####################################] 100%
{
"etag": "7f2340cd-e1bb-4900-8fb2-eb97f2c6e7ec",
"last-modified": "Fri, 17 Dec 2021 20:57:48 GMT",
"opc-multipart-md5": "w1Crx5PAkfat0nDCnmDfcg==-1"
}
(cli-3.3.2) ✔ ~
12:57 $ oci os object put --bucket-name "$BUCKET_NAME" --name "Test6" --file - <<<"my test"
Uploading object part [####################################] 100%
{
"etag": "0a5ff76b-db03-4962-87f4-c725e8f20a51",
"last-modified": "Fri, 17 Dec 2021 20:58:31 GMT",
"opc-multipart-md5": "mvMVYVKv58zwwqD/PXVb3w==-1"
}

@RichardExley
Copy link
Member Author

I have reproduced it on two different tenancies using cloud shell. is there some debug or trace I can set to isolate the problem? Have you tried to repro on cloud shell?

@harshkumar-dev
Copy link
Member

this is from Cloud-shell:

(cli-3.3.2) h_harsh_ku@cloudshell:~ (us-phoenix-1)$ oci --version
3.3.2
(cli-3.3.2) h_harsh_ku@cloudshell:~ (us-phoenix-1)$ echo "harsh test" | oci os object put --bucket-name "$BUCKET_NAME" --name "Test8" --file -
{
"etag": "9241d733-08b7-4756-8de5-6208c2974a21",
"last-modified": "Fri, 17 Dec 2021 21:55:47 GMT",
"opc-content-md5": "1B2M2Y8AsgTpgAmY7PhCfg=="
}

@RichardExley
Copy link
Member Author

So you were able to repro? Note, no "Uploading object part [####################################] 100%".

@harshkumar-dev
Copy link
Member

The file "Test8" is uploaded.

I have slacked you. Please message me there so that we can have a zoom.

@harshkumar-dev
Copy link
Member

I tried uploading a file using STDIN on mac using 3.2.2 and 3.3.3 and 3.4.0 and it worked fine.

But on Cloud shell, the uploaded file is 0 byte.

(cli-3-4.0) h_harsh_ku@cloudshell:~ (us-phoenix-1)$ oci os object put --bucket-name Harsh-test --name "Test2" --file - <<<"my test"
(cli-3-4.0) h_harsh_ku@cloudshell:~ (us-phoenix-1)$ oci os object put --bucket-name Harsh-test --name "Tes11" --file - <<<"my test"
Uploading object part [####################################] 100%
{
"etag": "cf5fbdaa-7e11-4532-b37a-979970a9e8f4",
"last-modified": "Sat, 18 Dec 2021 00:04:32 GMT",
"opc-content-md5": "1B2M2Y8AsgTpgAmY7PhCfg=="
}

@harshkumar-dev
Copy link
Member

We are able to replicate the issue. We are root causing it. We will keep you posted.

@harshkumar-dev harshkumar-dev changed the title oci os object put from STDIN not working oci os object put from STDIN not working in Cloud shell Dec 18, 2021
@harshkumar-dev harshkumar-dev pinned this issue Dec 18, 2021
@harshkumar-dev
Copy link
Member

Uploading a file using STDIN on Cloudshell (oci os object put --bucket-name Harsh-test --name "Test2" --file - <<<"my test") leads to uploaded object of size 0 byte. This could result in data-loss without any error message on Cloud-shell.

This issue is not been observed on other platforms ( Linux, Mac, Windows).

As a workaround please use an actual file as an input while uploading (oci os object put --bucket-name Harsh-test --name "Test2" --file ).

@kernleee
Copy link
Contributor

Issue was fixed in the latest release, 3.4.1. Cloud shell should have also updated the CLI version as well to latest.
Closing this issue, thank you @RichardExley for finding it.

@harshkumar-dev harshkumar-dev unpinned this issue Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SDK Issue pertains to the SDK itself and not specific to any service
Projects
None yet
Development

No branches or pull requests

4 participants
@RichardExley @kernleee @harshkumar-dev and others