Git Product home page Git Product logo

Comments (3)

chrislusf avatar chrislusf commented on July 22, 2024

Thanks a lot for debugging this! You can send a pull request next time, which will attribute the credit to you!

from glow.

radike avatar radike commented on July 22, 2024

Hi @chrislusf,

I think that the committed fix doesn't solve the issue. The local variable req is a pointer to the loop variable, so the slice still contains only pointers to the loop variable. See http://play.golang.org/p/_fos0OJUkq

I have created additional allocation test that verifies the allocation. There is one server with 2048 MB of memory, and 3 requests that differs in the requested memory: 1024 MB, 512 MB, 256 MB.

The expected is:
master_allocation_test.go:236: Result: &{Allocations:[{Location:{DataCenter:dc1 Rack:rack1 Server:server1 Port:1111} Allocated:CPUCount 1 Level 1 Memory 1024 MB} {Location:{DataCenter:dc1 Rack:rack1 Server:server1 Port:1111} Allocated:CPUCount 1 Level 1 Memory 512 MB} {Location:{DataCenter:dc1 Rack:rack1 Server:server1 Port:1111} Allocated:CPUCount 1 Level 1 Memory 256 MB}] Error:}

but the output before the proposed fix is:
master_allocation_test.go:236: Result: &{Allocations:[{Location:{DataCenter:dc1 Rack:rack1 Server:server1 Port:1111} Allocated:CPUCount 1 Level 1 Memory 256 MB} {Location:{DataCenter:dc1 Rack:rack1 Server:server1 Port:1111} Allocated:CPUCount 1 Level 1 Memory 256 MB} {Location:{DataCenter:dc1 Rack:rack1 Server:server1 Port:1111} Allocated:CPUCount 1 Level 1 Memory 256 MB}] Error:}

from glow.

chrislusf avatar chrislusf commented on July 22, 2024

That's right. Please create a PR to change it from:

for _, request := range []int{1, 2, 3} {
    req := &request
    requests = append(requests, req)
}

to:

for _, request := range []int{1, 2, 3} {
    req := request
    requests = append(requests, &req)
}

from glow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.