Skip to content
This repository was archived by the owner on Aug 31, 2022. It is now read-only.

Add read-only mode#27

Merged
renukamanavalan merged 4 commits intosonic-net:masterfrom
project-arlo:azure_ro_mode
Mar 23, 2020
Merged

Add read-only mode#27
renukamanavalan merged 4 commits intosonic-net:masterfrom
project-arlo:azure_ro_mode

Conversation

@seiferteric
Copy link
Copy Markdown
Contributor

Check for file /etc/sonic/telemetry_readonly and if it exists, gNMI set will be disabled.

@msftclas
Copy link
Copy Markdown

msftclas commented Feb 28, 2020

CLA assistant check
All CLA requirements met.

@renukamanavalan
Copy link
Copy Markdown

Do we need an explicit file for this ?

Can you infer the same through r/w mode of one/more paths mapped into container ?

For example, which path should be mounted as rw for non-read-onlly mode?
And if this path is instead mounted as read-only, you know this run has to be in read-only mode.

@seiferteric
Copy link
Copy Markdown
Contributor Author

I suppose we could put the file in the telemetry container instead of on the host, would this be better?. I am not sure about mounting a volume ro vs rw, I don't know which volume we would use for this or why.

@renukamanavalan
Copy link
Copy Markdown

Curious, what is the difference between read-only & read-write mode for telemetry docker?

@seiferteric
Copy link
Copy Markdown
Contributor Author

There was a request to have a read-only mode for telemetry since some do not want to use telemetry for configuration. The read-only mode will disable the Set() rpc so there is only Get, Subscribe and Capabilities rpc's available.

@renukamanavalan
Copy link
Copy Markdown

Just one more question:
Once an image is built as read-only or read-write mode, can it be changed during runtime?

If not, why can't we use a compile time flag to build it as read-only / read-write?

@seiferteric
Copy link
Copy Markdown
Contributor Author

Using the current method of looking for a file, you could disable read-only mode by removing the file. As for the compile time flag, that is an option as well which I considered. Would it be preferable this way?

@seiferteric
Copy link
Copy Markdown
Contributor Author

When looking at build flags, I thought I would need to make duplicate source files like server.go and server_ro.go for example. However looking at more examples, I could rather have a file like constants_rw.go and constants_ro.go and define a single "const TELEMETRY_RO" in each file which would be set by the build flag. So this is a good option as well. If this is preferred, I can redo this PR to use this method.

@renukamanavalan
Copy link
Copy Markdown

Please check with relevant folks, who were requesting for read-only mode, if this suits.

"An image is built for RO/RW mode as immutable"

@renukamanavalan
Copy link
Copy Markdown

I checked. The mode is burnt into the image. So we can use a build time flag to decide

@seiferteric
Copy link
Copy Markdown
Contributor Author

@renukamanavalan Please see the latest commit. I switched to using a go build flag instead of the file method. Now the readonly mode is set at build time in a constant inside the telemetry binary, so is immutable.

Copy link
Copy Markdown

@renukamanavalan renukamanavalan left a comment

Choose a reason for hiding this comment

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

Can you please help understand how does this BLDFLAG '-tag helps include the correct constant file ?

Makefile Outdated
TEST_FILES=$(wildcard *_test.go)
TELEMETRY_TEST_DIR = $(GO_MGMT_PATH)/build/tests/gnmi_server
TELEMETRY_TEST_BIN = $(TELEMETRY_TEST_DIR)/server.test
ifeq ($(TELEMETRY_READONLY),y)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can we make read-only as default ?

ifeq ($(TELEMETRY_READWITE y') BLD_FLAGS := -tags readwrite
Absence of a flag implies read-only.


package gnmi

const READ_ONLY_MODE = false
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

true

@seiferteric
Copy link
Copy Markdown
Contributor Author

Can you please help understand how does this BLDFLAG '-tag helps include the correct constant file ?

It is a build constraint: https://golang.org/pkg/go/build/#hdr-Build_Constraints
Using the -tags allows you to specify them at build time and determine which files will be included.

Can we make read-only as default ?

Sure I will make this change.

@seiferteric
Copy link
Copy Markdown
Contributor Author

Okay, I have changed the default to read-only.

@lguohan
Copy link
Copy Markdown
Contributor

lguohan commented Mar 23, 2020

suggest to the read-only default.

Copy link
Copy Markdown
Contributor

@lguohan lguohan left a comment

Choose a reason for hiding this comment

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

read only default

@seiferteric
Copy link
Copy Markdown
Contributor Author

read only default

This is already the case. renukamanavalan already requested this in a previous comment and I made the changes to have it readonly by default.

@renukamanavalan renukamanavalan merged commit c97e5c5 into sonic-net:master Mar 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants