Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/crio.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ crio [GLOBAL OPTIONS] command [COMMAND OPTIONS] [ARGUMENTS...]

**--seccomp-use-default-when-empty**="": Use the default seccomp profile when an empty one is specified (default: false)

**--selinux**: Enable selinux support (default: false)
**--selinux**: Enable selinux support (default: true)

**--separate-pull-cgroup**="": [EXPERIMENTAL] Pull in new cgroup (default: "")

Expand Down
2 changes: 1 addition & 1 deletion docs/crio.conf.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ CRI-O reads its storage defaults from the containers-storage.conf(5) file locate
It is used to check if crio wipe should wipe containers, which should
always happen on a node reboot

**version_file_persist**="/var/lib/crio/version"
**version_file_persist**=""
Location for CRI-O to lay down the persistent version file.
It is used to check if crio wipe should wipe images, which should
only happen when CRI-O has been upgraded
Expand Down
15 changes: 7 additions & 8 deletions internal/version/version.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package version

import (
"bufio"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"reflect"
Expand Down Expand Up @@ -56,14 +54,12 @@ func ShouldCrioWipe(versionFileName string) (bool, error) {

// shouldCrioWipe is an internal function for testing purposes
func shouldCrioWipe(versionFileName, versionString string) (bool, error) {
f, err := os.Open(versionFileName)
if err != nil {
return true, errors.Errorf("version file %s not found: %v", versionFileName, err)
if versionFileName == "" {
return false, nil
}
r := bufio.NewReader(f)
versionBytes, err := ioutil.ReadAll(r)
versionBytes, err := os.ReadFile(versionFileName)
if err != nil {
return true, errors.Errorf("reading version file %s failed: %v", versionFileName, err)
return true, errors.Errorf("version file %s not found: %v", versionFileName, err)
}

// parse the version that was laid down by a previous invocation of crio
Expand Down Expand Up @@ -99,6 +95,9 @@ func LogVersion() {

// writeVersionFile is an internal function for testing purposes
func writeVersionFile(file, gitCommit, version string) error {
if file == "" {
return nil
}
current, err := parseVersionConstant(version, gitCommit)
// Sanity check-this should never happen
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions internal/version/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ var _ = t.Describe("Version", func() {
_, err = ioutil.ReadFile(filename)
Expect(err).To(BeNil())
})
It("should fail to upgrade with unspecified version", func() {
It("should not wipe with empty version file", func() {
upgrade, err := shouldCrioWipe("", tempVersion)
Expect(upgrade).To(BeTrue())
Expect(err).ToNot(BeNil())
Expect(upgrade).To(BeFalse())
Expect(err).To(BeNil())
})
It("should fail to upgrade with empty version file", func() {
tempFileName := tempFileName
Expand Down
17 changes: 8 additions & 9 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,15 +717,14 @@ func DefaultConfig() (*Config, error) {
DockerRegistryUserAgent: useragent.Get(),
},
RootConfig: RootConfig{
Root: storeOpts.GraphRoot,
RunRoot: storeOpts.RunRoot,
Storage: storeOpts.GraphDriverName,
StorageOptions: storeOpts.GraphDriverOptions,
LogDir: "/var/log/crio/pods",
VersionFile: CrioVersionPathTmp,
VersionFilePersist: CrioVersionPathPersist,
CleanShutdownFile: CrioCleanShutdownFile,
InternalWipe: true,
Root: storeOpts.GraphRoot,
RunRoot: storeOpts.RunRoot,
Storage: storeOpts.GraphDriverName,
StorageOptions: storeOpts.GraphDriverOptions,
LogDir: "/var/log/crio/pods",
VersionFile: CrioVersionPathTmp,
CleanShutdownFile: CrioCleanShutdownFile,
InternalWipe: true,
},
APIConfig: APIConfig{
Listen: CrioSocketPath,
Expand Down
4 changes: 0 additions & 4 deletions pkg/config/config_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ const (
// used to check if we should wipe containers
CrioVersionPathTmp = "/var/run/crio/version"

// CrioVersionPathPersist is where the CRI-O version file is located
// used to check whether we've upgraded, and thus need to remove images
CrioVersionPathPersist = "/var/lib/crio/version"

// CrioCleanShutdownFile is the location CRI-O will lay down the clean shutdown file
// that checks whether we've had time to sync before shutting down.
// If not, crio wipe will clear the storage directory.
Expand Down