Skip to content
Merged
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
20 changes: 11 additions & 9 deletions internal/hcsoci/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"os"
"path/filepath"
"reflect"
"strconv"

"github.com/Microsoft/go-winio/pkg/guid"
Expand Down Expand Up @@ -101,33 +102,34 @@ func verifyCloneContainerSpecs(templateSpec, cloneSpec *specs.Spec) error {

// for annotations check that the values of memory & cpu annotations are same
if templateSpec.Annotations[annotations.ContainerMemorySizeInMB] != cloneSpec.Annotations[annotations.ContainerMemorySizeInMB] {
return fmt.Errorf("memory size limit for template and clone containers can not be different")
return errors.New("memory size limit for template and clone containers can not be different")
}
if templateSpec.Annotations[annotations.ContainerProcessorCount] != cloneSpec.Annotations[annotations.ContainerProcessorCount] {
return fmt.Errorf("processor count for template and clone containers can not be different")
return errors.New("processor count for template and clone containers can not be different")
}
if templateSpec.Annotations[annotations.ContainerProcessorLimit] != cloneSpec.Annotations[annotations.ContainerProcessorLimit] {
return fmt.Errorf("processor limit for template and clone containers can not be different")
return errors.New("processor limit for template and clone containers can not be different")
}

// LayerFolders should be identical except for the last element.
if !cmpSlices(templateSpec.Windows.LayerFolders[:len(templateSpec.Windows.LayerFolders)-1], cloneSpec.Windows.LayerFolders[:len(cloneSpec.Windows.LayerFolders)-1]) {
return fmt.Errorf("layers provided for template container and clone container don't match. Check the image specified in container config")
return errors.New("layers provided for template container and clone container don't match. Check the image specified in container config")
}

if templateSpec.Windows.HyperV != cloneSpec.Windows.HyperV {
return fmt.Errorf("HyperV spec for template and clone containers can not be different")
if !reflect.DeepEqual(templateSpec.Windows.HyperV, cloneSpec.Windows.HyperV) {
return errors.New("HyperV spec for template and clone containers can not be different")
}

if templateSpec.Windows.Network.AllowUnqualifiedDNSQuery != cloneSpec.Windows.Network.AllowUnqualifiedDNSQuery {
return fmt.Errorf("different values for allow unqualified DNS query can not be provided for template and clones")
return errors.New("different values for allow unqualified DNS query can not be provided for template and clones")
}
if templateSpec.Windows.Network.NetworkSharedContainerName != cloneSpec.Windows.Network.NetworkSharedContainerName {
return fmt.Errorf("different network shared name can not be provided for template and clones")
return errors.New("different network shared name can not be provided for template and clones")
}
if !cmpSlices(templateSpec.Windows.Network.DNSSearchList, cloneSpec.Windows.Network.DNSSearchList) {
return fmt.Errorf("different DNS search list can not be provided for template and clones")
return errors.New("different DNS search list can not be provided for template and clones")
}

return nil
}

Expand Down
20 changes: 11 additions & 9 deletions test/vendor/github.com/Microsoft/hcsshim/internal/hcsoci/create.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.